@doneisbetter/gds-theme 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-E55P7FOX.mjs +226 -0
- package/dist/chunk-TAPLA36E.mjs +354 -0
- package/dist/client.d.mts +36 -4
- package/dist/client.d.ts +36 -4
- package/dist/client.js +309 -13
- package/dist/client.mjs +16 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +309 -13
- package/dist/index.mjs +16 -2
- package/dist/server.d.mts +27 -1
- package/dist/server.d.ts +27 -1
- package/dist/server.js +142 -4
- package/dist/server.mjs +11 -1
- package/package.json +1 -1
- package/styles.css +1 -0
- package/dist/chunk-QTH2PIZY.mjs +0 -66
- package/dist/chunk-Z5I7D255.mjs +0 -221
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyGdsFontLane,
|
|
3
|
+
gdsTheme,
|
|
4
|
+
getGdsFontLanes,
|
|
5
|
+
getGdsThemePresets,
|
|
6
|
+
resolveGdsThemePreset
|
|
7
|
+
} from "./chunk-TAPLA36E.mjs";
|
|
8
|
+
|
|
9
|
+
// src/theme-runtime.ts
|
|
10
|
+
import { useCallback, useEffect, useState } from "react";
|
|
11
|
+
var defaultStorageKey = "gds-theme-preset-selection";
|
|
12
|
+
function isThemePresetId(value) {
|
|
13
|
+
return typeof value === "string" && getGdsThemePresets().some((preset) => preset.id === value);
|
|
14
|
+
}
|
|
15
|
+
function isFontLaneId(value) {
|
|
16
|
+
return typeof value === "string" && getGdsFontLanes().some((lane) => lane.id === value);
|
|
17
|
+
}
|
|
18
|
+
function isScheme(value) {
|
|
19
|
+
return value === "light" || value === "dark" || value === "auto";
|
|
20
|
+
}
|
|
21
|
+
function resolveEffectiveScheme(preset, colorScheme) {
|
|
22
|
+
if (preset === "dark-public" || preset === "neon-night") {
|
|
23
|
+
return "dark";
|
|
24
|
+
}
|
|
25
|
+
return colorScheme;
|
|
26
|
+
}
|
|
27
|
+
function createGdsThemePresetSelection(stored = {}) {
|
|
28
|
+
const preset = isThemePresetId(stored.preset) ? stored.preset : "default";
|
|
29
|
+
const requestedColorScheme = isScheme(stored.colorScheme) ? stored.colorScheme : "light";
|
|
30
|
+
const colorScheme = resolveEffectiveScheme(preset, requestedColorScheme);
|
|
31
|
+
const fontLane = isFontLaneId(stored.fontLane) ? stored.fontLane : "inter";
|
|
32
|
+
const brandPrimary = typeof stored.brandPrimary === "string" ? stored.brandPrimary : "blue";
|
|
33
|
+
const brandFlatSurfaces = typeof stored.brandFlatSurfaces === "boolean" ? stored.brandFlatSurfaces : true;
|
|
34
|
+
const brandEditorialSerif = typeof stored.brandEditorialSerif === "boolean" ? stored.brandEditorialSerif : false;
|
|
35
|
+
const runtimeKey = `${preset}-${colorScheme}-${brandPrimary}-${brandFlatSurfaces}-${brandEditorialSerif}-${fontLane}`;
|
|
36
|
+
return {
|
|
37
|
+
preset,
|
|
38
|
+
colorScheme,
|
|
39
|
+
theme: applyGdsFontLane(resolveGdsThemePreset(preset, {
|
|
40
|
+
brandPrimary,
|
|
41
|
+
brandFlatSurfaces,
|
|
42
|
+
brandEditorialSerif
|
|
43
|
+
}), fontLane),
|
|
44
|
+
fontLane,
|
|
45
|
+
runtimeKey,
|
|
46
|
+
brandPrimary,
|
|
47
|
+
brandFlatSurfaces,
|
|
48
|
+
brandEditorialSerif
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function readStoredSelection(storageKey, initialSelection) {
|
|
52
|
+
if (typeof window === "undefined") {
|
|
53
|
+
return createGdsThemePresetSelection(initialSelection);
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const stored = window.localStorage.getItem(storageKey);
|
|
57
|
+
return createGdsThemePresetSelection(stored ? JSON.parse(stored) : initialSelection);
|
|
58
|
+
} catch {
|
|
59
|
+
return createGdsThemePresetSelection(initialSelection);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function persistSelection(storageKey, selection) {
|
|
63
|
+
if (typeof window === "undefined") {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const stored = {
|
|
67
|
+
preset: selection.preset,
|
|
68
|
+
colorScheme: selection.colorScheme,
|
|
69
|
+
fontLane: selection.fontLane,
|
|
70
|
+
runtimeKey: selection.runtimeKey,
|
|
71
|
+
brandPrimary: selection.brandPrimary,
|
|
72
|
+
brandFlatSurfaces: selection.brandFlatSurfaces,
|
|
73
|
+
brandEditorialSerif: selection.brandEditorialSerif
|
|
74
|
+
};
|
|
75
|
+
try {
|
|
76
|
+
window.localStorage.setItem(storageKey, JSON.stringify(stored));
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function resolveDocumentScheme(selection) {
|
|
81
|
+
if (selection.colorScheme !== "auto") {
|
|
82
|
+
return selection.colorScheme;
|
|
83
|
+
}
|
|
84
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
85
|
+
}
|
|
86
|
+
function applyDocumentRuntime(selection) {
|
|
87
|
+
document.documentElement.setAttribute("data-mantine-color-scheme", resolveDocumentScheme(selection));
|
|
88
|
+
document.documentElement.setAttribute("data-gds-theme-runtime", selection.runtimeKey ?? `${selection.preset}-${selection.colorScheme}`);
|
|
89
|
+
document.documentElement.setAttribute("data-gds-font-lane", selection.fontLane);
|
|
90
|
+
}
|
|
91
|
+
function useGdsThemePresetState({
|
|
92
|
+
storageKey = defaultStorageKey,
|
|
93
|
+
initialSelection,
|
|
94
|
+
applyToDocument = true
|
|
95
|
+
} = {}) {
|
|
96
|
+
const [selection, setSelection] = useState(() => readStoredSelection(storageKey, initialSelection));
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (applyToDocument) {
|
|
99
|
+
applyDocumentRuntime(selection);
|
|
100
|
+
}
|
|
101
|
+
persistSelection(storageKey, selection);
|
|
102
|
+
if (!applyToDocument || selection.colorScheme !== "auto") {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
106
|
+
const handleChange = () => applyDocumentRuntime(selection);
|
|
107
|
+
mediaQuery.addEventListener("change", handleChange);
|
|
108
|
+
return () => {
|
|
109
|
+
mediaQuery.removeEventListener("change", handleChange);
|
|
110
|
+
};
|
|
111
|
+
}, [applyToDocument, selection, storageKey]);
|
|
112
|
+
const setRuntimeSelection = useCallback((nextSelection) => {
|
|
113
|
+
setSelection(createGdsThemePresetSelection(nextSelection));
|
|
114
|
+
}, []);
|
|
115
|
+
const setPreset = useCallback((preset) => {
|
|
116
|
+
setSelection((current) => createGdsThemePresetSelection({ ...current, preset }));
|
|
117
|
+
}, []);
|
|
118
|
+
const setScheme = useCallback((colorScheme) => {
|
|
119
|
+
setSelection((current) => createGdsThemePresetSelection({ ...current, colorScheme }));
|
|
120
|
+
}, []);
|
|
121
|
+
const setFontLane = useCallback((fontLane) => {
|
|
122
|
+
setSelection((current) => createGdsThemePresetSelection({ ...current, fontLane }));
|
|
123
|
+
}, []);
|
|
124
|
+
const setBrandOptions = useCallback((options) => {
|
|
125
|
+
setSelection((current) => createGdsThemePresetSelection({ ...current, ...options }));
|
|
126
|
+
}, []);
|
|
127
|
+
const reset = useCallback(() => {
|
|
128
|
+
setSelection(createGdsThemePresetSelection(initialSelection));
|
|
129
|
+
}, [initialSelection]);
|
|
130
|
+
return {
|
|
131
|
+
selection,
|
|
132
|
+
setSelection: setRuntimeSelection,
|
|
133
|
+
setPreset,
|
|
134
|
+
setScheme,
|
|
135
|
+
setFontLane,
|
|
136
|
+
setBrandOptions,
|
|
137
|
+
reset
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// src/i18n.ts
|
|
142
|
+
import { createContext, useContext } from "react";
|
|
143
|
+
var GdsI18nContext = createContext({
|
|
144
|
+
locale: "en",
|
|
145
|
+
messages: {}
|
|
146
|
+
});
|
|
147
|
+
function useGdsTranslation() {
|
|
148
|
+
const { messages, locale } = useContext(GdsI18nContext);
|
|
149
|
+
return {
|
|
150
|
+
t: (id, defaultMessage) => messages[id] || defaultMessage,
|
|
151
|
+
locale
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/GdsProvider.tsx
|
|
156
|
+
import { MantineProvider, DirectionProvider, Box } from "@mantine/core";
|
|
157
|
+
import { ModalsProvider } from "@mantine/modals";
|
|
158
|
+
import { Notifications } from "@mantine/notifications";
|
|
159
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
160
|
+
function GdsProvider({
|
|
161
|
+
children,
|
|
162
|
+
locale = "en",
|
|
163
|
+
messages = {},
|
|
164
|
+
theme = gdsTheme,
|
|
165
|
+
defaultColorScheme = "light",
|
|
166
|
+
forceColorScheme
|
|
167
|
+
}) {
|
|
168
|
+
const isRtl = ["ar", "he"].includes(locale);
|
|
169
|
+
const dir = isRtl ? "rtl" : "ltr";
|
|
170
|
+
return /* @__PURE__ */ jsx(DirectionProvider, { initialDirection: dir, children: /* @__PURE__ */ jsx(GdsI18nContext.Provider, { value: { locale, messages }, children: /* @__PURE__ */ jsx(
|
|
171
|
+
MantineProvider,
|
|
172
|
+
{
|
|
173
|
+
theme,
|
|
174
|
+
withCssVariables: true,
|
|
175
|
+
withGlobalClasses: true,
|
|
176
|
+
defaultColorScheme,
|
|
177
|
+
forceColorScheme,
|
|
178
|
+
children: /* @__PURE__ */ jsx(ModalsProvider, { children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
179
|
+
/* @__PURE__ */ jsx(Notifications, {}),
|
|
180
|
+
/* @__PURE__ */ jsx(
|
|
181
|
+
Box,
|
|
182
|
+
{
|
|
183
|
+
dir,
|
|
184
|
+
mih: "100vh",
|
|
185
|
+
h: "100%",
|
|
186
|
+
bg: "var(--mantine-color-body)",
|
|
187
|
+
c: "var(--mantine-color-text)",
|
|
188
|
+
style: { transition: "background-color 120ms ease, color 120ms ease" },
|
|
189
|
+
children
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
] }) })
|
|
193
|
+
}
|
|
194
|
+
) }) });
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/notifications.ts
|
|
198
|
+
import { notifications } from "@mantine/notifications";
|
|
199
|
+
var toneColorMap = {
|
|
200
|
+
success: "teal",
|
|
201
|
+
error: "red",
|
|
202
|
+
warning: "yellow",
|
|
203
|
+
info: "blue",
|
|
204
|
+
neutral: "gray"
|
|
205
|
+
};
|
|
206
|
+
function showGdsNotification({
|
|
207
|
+
message,
|
|
208
|
+
title,
|
|
209
|
+
tone = "info",
|
|
210
|
+
autoClose
|
|
211
|
+
}) {
|
|
212
|
+
notifications.show({
|
|
213
|
+
message,
|
|
214
|
+
title,
|
|
215
|
+
color: toneColorMap[tone],
|
|
216
|
+
autoClose
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export {
|
|
221
|
+
createGdsThemePresetSelection,
|
|
222
|
+
useGdsThemePresetState,
|
|
223
|
+
useGdsTranslation,
|
|
224
|
+
GdsProvider,
|
|
225
|
+
showGdsNotification
|
|
226
|
+
};
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
// src/theme.ts
|
|
2
|
+
import { DEFAULT_THEME, createTheme, mergeMantineTheme, mergeThemeOverrides } from "@mantine/core";
|
|
3
|
+
var baseTheme = mergeMantineTheme(DEFAULT_THEME, createTheme({
|
|
4
|
+
primaryColor: "violet",
|
|
5
|
+
fontFamily: "Inter, system-ui, Avenir, Helvetica, Arial, sans-serif",
|
|
6
|
+
fontSmoothing: true,
|
|
7
|
+
defaultRadius: "md",
|
|
8
|
+
black: "#111827",
|
|
9
|
+
white: "#ffffff",
|
|
10
|
+
headings: {
|
|
11
|
+
fontFamily: "Inter, system-ui, Avenir, Helvetica, Arial, sans-serif",
|
|
12
|
+
sizes: {
|
|
13
|
+
h1: { fontSize: "2.5rem", fontWeight: "800" },
|
|
14
|
+
h2: { fontSize: "1.75rem", fontWeight: "700" },
|
|
15
|
+
h3: { fontSize: "1.25rem", fontWeight: "600" }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
shadows: {
|
|
19
|
+
md: "0 8px 24px rgba(15, 23, 42, 0.08)",
|
|
20
|
+
lg: "0 16px 40px rgba(15, 23, 42, 0.12)"
|
|
21
|
+
},
|
|
22
|
+
components: {
|
|
23
|
+
Button: {
|
|
24
|
+
defaultProps: {
|
|
25
|
+
radius: "md",
|
|
26
|
+
size: "sm",
|
|
27
|
+
fw: 600
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
Card: {
|
|
31
|
+
defaultProps: {
|
|
32
|
+
radius: "lg",
|
|
33
|
+
shadow: "sm",
|
|
34
|
+
withBorder: true
|
|
35
|
+
},
|
|
36
|
+
styles: {
|
|
37
|
+
root: {
|
|
38
|
+
background: "var(--mantine-color-body)"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
Paper: {
|
|
43
|
+
defaultProps: {
|
|
44
|
+
radius: "lg",
|
|
45
|
+
withBorder: true
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
TextInput: {
|
|
49
|
+
defaultProps: {
|
|
50
|
+
radius: "md"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
Table: {
|
|
54
|
+
defaultProps: {
|
|
55
|
+
highlightOnHover: true,
|
|
56
|
+
verticalSpacing: "md"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
Badge: {
|
|
60
|
+
defaultProps: {
|
|
61
|
+
radius: "xl"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
var gdsTheme = baseTheme;
|
|
67
|
+
var gdsDarkPublicTheme = extendGdsTheme({
|
|
68
|
+
primaryColor: "violet",
|
|
69
|
+
components: {
|
|
70
|
+
AppShell: {
|
|
71
|
+
styles: {
|
|
72
|
+
main: {
|
|
73
|
+
background: "var(--mantine-color-dark-8)"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
Card: {
|
|
78
|
+
styles: {
|
|
79
|
+
root: {
|
|
80
|
+
background: "var(--mantine-color-dark-7)",
|
|
81
|
+
borderColor: "var(--mantine-color-dark-4)"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
Paper: {
|
|
86
|
+
styles: {
|
|
87
|
+
root: {
|
|
88
|
+
background: "var(--mantine-color-dark-7)",
|
|
89
|
+
borderColor: "var(--mantine-color-dark-4)"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
Table: {
|
|
94
|
+
styles: {
|
|
95
|
+
table: {
|
|
96
|
+
color: "var(--mantine-color-gray-0)"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
var gdsFlatSurfaceTheme = extendGdsTheme({
|
|
103
|
+
shadows: {
|
|
104
|
+
xs: "none",
|
|
105
|
+
sm: "none",
|
|
106
|
+
md: "none",
|
|
107
|
+
lg: "none",
|
|
108
|
+
xl: "none"
|
|
109
|
+
},
|
|
110
|
+
components: {
|
|
111
|
+
Card: {
|
|
112
|
+
defaultProps: {
|
|
113
|
+
shadow: void 0,
|
|
114
|
+
withBorder: true
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
Paper: {
|
|
118
|
+
defaultProps: {
|
|
119
|
+
withBorder: true
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
var gdsEditorialPublicTheme = extendGdsTheme({
|
|
125
|
+
headings: {
|
|
126
|
+
fontFamily: '"Instrument Serif", Georgia, "Times New Roman", serif',
|
|
127
|
+
sizes: {
|
|
128
|
+
h1: { fontSize: "2.75rem", fontWeight: "700" },
|
|
129
|
+
h2: { fontSize: "2rem", fontWeight: "700" },
|
|
130
|
+
h3: { fontSize: "1.375rem", fontWeight: "600" }
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
shadows: {
|
|
134
|
+
xs: "none",
|
|
135
|
+
sm: "none",
|
|
136
|
+
md: "none",
|
|
137
|
+
lg: "none",
|
|
138
|
+
xl: "none"
|
|
139
|
+
},
|
|
140
|
+
components: {
|
|
141
|
+
Card: {
|
|
142
|
+
defaultProps: {
|
|
143
|
+
shadow: void 0,
|
|
144
|
+
withBorder: true
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
Paper: {
|
|
148
|
+
defaultProps: {
|
|
149
|
+
withBorder: true
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
function composeGdsTheme(overrides = {}) {
|
|
155
|
+
return mergeMantineTheme(baseTheme, overrides);
|
|
156
|
+
}
|
|
157
|
+
function createPublicBrandTheme({
|
|
158
|
+
editorialSerif = false,
|
|
159
|
+
flatSurfaces = false,
|
|
160
|
+
overrides = {}
|
|
161
|
+
} = {}) {
|
|
162
|
+
const layeredOverrides = [];
|
|
163
|
+
if (flatSurfaces) {
|
|
164
|
+
layeredOverrides.push(gdsFlatSurfaceTheme);
|
|
165
|
+
}
|
|
166
|
+
if (editorialSerif) {
|
|
167
|
+
layeredOverrides.push(gdsEditorialPublicTheme);
|
|
168
|
+
}
|
|
169
|
+
layeredOverrides.push(overrides);
|
|
170
|
+
const mergedOverrides = layeredOverrides.reduce(
|
|
171
|
+
(theme, layer) => mergeThemeOverrides(theme, layer),
|
|
172
|
+
{}
|
|
173
|
+
);
|
|
174
|
+
return composeGdsTheme(mergedOverrides);
|
|
175
|
+
}
|
|
176
|
+
function extendGdsTheme(overrides = {}) {
|
|
177
|
+
return composeGdsTheme(overrides);
|
|
178
|
+
}
|
|
179
|
+
function withGdsMotion(overrides = {}) {
|
|
180
|
+
return extendGdsTheme(
|
|
181
|
+
mergeThemeOverrides(
|
|
182
|
+
{
|
|
183
|
+
components: {
|
|
184
|
+
Button: {
|
|
185
|
+
styles: {
|
|
186
|
+
root: {
|
|
187
|
+
transition: "transform 150ms ease, filter 120ms ease",
|
|
188
|
+
"&:hover": {
|
|
189
|
+
transform: "translateY(-1px)",
|
|
190
|
+
filter: "brightness(1.05)"
|
|
191
|
+
},
|
|
192
|
+
"&:active": {
|
|
193
|
+
transform: "translateY(0)",
|
|
194
|
+
filter: "brightness(0.95)"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
Card: {
|
|
200
|
+
styles: {
|
|
201
|
+
root: {
|
|
202
|
+
transition: "transform 150ms ease, box-shadow 150ms ease"
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
overrides
|
|
209
|
+
)
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// src/theme-presets.ts
|
|
214
|
+
function createVibrantPresetTheme(primaryColor, options = {}) {
|
|
215
|
+
const darkSurface = options.darkForward ? `color-mix(in srgb, var(--mantine-color-${primaryColor}-9) 18%, var(--mantine-color-dark-8))` : "var(--mantine-color-dark-8)";
|
|
216
|
+
return extendGdsTheme({
|
|
217
|
+
primaryColor,
|
|
218
|
+
components: {
|
|
219
|
+
AppShell: {
|
|
220
|
+
styles: {
|
|
221
|
+
main: {
|
|
222
|
+
background: `light-dark(color-mix(in srgb, var(--mantine-color-${primaryColor}-0) 58%, var(--mantine-color-white)), ${darkSurface})`
|
|
223
|
+
},
|
|
224
|
+
header: {
|
|
225
|
+
background: `light-dark(color-mix(in srgb, var(--mantine-color-${primaryColor}-0) 68%, var(--mantine-color-white)), var(--mantine-color-dark-8))`,
|
|
226
|
+
borderColor: `light-dark(var(--mantine-color-${primaryColor}-2), var(--mantine-color-dark-5))`
|
|
227
|
+
},
|
|
228
|
+
navbar: {
|
|
229
|
+
background: `light-dark(color-mix(in srgb, var(--mantine-color-${primaryColor}-0) 48%, var(--mantine-color-white)), var(--mantine-color-dark-8))`,
|
|
230
|
+
borderColor: `light-dark(var(--mantine-color-${primaryColor}-2), var(--mantine-color-dark-5))`
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
Card: {
|
|
235
|
+
styles: {
|
|
236
|
+
root: {
|
|
237
|
+
background: `light-dark(var(--mantine-color-white), color-mix(in srgb, var(--mantine-color-${primaryColor}-9) 10%, var(--mantine-color-dark-7)))`,
|
|
238
|
+
borderColor: `light-dark(var(--mantine-color-${primaryColor}-2), var(--mantine-color-dark-4))`
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
Paper: {
|
|
243
|
+
styles: {
|
|
244
|
+
root: {
|
|
245
|
+
background: `light-dark(color-mix(in srgb, var(--mantine-color-${primaryColor}-0) 16%, var(--mantine-color-white)), color-mix(in srgb, var(--mantine-color-${primaryColor}-9) 8%, var(--mantine-color-dark-7)))`,
|
|
246
|
+
borderColor: `light-dark(var(--mantine-color-${primaryColor}-2), var(--mantine-color-dark-4))`
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
var customPresetThemes = {
|
|
254
|
+
sunset: createVibrantPresetTheme("orange"),
|
|
255
|
+
oceanic: createVibrantPresetTheme("cyan"),
|
|
256
|
+
forest: createVibrantPresetTheme("green"),
|
|
257
|
+
ruby: createVibrantPresetTheme("red"),
|
|
258
|
+
amber: createVibrantPresetTheme("yellow"),
|
|
259
|
+
"neon-night": createVibrantPresetTheme("lime", { darkForward: true }),
|
|
260
|
+
skyline: createVibrantPresetTheme("indigo"),
|
|
261
|
+
aurora: createVibrantPresetTheme("teal"),
|
|
262
|
+
coral: createVibrantPresetTheme("pink"),
|
|
263
|
+
mint: createVibrantPresetTheme("lime"),
|
|
264
|
+
orchid: createVibrantPresetTheme("grape"),
|
|
265
|
+
royal: createVibrantPresetTheme("violet")
|
|
266
|
+
};
|
|
267
|
+
var themePresetCatalog = [
|
|
268
|
+
{ id: "default", label: "Default runtime theme", description: "Balanced, neutral baseline lane.", runtimeLane: "gdsTheme" },
|
|
269
|
+
{ id: "dark-public", label: "Dark public theme", description: "Dark-first public lane.", runtimeLane: "gdsDarkPublicTheme" },
|
|
270
|
+
{ id: "flat-surface", label: "Flat surface theme", description: "Lower-elevation operational lane.", runtimeLane: "gdsFlatSurfaceTheme" },
|
|
271
|
+
{ id: "editorial", label: "Editorial serif theme", description: "Reading-first, serif headline lane.", runtimeLane: "gdsEditorialPublicTheme" },
|
|
272
|
+
{ id: "brand", label: "Brand theme generator", description: "Governed brand composition lane.", runtimeLane: "createPublicBrandTheme(...)" },
|
|
273
|
+
{ id: "sunset", label: "Sunset pulse", description: "Warm orange-magenta vibrant lane.", runtimeLane: "resolveGdsThemePreset(sunset)" },
|
|
274
|
+
{ id: "oceanic", label: "Oceanic wave", description: "Cool cyan-blue vibrant lane.", runtimeLane: "resolveGdsThemePreset(oceanic)" },
|
|
275
|
+
{ id: "forest", label: "Forest signal", description: "Natural emerald-driven vibrant lane.", runtimeLane: "resolveGdsThemePreset(forest)" },
|
|
276
|
+
{ id: "ruby", label: "Ruby spark", description: "Bold red high-contrast lane.", runtimeLane: "resolveGdsThemePreset(ruby)" },
|
|
277
|
+
{ id: "amber", label: "Amber glow", description: "Golden yellow energetic lane.", runtimeLane: "resolveGdsThemePreset(amber)" },
|
|
278
|
+
{ id: "neon-night", label: "Neon night", description: "Lime-accented dark-forward lane.", runtimeLane: "resolveGdsThemePreset(neon-night)" },
|
|
279
|
+
{ id: "skyline", label: "Skyline indigo", description: "Indigo technology-forward lane.", runtimeLane: "resolveGdsThemePreset(skyline)" },
|
|
280
|
+
{ id: "aurora", label: "Aurora teal", description: "Fresh teal-cyan app lane for optimistic product surfaces.", runtimeLane: "resolveGdsThemePreset(aurora)" },
|
|
281
|
+
{ id: "coral", label: "Coral bloom", description: "Expressive pink-coral lane for creator, commerce, and social products.", runtimeLane: "resolveGdsThemePreset(coral)" },
|
|
282
|
+
{ id: "mint", label: "Mint circuit", description: "Clean green-mint lane for health, learning, and growth products.", runtimeLane: "resolveGdsThemePreset(mint)" },
|
|
283
|
+
{ id: "orchid", label: "Orchid signal", description: "Purple-grape lane for editorial, culture, and premium tools.", runtimeLane: "resolveGdsThemePreset(orchid)" },
|
|
284
|
+
{ id: "royal", label: "Royal violet", description: "Confident violet lane for SaaS dashboards and professional apps.", runtimeLane: "resolveGdsThemePreset(royal)" }
|
|
285
|
+
];
|
|
286
|
+
function getGdsThemePresets() {
|
|
287
|
+
return themePresetCatalog;
|
|
288
|
+
}
|
|
289
|
+
function resolveGdsThemePreset(id, options) {
|
|
290
|
+
switch (id) {
|
|
291
|
+
case "default":
|
|
292
|
+
return gdsTheme;
|
|
293
|
+
case "dark-public":
|
|
294
|
+
return gdsDarkPublicTheme;
|
|
295
|
+
case "flat-surface":
|
|
296
|
+
return gdsFlatSurfaceTheme;
|
|
297
|
+
case "editorial":
|
|
298
|
+
return gdsEditorialPublicTheme;
|
|
299
|
+
case "brand":
|
|
300
|
+
return createPublicBrandTheme({
|
|
301
|
+
editorialSerif: options?.brandEditorialSerif ?? false,
|
|
302
|
+
flatSurfaces: options?.brandFlatSurfaces ?? true,
|
|
303
|
+
overrides: { primaryColor: options?.brandPrimary ?? "blue" }
|
|
304
|
+
});
|
|
305
|
+
default:
|
|
306
|
+
return customPresetThemes[id] ?? gdsTheme;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// src/font-lanes.ts
|
|
311
|
+
import { mergeThemeOverrides as mergeThemeOverrides2 } from "@mantine/core";
|
|
312
|
+
var lanes = [
|
|
313
|
+
{ id: "inter", label: "Inter", body: "Inter, system-ui, sans-serif", heading: "Inter, system-ui, sans-serif", mono: "ui-monospace, SFMono-Regular, Menlo, monospace" },
|
|
314
|
+
{ id: "manrope", label: "Manrope", body: "Manrope, system-ui, sans-serif", heading: "Manrope, system-ui, sans-serif", mono: "ui-monospace, SFMono-Regular, Menlo, monospace" },
|
|
315
|
+
{ id: "space-grotesk", label: "Space Grotesk", body: '"Space Grotesk", Inter, system-ui, sans-serif', heading: '"Space Grotesk", Inter, system-ui, sans-serif', mono: "ui-monospace, SFMono-Regular, Menlo, monospace" },
|
|
316
|
+
{ id: "plus-jakarta", label: "Plus Jakarta Sans", body: '"Plus Jakarta Sans", Inter, system-ui, sans-serif', heading: '"Plus Jakarta Sans", Inter, system-ui, sans-serif', mono: "ui-monospace, SFMono-Regular, Menlo, monospace" },
|
|
317
|
+
{ id: "nunito", label: "Nunito", body: "Nunito, Inter, system-ui, sans-serif", heading: "Nunito, Inter, system-ui, sans-serif", mono: "ui-monospace, SFMono-Regular, Menlo, monospace" },
|
|
318
|
+
{ id: "work-sans", label: "Work Sans", body: '"Work Sans", Inter, system-ui, sans-serif', heading: '"Work Sans", Inter, system-ui, sans-serif', mono: "ui-monospace, SFMono-Regular, Menlo, monospace" },
|
|
319
|
+
{ id: "barlow", label: "Barlow", body: "Barlow, Inter, system-ui, sans-serif", heading: "Barlow, Inter, system-ui, sans-serif", mono: "ui-monospace, SFMono-Regular, Menlo, monospace" },
|
|
320
|
+
{ id: "dm-sans", label: "DM Sans", body: '"DM Sans", Inter, system-ui, sans-serif', heading: '"DM Sans", Inter, system-ui, sans-serif', mono: "ui-monospace, SFMono-Regular, Menlo, monospace" },
|
|
321
|
+
{ id: "instrument-serif", label: "Instrument Serif", body: "Inter, system-ui, sans-serif", heading: '"Instrument Serif", Georgia, serif', mono: "ui-monospace, SFMono-Regular, Menlo, monospace" },
|
|
322
|
+
{ id: "source-serif", label: "Source Serif", body: '"Source Serif 4", Georgia, serif', heading: '"Source Serif 4", Georgia, serif', mono: "ui-monospace, SFMono-Regular, Menlo, monospace" }
|
|
323
|
+
];
|
|
324
|
+
function getGdsFontLanes() {
|
|
325
|
+
return lanes;
|
|
326
|
+
}
|
|
327
|
+
function resolveGdsFontLane(id) {
|
|
328
|
+
return lanes.find((lane) => lane.id === id) ?? lanes[0];
|
|
329
|
+
}
|
|
330
|
+
function applyGdsFontLane(theme, laneId) {
|
|
331
|
+
const lane = resolveGdsFontLane(laneId);
|
|
332
|
+
return mergeThemeOverrides2(theme, {
|
|
333
|
+
fontFamily: lane.body,
|
|
334
|
+
fontFamilyMonospace: lane.mono,
|
|
335
|
+
headings: {
|
|
336
|
+
fontFamily: lane.heading
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export {
|
|
342
|
+
gdsTheme,
|
|
343
|
+
gdsDarkPublicTheme,
|
|
344
|
+
gdsFlatSurfaceTheme,
|
|
345
|
+
gdsEditorialPublicTheme,
|
|
346
|
+
createPublicBrandTheme,
|
|
347
|
+
extendGdsTheme,
|
|
348
|
+
withGdsMotion,
|
|
349
|
+
getGdsThemePresets,
|
|
350
|
+
resolveGdsThemePreset,
|
|
351
|
+
getGdsFontLanes,
|
|
352
|
+
resolveGdsFontLane,
|
|
353
|
+
applyGdsFontLane
|
|
354
|
+
};
|
package/dist/client.d.mts
CHANGED
|
@@ -1,7 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
import { GdsThemePresetId, GdsFontLaneId } from './server.mjs';
|
|
2
|
+
export { GdsFontLane, GdsThemePreset, applyGdsFontLane, createPublicBrandTheme, extendGdsTheme, gdsDarkPublicTheme, gdsEditorialPublicTheme, gdsFlatSurfaceTheme, gdsTheme, getGdsFontLanes, getGdsThemePresets, resolveGdsFontLane, resolveGdsThemePreset, withGdsMotion } from './server.mjs';
|
|
3
|
+
import { MantineThemeOverride } from '@mantine/core';
|
|
2
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
5
|
import React from 'react';
|
|
4
|
-
|
|
6
|
+
|
|
7
|
+
type GdsThemeScheme = 'light' | 'dark' | 'auto';
|
|
8
|
+
interface GdsStoredThemePresetState {
|
|
9
|
+
preset: GdsThemePresetId;
|
|
10
|
+
colorScheme: GdsThemeScheme;
|
|
11
|
+
fontLane: GdsFontLaneId;
|
|
12
|
+
runtimeKey?: string;
|
|
13
|
+
brandPrimary?: string;
|
|
14
|
+
brandFlatSurfaces?: boolean;
|
|
15
|
+
brandEditorialSerif?: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface GdsThemePresetSelection extends GdsStoredThemePresetState {
|
|
18
|
+
theme: MantineThemeOverride;
|
|
19
|
+
}
|
|
20
|
+
interface UseGdsThemePresetStateOptions {
|
|
21
|
+
storageKey?: string;
|
|
22
|
+
initialSelection?: Partial<GdsStoredThemePresetState>;
|
|
23
|
+
applyToDocument?: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface UseGdsThemePresetStateResult {
|
|
26
|
+
selection: GdsThemePresetSelection;
|
|
27
|
+
setSelection: (selection: Partial<GdsStoredThemePresetState>) => void;
|
|
28
|
+
setPreset: (preset: GdsThemePresetId) => void;
|
|
29
|
+
setScheme: (scheme: GdsThemeScheme) => void;
|
|
30
|
+
setFontLane: (fontLane: GdsFontLaneId) => void;
|
|
31
|
+
setBrandOptions: (options: Pick<GdsStoredThemePresetState, 'brandPrimary' | 'brandFlatSurfaces' | 'brandEditorialSerif'>) => void;
|
|
32
|
+
reset: () => void;
|
|
33
|
+
}
|
|
34
|
+
declare function createGdsThemePresetSelection(stored?: Partial<GdsStoredThemePresetState>): GdsThemePresetSelection;
|
|
35
|
+
declare function useGdsThemePresetState({ storageKey, initialSelection, applyToDocument, }?: UseGdsThemePresetStateOptions): UseGdsThemePresetStateResult;
|
|
5
36
|
|
|
6
37
|
interface GdsProviderProps {
|
|
7
38
|
children: React.ReactNode;
|
|
@@ -9,12 +40,13 @@ interface GdsProviderProps {
|
|
|
9
40
|
messages?: Record<string, string>;
|
|
10
41
|
theme?: MantineThemeOverride;
|
|
11
42
|
defaultColorScheme?: 'light' | 'dark' | 'auto';
|
|
43
|
+
forceColorScheme?: 'light' | 'dark';
|
|
12
44
|
}
|
|
13
45
|
/**
|
|
14
46
|
* GdsProvider is the single required root provider for any application
|
|
15
47
|
* adopting the General Design System. It injects the strict Mantine theme.
|
|
16
48
|
*/
|
|
17
|
-
declare function GdsProvider({ children, locale, messages, theme, defaultColorScheme, }: GdsProviderProps): react_jsx_runtime.JSX.Element;
|
|
49
|
+
declare function GdsProvider({ children, locale, messages, theme, defaultColorScheme, forceColorScheme, }: GdsProviderProps): react_jsx_runtime.JSX.Element;
|
|
18
50
|
|
|
19
51
|
/**
|
|
20
52
|
* useGdsTranslation provides a lightweight translation hook.
|
|
@@ -35,4 +67,4 @@ interface GdsNotificationOptions {
|
|
|
35
67
|
}
|
|
36
68
|
declare function showGdsNotification({ message, title, tone, autoClose, }: GdsNotificationOptions): void;
|
|
37
69
|
|
|
38
|
-
export { type GdsNotificationOptions, type GdsNotificationTone, GdsProvider, type GdsProviderProps, showGdsNotification, useGdsTranslation };
|
|
70
|
+
export { GdsFontLaneId, type GdsNotificationOptions, type GdsNotificationTone, GdsProvider, type GdsProviderProps, type GdsStoredThemePresetState, GdsThemePresetId, type GdsThemePresetSelection, type GdsThemeScheme, type UseGdsThemePresetStateOptions, type UseGdsThemePresetStateResult, createGdsThemePresetSelection, showGdsNotification, useGdsThemePresetState, useGdsTranslation };
|