import type { ReactElement } from "react"; import { Text, View, type StyleProp, type TextStyle, type ViewStyle } from "react-native"; import { StyleSheet } from "react-native-unistyles"; import { formatShortcut, type ShortcutKey } from "@/utils/format-shortcut"; import { getShortcutOs } from "@/utils/shortcut-platform"; export function Shortcut({ keys, chord, style, textStyle, }: { keys?: ShortcutKey[]; chord?: ShortcutKey[][]; style?: StyleProp; textStyle?: StyleProp; }): ReactElement { const displayChord = chord ?? (keys ? [keys] : []); const shortcutOs = getShortcutOs(); const singleCombo = displayChord[0]; if (!singleCombo) { return ; } if (displayChord.length === 1) { return ( {formatShortcut(singleCombo, shortcutOs)} ); } return ( {displayChord.map(function (combo, index) { return ( {formatShortcut(combo, shortcutOs)} ); })} ); } const styles = StyleSheet.create((theme) => ({ badge: { paddingHorizontal: theme.spacing[1], paddingVertical: 2, borderRadius: theme.borderRadius.md, backgroundColor: theme.colors.surface2, borderWidth: theme.borderWidth[1], borderColor: theme.colors.borderAccent, }, sequence: { flexDirection: "row", alignItems: "center", flexWrap: "wrap", gap: theme.spacing[1], }, text: { fontSize: theme.fontSize.xs, fontWeight: theme.fontWeight.normal, color: theme.colors.foregroundMuted, }, }));