mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat(component): shortcut style for tooltip (#7721)
 - New `shortcut` prop for `<Tooltip />` - single key ```tsx <Tooltip shortcut="T" /> ``` - multiple ```tsx <Tooltip shortcut={["⌘", "K"]} /> ``` - Round tooltip's arrow - Use new design system colors - Replace some usage - App sidebar switch - Editor mode switch - New tab (new)
This commit is contained in:
10
packages/frontend/component/src/utils/keyboard-mapping.ts
Normal file
10
packages/frontend/component/src/utils/keyboard-mapping.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { isMacOS } from './platform';
|
||||
|
||||
const macOS = isMacOS();
|
||||
|
||||
export const getCommand = (cmd: '$mod' | '$shift' | '$alt' | string) => {
|
||||
if (cmd === '$mod') return macOS ? '⌘' : 'Ctrl';
|
||||
if (cmd === '$alt') return macOS ? '⌥' : 'Alt';
|
||||
if (cmd === '$shift') return macOS ? '⇧' : 'Shift';
|
||||
return cmd;
|
||||
};
|
||||
4
packages/frontend/component/src/utils/platform.ts
Normal file
4
packages/frontend/component/src/utils/platform.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export function isMacOS() {
|
||||
if (typeof navigator === 'undefined') return false;
|
||||
return navigator.userAgent.indexOf('Mac') !== -1;
|
||||
}
|
||||
Reference in New Issue
Block a user