docs: handle step tooltip bug in safari (#10954)

This commit is contained in:
Shahed Nasser
2025-01-14 12:08:59 +02:00
committed by GitHub
parent fa5d1b65fd
commit cf62a0a43c
4 changed files with 54 additions and 12 deletions

View File

@@ -1,8 +0,0 @@
export function getOsShortcut() {
const isMacOs =
typeof navigator !== "undefined"
? navigator.userAgent.toLowerCase().indexOf("mac") !== 0
: true
return isMacOs ? "⌘" : "Ctrl"
}

View File

@@ -5,7 +5,7 @@ export * from "./decode-str"
export * from "./dom-utils"
export * from "./get-link-with-base-path"
export * from "./get-navbar-items"
export * from "./get-os-shortcut"
export * from "./os-browser-utils"
export * from "./get-scrolled-top"
export * from "./is-elm-window"
export * from "./is-in-view"

View File

@@ -0,0 +1,39 @@
export function getBrowser():
| "Chrome"
| "Safari"
| "Firefox"
| "Internet Explorer"
| "Edge"
| "unknown" {
if (typeof navigator === "undefined") {
return "unknown"
}
const userAgent = navigator.userAgent.toLowerCase()
if (userAgent.indexOf("chrome") > -1) {
return "Chrome"
} else if (userAgent.indexOf("safari") > -1) {
return "Safari"
} else if (userAgent.indexOf("firefox") > -1) {
return "Firefox"
} else if (
userAgent.indexOf("msie") > -1 ||
userAgent.indexOf("trident") > -1
) {
return "Internet Explorer"
} else if (userAgent.indexOf("edge") > -1) {
return "Edge"
} else {
return "unknown"
}
}
export function getOsShortcut() {
const isMacOs =
typeof navigator !== "undefined"
? navigator.userAgent.toLowerCase().indexOf("mac") !== 0
: true
return isMacOs ? "⌘" : "Ctrl"
}