Skip to content

Commit 0d97c2b

Browse files
committed
feat: add support for platform based shortcut combos
1 parent 861c170 commit 0d97c2b

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

src/Common/Tooltip/ShortcutKeyComboTooltipContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { TooltipProps } from './types'
1+
import { KEYBOARD_KEYS_MAP, TooltipProps } from './types'
22

33
const ShortcutKeyComboTooltipContent = ({ text, combo }: TooltipProps['shortcutKeyCombo']) => (
44
<div className="flexbox dc__gap-8 px-8 py-4 flex-wrap">
55
<span className="lh-18 fs-12 fw-4 cn-0">{text}</span>
66
<div className="flexbox dc__gap-4 dc__align-items-center flex-wrap">
77
{combo.map((key) => (
88
<span key={key} className="shortcut-keys__chip dc__capitalize lh-16 fs-11 fw-5 flex">
9-
{key}
9+
{KEYBOARD_KEYS_MAP[key]}
1010
</span>
1111
))}
1212
</div>

src/Common/Tooltip/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { default as Tooltip } from './Tooltip'
2+
export type { SupportedKeyboardKeysType } from './types'

src/Common/Tooltip/types.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import { TippyProps } from '@tippyjs/react'
22

3+
const isMacOS = navigator.userAgent.toUpperCase().includes('MAC')
4+
5+
export const KEYBOARD_KEYS_MAP = {
6+
Control: isMacOS ? '⌘' : 'Ctrl',
7+
Shift: '⇧',
8+
F: 'F',
9+
} as const
10+
11+
export type SupportedKeyboardKeysType = keyof typeof KEYBOARD_KEYS_MAP
12+
313
type BaseTooltipProps =
414
| {
515
/**
@@ -52,7 +62,7 @@ type BaseTooltipProps =
5262
*/
5363
shortcutKeyCombo?: {
5464
text: string
55-
combo: string[]
65+
combo: SupportedKeyboardKeysType[]
5666
}
5767
}
5868

src/Shared/Components/CICDHistory/LogsRenderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ export const LogsRenderer = ({
445445
<Tooltip
446446
shortcutKeyCombo={{
447447
text: areAllStagesExpanded ? 'Collapse all stages' : 'Expand all stages',
448-
combo: ['Ctrl / ⌘', '', 'F'],
448+
combo: ['Control', 'Shift', 'F'] as const,
449449
}}
450450
className="dc__mxw-500"
451451
placement="left"

0 commit comments

Comments
 (0)