diff --git a/src/components/stem/index.tsx b/src/components/stem/index.tsx index ec1f678..8f43286 100644 --- a/src/components/stem/index.tsx +++ b/src/components/stem/index.tsx @@ -193,7 +193,7 @@ const ScoutbarStemCell: React.FC<{ ); const options: ActionOptions = { - close: (val = false) => setScoutbarReveal?.(val), + close: setScoutbarReveal, clearSearch: () => setInputValue?.(''), // ... }; diff --git a/src/helpers/action-helpers.ts b/src/helpers/action-helpers.ts index 3189c8d..3f02928 100644 --- a/src/helpers/action-helpers.ts +++ b/src/helpers/action-helpers.ts @@ -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; } @@ -19,6 +18,7 @@ export interface IScoutAction { target?: string; rel?: string; keyboardShortcut?: string[]; + disableIdledAction?: boolean; icon?: HTMLElement | string; description?: string; ariaLabel?: string; diff --git a/src/utils/constants.ts b/src/utils/constants.ts new file mode 100644 index 0000000..58b2ae3 --- /dev/null +++ b/src/utils/constants.ts @@ -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']; diff --git a/src/utils/index.ts b/src/utils/index.ts index a02f2a8..22332ca 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -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); +};