mirror of
https://github.com/priyanshujain/margin.git
synced 2026-10-04 20:17:03 +00:00
changes
This commit is contained in:
1 parent
47710970c2
commit
fa1c89af63
7 files changed
+213
-1
No files matched your search
@@ -0,0 +1,28 @@
|
||||
export type Width = "narrow" | "medium" | "wide" | "full";
|
||||
|
||||
const KEY = "margin-width";
|
||||
|
||||
const MEASURE: Record<Width, string> = {
|
||||
narrow: "38em",
|
||||
medium: "46em",
|
||||
wide: "62em",
|
||||
full: "80em",
|
||||
};
|
||||
|
||||
export const WIDTH_OPTIONS: { id: Width; label: string }[] = [
|
||||
{ id: "narrow", label: "Narrow" },
|
||||
{ id: "medium", label: "Medium" },
|
||||
{ id: "wide", label: "Wide" },
|
||||
{ id: "full", label: "Full" },
|
||||
];
|
||||
|
||||
export function initialWidth(): Width {
|
||||
const saved = localStorage.getItem(KEY);
|
||||
if (saved && saved in MEASURE) return saved as Width;
|
||||
return "medium";
|
||||
}
|
||||
|
||||
export function applyWidth(width: Width) {
|
||||
document.documentElement.style.setProperty("--measure", MEASURE[width]);
|
||||
localStorage.setItem(KEY, width);
|
||||
}
|
||||
Reference in new issue
Block a user