Skip to content

Commit

Permalink
Added nice keybinding rendering for different platforms.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuznietsov committed Oct 12, 2023
1 parent c3f60cf commit bf1a37a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/src/demo/tables/editableTable/ProjectTableDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,26 +191,31 @@ export function ProjectTableDemo() {
};
}, [keydownHandler]);

const getKeybindingWithControl = (keybindingWithoutControl: string) => {
const controlKey = navigator.platform.indexOf('Mac') === 0 ? '⌘' : 'Ctrl';
return `${controlKey} + ${keybindingWithoutControl}`;
};

return (
<Panel cx={ css.container }>
<FlexRow spacing="18" padding="24" vPadding="18" borderBottom={ true } background="gray5">
<FlexCell width="auto">
<Tooltip content="Ctrl + Enter / ⌘ + Enter" placement="bottom">
<Tooltip content={ getKeybindingWithControl('Enter') } placement="bottom">
<Button size="30" icon={ add } caption="Add Task" onClick={ () => insertTask('bottom') } />
</Tooltip>
</FlexCell>
<FlexCell width="auto">
<Tooltip content="Ctrl + Enter / ⌘ + Enter" placement="bottom">
<Tooltip content={ getKeybindingWithControl('Enter') } placement="bottom">
<IconButton icon={ insertAfter } onClick={ () => insertTask('bottom', selectedItem) } />
</Tooltip>
</FlexCell>
<FlexCell width="auto">
<Tooltip content="Ctrl + Shift + Enter / ⌘ + Shift + Enter" placement="bottom">
<Tooltip content={ getKeybindingWithControl('Shift + Enter') } placement="bottom">
<IconButton icon={ insertBefore } onClick={ () => insertTask('top', selectedItem) } />
</Tooltip>
</FlexCell>
<FlexCell width="auto">
<Tooltip content="Ctrl + Backspace / ⌘ + Backspace" placement="bottom">
<Tooltip content={ getKeybindingWithControl('Backspace') } placement="bottom">
<IconButton icon={ deleteLast } onClick={ () => deleteSelectedItem() } />
</Tooltip>
</FlexCell>
Expand Down

0 comments on commit bf1a37a

Please sign in to comment.