* initial commit * use colours! * match by scoring * scroll job card into view * introduce @ based 'locks' to restrict search to specific statuses * clear lock states on close * split up component * inline pill * resuse job row content * fix intro anim * larger size, instruction * refactor existing search feature * lock colour border * if active, clear active on escape * remove query param * documenration update * scoring logic * check exists before scroll * status dot and checkbox occupy the same space!
35 lines
948 B
TypeScript
35 lines
948 B
TypeScript
interface NavigatorLike {
|
|
platform?: string;
|
|
userAgent?: string;
|
|
}
|
|
|
|
const isApplePlatform = (value: string) =>
|
|
/(mac|iphone|ipad|ipod)/i.test(value);
|
|
|
|
const getRuntimeNavigator = (): NavigatorLike | null => {
|
|
if (typeof navigator === "undefined") return null;
|
|
return navigator;
|
|
};
|
|
|
|
export const getMetaKeyLabel = (
|
|
nav: NavigatorLike | null = getRuntimeNavigator(),
|
|
) => {
|
|
const platform = nav?.platform ?? "";
|
|
const userAgent = nav?.userAgent ?? "";
|
|
return isApplePlatform(`${platform} ${userAgent}`) ? "⌘" : "Ctrl";
|
|
};
|
|
|
|
export const getMetaShortcutLabel = (
|
|
key: string,
|
|
nav: NavigatorLike | null = getRuntimeNavigator(),
|
|
) => {
|
|
const normalizedKey = key.trim().toUpperCase();
|
|
const meta = getMetaKeyLabel(nav);
|
|
return meta === "⌘" ? `${meta}${normalizedKey}` : `${meta}+${normalizedKey}`;
|
|
};
|
|
|
|
export const isMetaKeyPressed = (event: {
|
|
metaKey: boolean;
|
|
ctrlKey: boolean;
|
|
}) => event.metaKey || event.ctrlKey;
|