Skip to content

Commit f67c131

Browse files
committed
New shortcut key style variant
1 parent ddbf70d commit f67c131

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

apps/webapp/app/components/primitives/ShortcutKey.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ import { cn } from "~/utils/cn";
88
import { useOperatingSystem } from "./OperatingSystemProvider";
99
import { KeyboardEnterIcon } from "~/assets/icons/KeyboardEnterIcon";
1010

11+
const small =
12+
"justify-center text-[0.6rem] font-mono font-medium min-w-[1rem] min-h-[1rem] rounded-[2px] tabular-nums px-1 ml-1 -mr-0.5 flex items-center gap-x-1 border transition uppercase";
13+
1114
const medium =
1215
"justify-center min-w-[1.25rem] min-h-[1.25rem] text-[0.65rem] font-mono font-medium rounded-[2px] tabular-nums px-1 ml-1 -mr-0.5 flex items-center gap-x-1.5 border border-dimmed/40 text-text-dimmed group-hover:text-text-bright/80 group-hover:border-dimmed/60 transition uppercase";
1316

1417
export const variants = {
15-
small:
16-
"justify-center text-[0.6rem] font-mono font-medium min-w-[1rem] min-h-[1rem] rounded-[2px] tabular-nums px-1 ml-1 -mr-0.5 flex items-center gap-x-1 border border-text-dimmed/40 text-text-dimmed group-hover:text-text-bright/80 group-hover:border-text-dimmed/60 transition uppercase",
18+
small: cn(small, "border-text-dimmed/40 text-text-dimmed group-hover:text-text-bright/80 group-hover:border-text-dimmed/60"),
19+
"small/bright": cn(small, "bg-charcoal-750 text-text-bright border-charcoal-650"),
1720
medium: cn(medium, "group-hover:border-charcoal-550"),
1821
"medium/bright": cn(medium, "bg-charcoal-750 text-text-bright border-charcoal-650"),
1922
};
@@ -54,10 +57,10 @@ export function ShortcutKey({ shortcut, variant, className }: ShortcutKeyProps)
5457
);
5558
}
5659

57-
function keyString(key: string, isMac: boolean, variant: "small" | "medium" | "medium/bright") {
60+
function keyString(key: string, isMac: boolean, variant: ShortcutKeyVariant) {
5861
key = key.toLowerCase();
5962

60-
const className = variant === "small" ? "w-2.5 h-4" : "w-2.5 h-4.5";
63+
const className = variant.startsWith("small") ? "w-2.5 h-4" : "w-2.5 h-4.5";
6164

6265
switch (key) {
6366
case "enter":
@@ -86,9 +89,9 @@ function keyString(key: string, isMac: boolean, variant: "small" | "medium" | "m
8689
function modifierString(
8790
modifier: Modifier,
8891
isMac: boolean,
89-
variant: "small" | "medium" | "medium/bright"
92+
variant: ShortcutKeyVariant
9093
): string | JSX.Element {
91-
const className = variant === "small" ? "w-2.5 h-4" : "w-3.5 h-5";
94+
const className = variant.startsWith("small") ? "w-2.5 h-4" : "w-3.5 h-5";
9295

9396
switch (modifier) {
9497
case "alt":

0 commit comments

Comments
 (0)