-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More correctly show platform-localized super keys
- Loading branch information
Showing
1 changed file
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,33 @@ | ||
const GuiLabels = { | ||
linux: { full: "Super", "1u": "Sup.", short: "Su" }, | ||
win32: { full: "Windows", "1u": "Win", short: "W" }, | ||
darwin: { full: "Command", "1u": "Cmd", short: "Cm" }, | ||
win32: { full: "Windows", "1u": "Win", short: "⊞" }, | ||
darwin: { full: "Command", "1u": "Cmd", short: "⌘" }, | ||
default: { full: "Gui", "1u": "Gui", short: "G" }, | ||
}; | ||
export const GuiLabel = GuiLabels.default; // TODO: GuiLabels[process.platform] || GuiLabels.default; | ||
|
||
const getPlatformLabels = () => { | ||
const platform = navigator.platform.toLowerCase(); | ||
const macosPrefix = "mac"; | ||
const windowsPrefixes = ["win"]; | ||
const iosPrefixes = ["iphone", "ipad", "ipod"]; | ||
const linuxPrefix = "linux"; | ||
const androidPrefix = "android"; | ||
|
||
if (platform.startsWith(macosPrefix)) { | ||
return GuiLabels.darwin; | ||
} else if (iosPrefixes.some((prefix) => platform.startsWith(prefix))) { | ||
return GuiLabels.darwin; | ||
} else if (windowsPrefixes.some((prefix) => platform.startsWith(prefix))) { | ||
return GuiLabels.win32; | ||
} else if (platform.startsWith(androidPrefix)) { | ||
return GuiLabels.default; | ||
} else if (platform.startsWith(linuxPrefix)) { | ||
return GuiLabels.linux; | ||
} else { | ||
return GuiLabels.default; | ||
} | ||
}; | ||
|
||
export const GuiLabel = getPlatformLabels(); | ||
|
||
export const GuiShortLabel = GuiLabel.short; |