Skip to content

Commit 267bb3c

Browse files
committed
feat(demo): add the Theme Builder page
Grouped controls with per-control reset edit a light and a dark GridTheme on a live grid (toolbar, pinned column, selection, row grouping, column menu). Start from a built-in preset, copy or download the theme as TypeScript with only non-default values, share it through the URL hash, check WCAG AA contrast, and edit every key as JSON. The route hides the table of contents so controls and preview fit side by side; narrower pages get a drawer. The demo smoke test also runs the page in Firefox and WebKit.
1 parent 7ac131f commit 267bb3c

8 files changed

Lines changed: 1500 additions & 5 deletions

File tree

‎demo/App.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const ServerSideTreeDemo = lazy(() =>
3434
);
3535
const ServerSideAggregationDemo = lazy(() => import('./examples/ServerSideAggregationDemo/ServerSideAggregationDemo'));
3636
const ThemingDemo = lazy(() => import('./examples/ThemingDemo/ThemingDemo'));
37+
const ThemeBuilderDemo = lazy(() => import('./examples/ThemeBuilderDemo/ThemeBuilderDemo'));
3738
const StatePersistenceDemo = lazy(() => import('./examples/StatePersistenceDemo/StatePersistenceDemo'));
3839
const PivotModeDemo = lazy(() => import('./examples/PivotModeDemo/PivotModeDemo'));
3940
const ListViewDemo = lazy(() => import('./examples/ListViewDemo/ListViewDemo'));
@@ -114,6 +115,8 @@ const examplesConfig = [
114115
// Customization
115116
{ path: '/locale-text', name: 'Locale Text (i18n)', component: LocaleTextDemo, category: 'Customization' },
116117
{ path: '/theming', name: 'Theming', component: ThemingDemo, category: 'Customization' },
118+
// fullWidth: no table of contents column, so the controls and the preview fit side by side.
119+
{ path: '/theme-builder', name: 'Theme Builder', component: ThemeBuilderDemo, category: 'Customization', fullWidth: true },
117120
{ path: '/list-view', name: 'List View', component: ListViewDemo, category: 'Customization' },
118121
{ path: '/slots', name: 'Slots & Renderers', component: SlotsDemo, category: 'Customization' },
119122

@@ -138,14 +141,15 @@ function PageWrapper({ children }: { children: React.ReactNode }) {
138141
// Check if current route is in 'Resources' category
139142
const currentConfig = examplesConfig.find(item => item.path === location.pathname);
140143
const isResourcePage = currentConfig?.category === 'Resources';
144+
const isFullWidth = isResourcePage || currentConfig?.fullWidth === true;
141145

142146
// Automatically extract TOC from current page, except for Resources
143147
return (
144148
<div className="app-page-wrapper" key={location.pathname}>
145-
<div className={`app-content-column ${isResourcePage ? 'app-content-column--full-width' : ''}`}>
149+
<div className={`app-content-column ${isFullWidth ? 'app-content-column--full-width' : ''}`}>
146150
{children}
147151
</div>
148-
{!isResourcePage && <Toc />}
152+
{!isFullWidth && <Toc />}
149153
</div>
150154
);
151155
}
Lines changed: 358 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,358 @@
1+
/* Theme Builder page. The page itself stays in the demo site's light look; only the preview is themed. */
2+
.tb {
3+
container-type: inline-size;
4+
container-name: tb;
5+
display: flex;
6+
flex-direction: column;
7+
gap: 12px;
8+
color: #1f2937;
9+
font-size: 0.875rem;
10+
}
11+
12+
.tb__bar {
13+
display: flex;
14+
flex-wrap: wrap;
15+
align-items: center;
16+
gap: 12px;
17+
}
18+
19+
.tb-segment {
20+
display: inline-flex;
21+
border: 1px solid #d1d5db;
22+
border-radius: 8px;
23+
overflow: hidden;
24+
}
25+
.tb-segment__btn {
26+
padding: 6px 16px;
27+
border: none;
28+
background: #fff;
29+
color: #374151;
30+
font: inherit;
31+
cursor: pointer;
32+
}
33+
.tb-segment__btn + .tb-segment__btn {
34+
border-inline-start: 1px solid #d1d5db;
35+
}
36+
.tb-segment__btn--on {
37+
background: #1e293b;
38+
color: #fff;
39+
font-weight: 600;
40+
}
41+
.tb-segment__btn:focus-visible {
42+
outline: 2px solid #3b82f6;
43+
outline-offset: -2px;
44+
}
45+
46+
.tb-presets {
47+
display: flex;
48+
flex-wrap: wrap;
49+
align-items: center;
50+
gap: 6px;
51+
}
52+
.tb-presets__label {
53+
color: #6b7280;
54+
margin-inline-end: 2px;
55+
}
56+
57+
.tb-drawer-toggle {
58+
display: none;
59+
margin-inline-start: auto;
60+
}
61+
62+
.tb__layout {
63+
display: grid;
64+
grid-template-columns: 290px minmax(0, 1fr);
65+
gap: 16px;
66+
align-items: start;
67+
}
68+
69+
/* ── Controls panel ─────────────────────────────────────────────────────── */
70+
.tb-controls {
71+
position: sticky;
72+
top: 12px;
73+
max-height: calc(100vh - 24px);
74+
overflow: auto;
75+
border: 1px solid #e5e7eb;
76+
border-radius: 10px;
77+
background: #fafafa;
78+
}
79+
.tb-controls__drawer-head {
80+
display: none;
81+
}
82+
.tb-controls__inner {
83+
display: flex;
84+
flex-direction: column;
85+
}
86+
.tb-controls__top {
87+
display: flex;
88+
align-items: center;
89+
justify-content: space-between;
90+
padding: 10px 12px;
91+
border-bottom: 1px solid #e5e7eb;
92+
}
93+
.tb-controls__title {
94+
font-weight: 600;
95+
}
96+
97+
.tb-group {
98+
border-bottom: 1px solid #e5e7eb;
99+
}
100+
.tb-group__summary {
101+
display: flex;
102+
align-items: center;
103+
gap: 8px;
104+
padding: 10px 12px;
105+
font-weight: 600;
106+
cursor: pointer;
107+
user-select: none;
108+
}
109+
.tb-group__summary:focus-visible {
110+
outline: 2px solid #3b82f6;
111+
outline-offset: -2px;
112+
}
113+
.tb-group__count {
114+
min-width: 18px;
115+
padding: 0 6px;
116+
border-radius: 999px;
117+
background: #dbeafe;
118+
color: #1d4ed8;
119+
font-size: 0.75rem;
120+
text-align: center;
121+
}
122+
.tb-group__body {
123+
display: flex;
124+
flex-direction: column;
125+
gap: 10px;
126+
padding: 4px 12px 14px;
127+
}
128+
129+
.tb-field {
130+
display: flex;
131+
flex-direction: column;
132+
gap: 4px;
133+
}
134+
.tb-field__head {
135+
display: flex;
136+
align-items: center;
137+
justify-content: space-between;
138+
gap: 8px;
139+
}
140+
.tb-field__label {
141+
color: #374151;
142+
}
143+
.tb-field--changed .tb-field__label {
144+
font-weight: 600;
145+
color: #111827;
146+
}
147+
.tb-field--changed .tb-field__label::after {
148+
content: ' •';
149+
color: #2563eb;
150+
}
151+
.tb-reset.ogx-button {
152+
padding: 0 6px;
153+
min-height: 0;
154+
font-size: 0.75rem;
155+
}
156+
.tb-field__row {
157+
display: flex;
158+
align-items: center;
159+
gap: 8px;
160+
}
161+
.tb-field__row > .ogx-input-wrapper,
162+
.tb-field__stack > .ogx-input-wrapper {
163+
flex: 1 1 auto;
164+
min-width: 0;
165+
}
166+
.tb-field__stack {
167+
display: flex;
168+
flex-direction: column;
169+
gap: 6px;
170+
}
171+
.tb-swatch {
172+
flex: 0 0 auto;
173+
width: 36px;
174+
height: 30px;
175+
padding: 2px;
176+
border: 1px solid #d1d5db;
177+
border-radius: 6px;
178+
background: #fff;
179+
cursor: pointer;
180+
}
181+
.tb-select {
182+
height: 30px;
183+
padding: 0 6px;
184+
border: 1px solid #d1d5db;
185+
border-radius: 6px;
186+
background: #fff;
187+
color: inherit;
188+
font: inherit;
189+
}
190+
.tb-range {
191+
flex: 1 1 auto;
192+
min-width: 0;
193+
accent-color: #2563eb;
194+
}
195+
.tb-range__value {
196+
flex: 0 0 44px;
197+
text-align: end;
198+
font-variant-numeric: tabular-nums;
199+
color: #4b5563;
200+
}
201+
202+
.tb-contrast {
203+
font-size: 0.75rem;
204+
line-height: 1.4;
205+
}
206+
.tb-contrast--ok {
207+
color: #047857;
208+
}
209+
.tb-contrast--warn {
210+
color: #b45309;
211+
}
212+
.tb-contrast--unknown {
213+
color: #6b7280;
214+
}
215+
216+
.tb-hint {
217+
margin: 0;
218+
color: #6b7280;
219+
font-size: 0.8rem;
220+
}
221+
222+
/* ── Preview and output ─────────────────────────────────────────────────── */
223+
.tb-main {
224+
display: flex;
225+
flex-direction: column;
226+
gap: 12px;
227+
min-width: 0;
228+
}
229+
.tb-preview__bar,
230+
.tb-output__actions {
231+
display: flex;
232+
flex-wrap: wrap;
233+
align-items: center;
234+
gap: 10px;
235+
}
236+
.tb-inline {
237+
display: inline-flex;
238+
align-items: center;
239+
gap: 6px;
240+
color: #374151;
241+
}
242+
.tb-preview {
243+
padding: 16px;
244+
border-radius: 12px;
245+
border: 1px solid #e5e7eb;
246+
}
247+
.tb-preview--light {
248+
background: #f8fafc;
249+
}
250+
.tb-preview--dark {
251+
background: #020617;
252+
border-color: #1e293b;
253+
}
254+
255+
.tb-output {
256+
display: flex;
257+
flex-direction: column;
258+
gap: 10px;
259+
}
260+
.tb-status {
261+
color: #047857;
262+
font-size: 0.8rem;
263+
}
264+
.tb-contrast-list {
265+
display: flex;
266+
flex-wrap: wrap;
267+
gap: 4px 14px;
268+
}
269+
.tb-contrast-list__title {
270+
flex-basis: 100%;
271+
font-weight: 600;
272+
}
273+
.tb-code {
274+
margin: 0;
275+
max-height: 320px;
276+
overflow: auto;
277+
padding: 12px 14px;
278+
border-radius: 8px;
279+
background: #0f172a;
280+
color: #e2e8f0;
281+
font-size: 0.8rem;
282+
line-height: 1.5;
283+
}
284+
285+
.tb-json {
286+
display: flex;
287+
flex-direction: column;
288+
gap: 8px;
289+
}
290+
.tb-json__area {
291+
min-height: 220px;
292+
padding: 8px;
293+
border: 1px solid #d1d5db;
294+
border-radius: 6px;
295+
font-family: ui-monospace, Menlo, monospace;
296+
font-size: 0.75rem;
297+
resize: vertical;
298+
}
299+
.tb-json__actions {
300+
display: flex;
301+
align-items: center;
302+
gap: 8px;
303+
}
304+
.tb-json__error {
305+
color: #b91c1c;
306+
font-size: 0.8rem;
307+
}
308+
309+
.tb-backdrop {
310+
display: none;
311+
}
312+
313+
/* ── Narrow: the controls move into a drawer ────────────────────────────── */
314+
@container tb (max-width: 680px) {
315+
.tb__layout {
316+
grid-template-columns: minmax(0, 1fr);
317+
}
318+
.tb-drawer-toggle {
319+
display: inline-flex;
320+
}
321+
.tb-controls {
322+
position: fixed;
323+
inset-block: 0;
324+
inset-inline-start: 0;
325+
top: 0;
326+
z-index: 2001;
327+
width: min(360px, 90vw);
328+
max-height: none;
329+
border-radius: 0;
330+
transform: translateX(-100%);
331+
transition: transform 0.2s ease;
332+
box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
333+
visibility: hidden;
334+
}
335+
.tb--drawer-open .tb-controls {
336+
transform: none;
337+
visibility: visible;
338+
}
339+
.tb-controls__drawer-head {
340+
position: sticky;
341+
top: 0;
342+
z-index: 1;
343+
display: flex;
344+
align-items: center;
345+
justify-content: space-between;
346+
padding: 10px 12px;
347+
background: #fff;
348+
border-bottom: 1px solid #e5e7eb;
349+
font-weight: 600;
350+
}
351+
.tb-backdrop {
352+
display: block;
353+
position: fixed;
354+
inset: 0;
355+
z-index: 2000;
356+
background: rgba(15, 23, 42, 0.35);
357+
}
358+
}

0 commit comments

Comments
 (0)