fix: Bag 'o fixes

Remove menu hover styles on mobile
Fixed duplicate hover+active behavior on editor menus
Fixed editor menus visibly scroll to the top when reopened
Fixed some minor editor spacing issues
Renamed shred routeHelpers -> urlHelpers
This commit is contained in:
Tom Moor
2022-01-25 23:43:11 -08:00
parent 13b8ed58fd
commit 175857753e
21 changed files with 103 additions and 64 deletions

17
app/utils/browser.ts Normal file
View File

@@ -0,0 +1,17 @@
/**
* Returns true if the client is a touch device.
*/
export function isTouchDevice(): boolean {
if (typeof window === "undefined") {
return false;
}
return window.matchMedia?.("(hover: none) and (pointer: coarse)")?.matches;
}
/**
* Returns true if the client is running on a Mac.
*/
export function isMac(): boolean {
const SSR = typeof window === "undefined";
return !SSR && window.navigator.platform === "MacIntel";
}

View File

@@ -1,11 +1,11 @@
const isMac = window.navigator.platform === "MacIntel";
import { isMac } from "~/utils/browser";
export const metaDisplay = isMac ? "⌘" : "Ctrl";
export const metaDisplay = isMac() ? "⌘" : "Ctrl";
export const meta = isMac ? "cmd" : "ctrl";
export const meta = isMac() ? "cmd" : "ctrl";
export function isModKey(
event: KeyboardEvent | MouseEvent | React.KeyboardEvent
) {
return isMac ? event.metaKey : event.ctrlKey;
return isMac() ? event.metaKey : event.ctrlKey;
}