diff --git a/packages/bbui/src/Menu/Item.svelte b/packages/bbui/src/Menu/Item.svelte index 495bb8d71f..ba103460c0 100644 --- a/packages/bbui/src/Menu/Item.svelte +++ b/packages/bbui/src/Menu/Item.svelte @@ -10,6 +10,21 @@ export let noClose = false export let keyBind = undefined + $: keys = getKeys(keyBind) + + const getKeys = keyBind => { + let keys = keyBind?.split("+") || [] + for (let i = 0; i < keys.length; i++) { + if ( + keys[i].toLowerCase() === "ctrl" && + navigator.platform.startsWith("Mac") + ) { + keys[i] = "⌘" + } + } + return keys + } + const onClick = () => { if (actionMenu && !noClose) { actionMenu.hide() @@ -37,9 +52,13 @@ {/if} - {#if keyBind} -
- {keyBind} + {#if keys?.length} +
+ {#each keys as key} +
+ {key} +
+ {/each}
{/if} @@ -48,14 +67,26 @@ .spectrum-Menu-itemIcon { align-self: center; } - .keyBind { - margin-left: var(--spacing-xl); - color: var(--spectrum-global-color-gray-600); - text-transform: uppercase; + .keys { + margin-left: 30px; + display: flex; + flex-direction: row; + justify-content: flex-end; + align-items: center; + gap: 4px; + } + .key { + color: var(--spectrum-global-color-gray-900); + padding: 2px 4px; font-size: 12px; font-weight: 600; + background-color: var(--spectrum-global-color-gray-300); + border-radius: 4px; + min-width: 12px; + text-align: center; + margin: -1px 0; } - .is-disabled .keyBind { - color: var(--spectrum-global-color-gray-300); + .is-disabled .key { + color: var(--spectrum-global-color-gray-600); }