diff options
| author | Maze Winther <mazewinther@gmail.com> | 2025-07-18 11:27:02 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2025-07-18 11:27:02 +0200 |
| commit | c4e6a9a45ab0f0afdde4f0c9991e39cd5d6205d0 (patch) | |
| tree | 6edf33d7d4e4ddca3049caff5f77bbdf5f303a65 /apps/web/src/lib/utils.ts | |
| parent | dc5416da07c28ff1b2e6d1a9695f1eb70902fe0c (diff) | |
| parent | b19db0bbea168f757fe1f6c7ff254128373cc593 (diff) | |
| download | opencut-c4e6a9a45ab0f0afdde4f0c9991e39cd5d6205d0.tar.gz | |
Merge branch 'feat/kbd' into staging
Diffstat (limited to 'apps/web/src/lib/utils.ts')
| -rw-r--r-- | apps/web/src/lib/utils.ts | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/apps/web/src/lib/utils.ts b/apps/web/src/lib/utils.ts index dd73059f..fd47cc13 100644 --- a/apps/web/src/lib/utils.ts +++ b/apps/web/src/lib/utils.ts @@ -13,7 +13,10 @@ export function cn(...inputs: ClassValue[]) { */ export function generateUUID(): string { // Use the native crypto.randomUUID if available - if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') { + if ( + typeof crypto !== "undefined" && + typeof crypto.randomUUID === "function" + ) { return crypto.randomUUID(); } @@ -26,13 +29,29 @@ export function generateUUID(): string { // Set variant 10xxxxxx bytes[8] = (bytes[8] & 0x3f) | 0x80; - const hex = [...bytes].map(b => b.toString(16).padStart(2, '0')); + const hex = [...bytes].map((b) => b.toString(16).padStart(2, "0")); return ( - hex.slice(0, 4).join('') + '-' + - hex.slice(4, 6).join('') + '-' + - hex.slice(6, 8).join('') + '-' + - hex.slice(8, 10).join('') + '-' + - hex.slice(10, 16).join('') + hex.slice(0, 4).join("") + + "-" + + hex.slice(4, 6).join("") + + "-" + + hex.slice(6, 8).join("") + + "-" + + hex.slice(8, 10).join("") + + "-" + + hex.slice(10, 16).join("") ); -}
\ No newline at end of file +} + +export function isAppleDevice() { + return /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform); +} + +export function getPlatformSpecialKey() { + return isAppleDevice() ? "⌘" : "Ctrl"; +} + +export function getPlatformAlternateKey() { + return isAppleDevice() ? "⌥" : "Alt"; +} |
