Skip to content

Commit

Permalink
fix: display cmd icon for macs (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
j4k0xb committed Jun 8, 2024
1 parent 2974a0c commit c1fa1d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions apps/playground/src/components/menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { For, createSignal, onCleanup, onMount } from 'solid-js';
import { setSettings, settings, type Settings } from '../../hooks/useSettings';
import { useWorkspaces, type Workspace } from '../../indexeddb';
import { openFile } from '../../utils/files';
import { ctrlCmdIcon } from '../../utils/platform';
import MenuButton from './MenuButton';
import MenuDropdown from './MenuDropdown';
import MenuHeader from './MenuHeader';
Expand Down Expand Up @@ -42,7 +43,7 @@ export default function Menu(props: Props) {
onOpen={() => setOpenedMenu('file')}
>
<MenuButton
shortcut={['Ctrl', 'O']}
shortcut={[ctrlCmdIcon, 'O']}
onClick={() => openFile(props.onFileOpen)}
>
Open File…
Expand All @@ -62,7 +63,7 @@ export default function Menu(props: Props) {
)}
</For>
</MenuDropdown>
<MenuButton shortcut={['Ctrl', 'S']} onClick={props.onSave}>
<MenuButton shortcut={[ctrlCmdIcon, 'S']} onClick={props.onSave}>
Save
</MenuButton>
</MenuHeader>
Expand Down
9 changes: 9 additions & 0 deletions apps/playground/src/utils/platform.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const isMacintosh = navigator.userAgent.includes('Macintosh');
const isIOS =
(navigator.userAgent.includes('Macintosh') ||
navigator.userAgent.includes('iPad') ||
navigator.userAgent.includes('iPhone')) &&
!!navigator.maxTouchPoints &&
navigator.maxTouchPoints > 0;

export const ctrlCmdIcon = isMacintosh || isIOS ? '⌘' : 'Ctrl';

0 comments on commit c1fa1d6

Please sign in to comment.