Skip to content

Commit

Permalink
(chore): updated stem and constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
adenekan41 committed Dec 26, 2022
1 parent 3aabddd commit 3075316
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/stem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ const ScoutbarStemCell: React.FC<{
);

const options: ActionOptions = {
close: (val = false) => setScoutbarReveal?.(val),
close: setScoutbarReveal,
clearSearch: () => setInputValue?.(''),
// ...
};
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/action-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* --------------------------- Internal Dependency -------------------------- */
import React from 'react';
import { guidGenerator } from 'utils';

export interface ActionOptions {
close?: (val?: boolean) => void;
close?: (value: boolean) => void;
clearSearch?: () => void;
}

Expand All @@ -19,6 +18,7 @@ export interface IScoutAction {
target?: string;
rel?: string;
keyboardShortcut?: string[];
disableIdledAction?: boolean;
icon?: HTMLElement | string;
description?: string;
ariaLabel?: string;
Expand Down
6 changes: 6 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { getOS } from 'utils';

export const SCOUTBAR_ROOT_ID = 'scoutbar___root';
export const FOCUSABLE_ELEMENTS = `body > div:not(#${SCOUTBAR_ROOT_ID})`;
export const ROOT_SHORTCUT =
getOS() === 'Mac' ? ['meta', 'k'] : ['control', 'k'];
17 changes: 17 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,20 @@ export const getOS = () => {

return os;
};

export const print = (
data: string,
type: 'error' | 'warn' = 'warn',
isSystemDefault = false
) => {
const message = `%c[${type === 'error' ? '⛔️' : '⚠️'} Scoutbar]: ${data}`;
const options = `color: ${
type === 'error' ? '#eb1c1c' : '#ae832c'
}; font-weight: bold; background: #eaeaea; padding: 5px; border-radius: 5px; border: 2px solid ${
type === 'error' ? '#eb1c1c' : '#ae832c'
}; font-size: 13px; font-family: sans-serif;`;

if (isSystemDefault) return console[type](message, options);

return console.log(message, options);
};

0 comments on commit 3075316

Please sign in to comment.