Skip to content

Commit

Permalink
Hotkeys visual tweeks
Browse files Browse the repository at this point in the history
  • Loading branch information
OzzyCzech committed Dec 6, 2023
1 parent 3e597ff commit 398b2ef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
12 changes: 11 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,21 @@
console.log('You activate the "A" action');
}
},
},
{
title: 'The "A" action',
hotkey: 'd i a l o g',
description: 'Do something',
onAction(event) {
if (!/TEXTAREA|INPUT|CMD-DIALOG/.test(event.target.tagName)) {
console.log('You activate the "A" action');
}
},
}
);

dialog.actions = actions;
//dialog.open();
dialog.open();
</script>
</main>
</body>
Expand Down
16 changes: 9 additions & 7 deletions src/cmd-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ export class CmdAction extends LitElement {
private get hotkeys() {
if (this.action?.hotkey) {
const hotkeys = this.action.hotkey
.replace('$mod', /Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent) ? '⌘' : 'Ctrl')
.replace('Meta', '⌘')
.replace('Control', '⌃')
.replace('Shift', '⇧')
.replace('Alt', '⌥')
.replace('Control', '⌃')
.split('+');
.replaceAll('$mod', /Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent) ? '⌘' : 'Ctrl')
.replaceAll('Meta', '<span>⌘</span>')
.replaceAll('Control', '⌃')
.replaceAll('Shift', '⇧')
.replaceAll('Alt', '⌥')
.replaceAll('Control', '⌃')
.replaceAll('+', '')
.replaceAll(' ', '')
.split('|');
return hotkeys.length > 0 ? html`<span>${repeat(hotkeys, hotkey => html`<kbd part="kbd">${hotkey}</kbd>`)}</span>` : '';
}

Expand Down
2 changes: 1 addition & 1 deletion src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
}

kbd {
@apply font-mono font-semibold whitespace-nowrap text-center;
@apply font-mono font-semibold whitespace-nowrap text-center tracking-wider;
@apply rounded-sm bg-neutral-700/20 dark:bg-neutral-800;
@apply inline-block px-1 mx-0.5 leading-normal;
@apply min-w-[1.3rem];
Expand Down

1 comment on commit 398b2ef

@vercel
Copy link

@vercel vercel bot commented on 398b2ef Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

cmd-dialog – ./

cmd-dialog-ozzyczech.vercel.app
cmd-dialog.vercel.app
cmd-dialog-git-main-ozzyczech.vercel.app

Please sign in to comment.