@gntik-ai/templates 0.11.0 → 0.13.0
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/index.d.ts +24 -10
- package/dist/index.js +304 -266
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/assistant-chat/Page.test.tsx +37 -7
- package/src/assistant-chat/Page.tsx +98 -137
- package/src/assistant-chat/data.ts +69 -1
- package/src/assistant-chat/examples/AdapterChat.tsx +9 -0
- package/src/assistant-chat/template.meta.ts +1 -1
- package/src/board/Lane.tsx +1 -1
- package/src/code-editor/Page.test.tsx +12 -0
- package/src/code-editor/Page.tsx +2 -1
- package/src/code-editor/examples/PaletteTypography.tsx +130 -0
- package/src/code-editor/template.meta.ts +1 -1
- package/src/contact/Page.test.tsx +106 -0
- package/src/contact/Page.tsx +21 -3
- package/src/contact/PublicFrame.tsx +2 -17
- package/src/contact/examples/CustomFailure.tsx +24 -0
- package/src/contact/examples/FailedSend.tsx +19 -0
- package/src/contact/template.meta.ts +2 -2
- package/src/docs-article/Page.tsx +1 -1
- package/src/help-home/Page.test.tsx +10 -0
- package/src/help-home/Page.tsx +2 -4
- package/src/incident-console/Page.tsx +1 -1
- package/src/keyboard-shortcuts/Page.test.tsx +23 -1
- package/src/keyboard-shortcuts/Page.tsx +13 -3
- package/src/keyboard-shortcuts/ShortcutSheet.tsx +4 -5
- package/src/landing/Page.tsx +3 -17
- package/src/landing/template.meta.ts +1 -1
- package/src/messaging/Page.test.tsx +20 -3
- package/src/messaging/Page.tsx +15 -43
- package/src/messaging/template.meta.ts +1 -1
- package/src/notification-inbox/Page.tsx +1 -1
- package/src/pending-activation/Page.test.tsx +1 -1
- package/src/pricing/PublicFrame.tsx +2 -17
- package/src/pricing/template.meta.ts +1 -1
- package/src/resource-detail/Page.default.test.tsx +3 -2
- package/src/resource-detail/__snapshots__/Page.default.test.tsx.snap +2 -4
- package/src/resource-index/Page.test.tsx +178 -1
- package/src/resource-index/Page.tsx +59 -3
- package/src/resource-index/examples/UrlSynced.tsx +10 -0
- package/src/resource-index/template.meta.ts +1 -1
- package/src/resource-tree/Page.tsx +1 -1
- package/src/run-trace/Page.tsx +2 -2
- package/src/scorecard/Page.test.tsx +54 -0
- package/src/scorecard/Page.tsx +2 -0
- package/src/scorecard/data.ts +1 -1
- package/src/search-results/Page.tsx +3 -6
- package/src/settings-appearance/Page.test.tsx +36 -1
- package/src/settings-appearance/Page.tsx +15 -2
- package/src/settings-appearance/template.meta.ts +2 -1
- package/src/settings-profile/__tests__/dom.ts +4 -2
- package/src/settings-profile/fixtures/editable.snap +1 -1
- package/src/shared/ConsoleShell.context.test.tsx +125 -0
- package/src/shared/ConsoleShell.navigation.test.tsx +100 -0
- package/src/shared/ConsoleShell.tsx +38 -9
- package/src/shell-sidebar/Examples.test.tsx +73 -0
- package/src/shell-sidebar/examples/Brand.tsx +16 -0
- package/src/shell-sidebar/examples/ContextRegion.tsx +26 -0
- package/src/shell-sidebar/examples/PlatformWide.tsx +11 -0
- package/src/shell-sidebar/examples/Tenants.tsx +42 -0
- package/src/shell-sidebar/examples/UserMenuChildren.tsx +23 -0
- package/src/shell-sidebar/template.meta.ts +1 -1
- package/src/sign-in/BrandPanel.tsx +2 -2
- package/src/sign-in/Page.test.tsx +5 -0
- package/src/sso-login/Page.test.tsx +6 -0
- package/src/sso-login/Page.tsx +1 -0
- package/src/test/public-footer.test.tsx +44 -0
- package/src/test/without-forced-colors.test.ts +44 -0
- package/src/test/without-forced-colors.ts +14 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useI18n } from '@gntik-ai/ui';
|
|
1
|
+
import { useI18n, useUrlState, urlParam, type UrlStateAdapter } from '@gntik-ai/ui';
|
|
2
2
|
import {
|
|
3
3
|
BulkActionBar,
|
|
4
4
|
DataTable,
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type DataTableColumn,
|
|
10
10
|
type FilterField,
|
|
11
11
|
type SavedView,
|
|
12
|
+
type SortState,
|
|
12
13
|
} from '@gntik-ai/blocks';
|
|
13
14
|
import { Archive, Download, Plus, Trash2 } from '@gntik-ai/icons';
|
|
14
15
|
import { Link, Page, Stack, type BreadcrumbItem } from '@gntik-ai/ui';
|
|
@@ -60,10 +61,28 @@ export interface ResourceIndexProps<T extends object = ResourceRow> {
|
|
|
60
61
|
onBulkAction: (action: ResourceBulkAction, ids: string[]) => void;
|
|
61
62
|
/** Local Archive without `onBulkAction`; defaults to `status: 'paused'` on rows that have a status. */
|
|
62
63
|
archiveRow: (row: T) => T;
|
|
64
|
+
/**
|
|
65
|
+
* Keep q, repeated f=field:value and sort=column:asc|desc in the URL (default false).
|
|
66
|
+
* Filters push history; query and sort replace. Use UrlStateProvider with a router.
|
|
67
|
+
* Saved-view selection itself is local and may show a stale label after Back.
|
|
68
|
+
* Page and page size remain local. Default-adapter SSR initially renders unfiltered rows.
|
|
69
|
+
*/
|
|
70
|
+
syncUrl?: boolean;
|
|
63
71
|
loading: boolean;
|
|
64
72
|
shell: Omit<ConsoleShellProps, 'children'>;
|
|
65
73
|
}
|
|
66
74
|
|
|
75
|
+
const urlSchema = {
|
|
76
|
+
q: urlParam.string(),
|
|
77
|
+
f: urlParam.array(urlParam.string(), { history: 'push' }),
|
|
78
|
+
sort: urlParam.string(),
|
|
79
|
+
};
|
|
80
|
+
const inertAdapter: UrlStateAdapter = {
|
|
81
|
+
getSearch: () => '',
|
|
82
|
+
subscribe: () => () => {},
|
|
83
|
+
setSearch: () => {},
|
|
84
|
+
};
|
|
85
|
+
|
|
67
86
|
const defaultRowId = (row: object): string => {
|
|
68
87
|
const id = (row as { id?: unknown }).id;
|
|
69
88
|
return typeof id === 'string' || typeof id === 'number' ? String(id) : '';
|
|
@@ -91,12 +110,20 @@ export default function ResourceIndexPage<T extends object = ResourceRow>({
|
|
|
91
110
|
onBulkAction,
|
|
92
111
|
archiveRow = defaultArchive,
|
|
93
112
|
loading = false,
|
|
113
|
+
syncUrl = false,
|
|
94
114
|
shell,
|
|
95
115
|
}: Partial<ResourceIndexProps<T>>) {
|
|
96
116
|
const { locale } = useI18n();
|
|
97
117
|
const [rows, setRows] = useState<readonly T[]>(initialRows);
|
|
98
|
-
const [
|
|
99
|
-
const [
|
|
118
|
+
const [localQuery, setLocalQuery] = useState('');
|
|
119
|
+
const [localFilters, setLocalFilters] = useState<ActiveFilter[]>([]);
|
|
120
|
+
const [url, setUrl] = useUrlState(urlSchema, { adapter: syncUrl ? undefined : inertAdapter });
|
|
121
|
+
const query = syncUrl ? url.q : localQuery;
|
|
122
|
+
const filters = syncUrl ? decodeFilters(url.f, filterFields) : localFilters;
|
|
123
|
+
const sort = syncUrl ? decodeSort(url.sort, columns) : undefined;
|
|
124
|
+
const setQuery = (q: string) => (syncUrl ? setUrl({ q }) : setLocalQuery(q));
|
|
125
|
+
const setFilters = (next: ActiveFilter[]) =>
|
|
126
|
+
syncUrl ? setUrl({ f: next.map(({ field, value }) => `${field}:${value}`) }) : setLocalFilters(next);
|
|
100
127
|
const [selected, setSelected] = useState<string[]>([]);
|
|
101
128
|
const visible = filterResources(rows, query, filters, columns, locale);
|
|
102
129
|
const visibleSelected = selected.filter((id) => visible.some((r) => getRowId(r) === id));
|
|
@@ -160,6 +187,12 @@ export default function ResourceIndexPage<T extends object = ResourceRow>({
|
|
|
160
187
|
rows={visible}
|
|
161
188
|
columns={tableColumns}
|
|
162
189
|
getRowId={getRowId}
|
|
190
|
+
sort={sort}
|
|
191
|
+
onSortChange={
|
|
192
|
+
syncUrl
|
|
193
|
+
? (next) => setUrl({ sort: `${next.columnId}:${next.direction === 'ascending' ? 'asc' : 'desc'}` })
|
|
194
|
+
: undefined
|
|
195
|
+
}
|
|
163
196
|
caption={title}
|
|
164
197
|
loading={loading}
|
|
165
198
|
selectedIds={visibleSelected}
|
|
@@ -216,3 +249,26 @@ function linkColumns<T>(
|
|
|
216
249
|
};
|
|
217
250
|
});
|
|
218
251
|
}
|
|
252
|
+
|
|
253
|
+
function decodeFilters(raw: readonly string[], fields: readonly FilterField[]): ActiveFilter[] {
|
|
254
|
+
return raw
|
|
255
|
+
.flatMap((entry) => {
|
|
256
|
+
const colon = entry.indexOf(':');
|
|
257
|
+
if (colon < 0) return [];
|
|
258
|
+
const field = fields.find((field) => field.id === entry.slice(0, colon));
|
|
259
|
+
const value = field?.options.find((option) => option.toLowerCase() === entry.slice(colon + 1).toLowerCase());
|
|
260
|
+
return field && value !== undefined ? [{ field: field.id, value }] : [];
|
|
261
|
+
})
|
|
262
|
+
.filter(
|
|
263
|
+
(filter, index, all) =>
|
|
264
|
+
all.findIndex((other) => other.field === filter.field && other.value === filter.value) === index,
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
function decodeSort<T>(raw: string, columns: ReadonlyArray<DataTableColumn<T>>): SortState | null {
|
|
268
|
+
const colon = raw.lastIndexOf(':');
|
|
269
|
+
const columnId = raw.slice(0, colon);
|
|
270
|
+
const direction = raw.slice(colon + 1);
|
|
271
|
+
if (colon < 0 || (direction !== 'asc' && direction !== 'desc')) return null;
|
|
272
|
+
const column = columns.find((column) => column.id === columnId && column.sortable && column.accessor);
|
|
273
|
+
return column ? { columnId: column.id, direction: direction === 'asc' ? 'ascending' : 'descending' } : null;
|
|
274
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import ResourceIndexPage from '../Page';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Search and sorting replace history; filters push. Try Back after changing filters.
|
|
5
|
+
* A shared link can include ?q=api&f=status:failed&sort=name:desc.
|
|
6
|
+
* With a router, wrap the page in UrlStateProvider using the hook's adapter recipe.
|
|
7
|
+
*/
|
|
8
|
+
export default function UrlSynced() {
|
|
9
|
+
return <ResourceIndexPage syncUrl />;
|
|
10
|
+
}
|
|
@@ -6,7 +6,7 @@ export const meta: TemplateMeta = {
|
|
|
6
6
|
priority: 'P1',
|
|
7
7
|
status: 'beta',
|
|
8
8
|
description:
|
|
9
|
-
'List page for any resource: header with the create action, filter bar with saved views, a selectable sortable table with pagination, a sticky bulk action bar and a no-results state.',
|
|
9
|
+
'List page for any resource: header with the create action, filter bar with saved views, a selectable sortable table with pagination, a sticky bulk action bar and a no-results state. Opt-in syncUrl preserves query, filters and sort in shared links and browser history.',
|
|
10
10
|
layout: 'SidebarLayout + Page',
|
|
11
11
|
blocks: [
|
|
12
12
|
'app-sidebar',
|
|
@@ -73,7 +73,7 @@ function columns(onOpen?: (r: TreeResource) => void): DataTableColumn<TreeResour
|
|
|
73
73
|
<button
|
|
74
74
|
type="button"
|
|
75
75
|
onClick={() => onOpen(r)}
|
|
76
|
-
className="font-medium text-foreground underline-offset-2 hover:underline focus-
|
|
76
|
+
className="font-medium text-foreground underline-offset-2 hover:underline focus-ring"
|
|
77
77
|
>
|
|
78
78
|
{r.name}
|
|
79
79
|
</button>
|
package/src/run-trace/Page.tsx
CHANGED
|
@@ -99,7 +99,7 @@ function SpanPanel({
|
|
|
99
99
|
))}
|
|
100
100
|
</dl>
|
|
101
101
|
<section aria-label="Input">
|
|
102
|
-
<h3 className="mb-2 text-[12px] font-semibold tracking-wide text-muted-foreground
|
|
102
|
+
<h3 className="mb-2 text-[12px] font-semibold tracking-wide text-muted-foreground label-case">Input</h3>
|
|
103
103
|
{detail?.input === undefined ? (
|
|
104
104
|
<p className="text-[12.5px] text-muted-foreground">No input recorded.</p>
|
|
105
105
|
) : (
|
|
@@ -113,7 +113,7 @@ function SpanPanel({
|
|
|
113
113
|
)}
|
|
114
114
|
</section>
|
|
115
115
|
<section aria-label="Output">
|
|
116
|
-
<h3 className="mb-2 text-[12px] font-semibold tracking-wide text-muted-foreground
|
|
116
|
+
<h3 className="mb-2 text-[12px] font-semibold tracking-wide text-muted-foreground label-case">Output</h3>
|
|
117
117
|
{detail?.output === undefined ? (
|
|
118
118
|
<p className="text-[12.5px] text-muted-foreground">
|
|
119
119
|
{running ? 'Waiting for the span to finish…' : 'No output recorded.'}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { render, screen, within } from '@testing-library/react';
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { ThemeProvider } from '@gntik-ai/ui';
|
|
3
4
|
import { expectNoAxeViolations } from '../test/a11y';
|
|
4
5
|
import ScorecardPage from './Page';
|
|
5
6
|
import { attainment, periodDelta, scorecardMetrics } from './data';
|
|
@@ -35,4 +36,57 @@ describe('ScorecardPage', () => {
|
|
|
35
36
|
expect(periodDelta(latency, 176, 205)?.sentiment).toBe('positive');
|
|
36
37
|
expect(attainment(latency, 180)).toBe(100);
|
|
37
38
|
});
|
|
39
|
+
|
|
40
|
+
it('renders commentary Markdown and safely handles untrusted bodies', { timeout: 15000 }, async () => {
|
|
41
|
+
const { container } = render(
|
|
42
|
+
<ScorecardPage
|
|
43
|
+
comments={[
|
|
44
|
+
{
|
|
45
|
+
id: 'markdown',
|
|
46
|
+
author: { name: 'Reviewer' },
|
|
47
|
+
at: '2026-10-01T12:00:00Z',
|
|
48
|
+
body: 'See [runbook](https://example.test/runbook). Use **retry** with `backoff`.\n\n<img src=x onerror=alert(1)>\n\n<script>alert(1)</script>\n\n[x](javascript:alert(1))\n\n```ts\nretry();\n```',
|
|
49
|
+
},
|
|
50
|
+
]}
|
|
51
|
+
/>,
|
|
52
|
+
);
|
|
53
|
+
const thread = screen.getByRole('region', { name: 'Scorecard commentary' });
|
|
54
|
+
expect(within(thread).getByRole('link', { name: /^runbook/ })).toHaveAttribute(
|
|
55
|
+
'href',
|
|
56
|
+
'https://example.test/runbook',
|
|
57
|
+
);
|
|
58
|
+
expect(within(thread).getByText('backoff').tagName).toBe('CODE');
|
|
59
|
+
expect(within(thread).getByText('retry').tagName).toBe('STRONG');
|
|
60
|
+
expect(within(thread).getByText('x')).toBeInTheDocument();
|
|
61
|
+
expect(thread.querySelector('img, script, p p, a[href^="javascript:"]')).toBeNull();
|
|
62
|
+
const user = userEvent.setup();
|
|
63
|
+
await user.type(within(thread).getByRole('textbox'), 'Use **retry**');
|
|
64
|
+
await user.keyboard('{Control>}{Enter}{/Control}');
|
|
65
|
+
expect(within(thread).getAllByText('retry')).toHaveLength(2);
|
|
66
|
+
expect(
|
|
67
|
+
within(thread)
|
|
68
|
+
.getAllByText('retry')
|
|
69
|
+
.every((node) => node.tagName === 'STRONG'),
|
|
70
|
+
).toBe(true);
|
|
71
|
+
await expectNoAxeViolations(container);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it.each(['dark', 'light', 'high_contrast'] as const)(
|
|
75
|
+
'shows the sample Markdown and passes axe in %s',
|
|
76
|
+
{ timeout: 15000 },
|
|
77
|
+
async (theme) => {
|
|
78
|
+
const { container } = render(
|
|
79
|
+
<ThemeProvider defaultMode={theme} storageKey={null}>
|
|
80
|
+
<ScorecardPage />
|
|
81
|
+
</ThemeProvider>,
|
|
82
|
+
);
|
|
83
|
+
const thread = screen.getByRole('region', { name: 'Scorecard commentary' });
|
|
84
|
+
expect(within(thread).getByRole('link', { name: /^runbook/ })).toHaveAttribute(
|
|
85
|
+
'href',
|
|
86
|
+
'https://example.test/runbook',
|
|
87
|
+
);
|
|
88
|
+
expect(within(thread).getByText('backoff').tagName).toBe('CODE');
|
|
89
|
+
await expectNoAxeViolations(container);
|
|
90
|
+
},
|
|
91
|
+
);
|
|
38
92
|
});
|
package/src/scorecard/Page.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CommentThread, KpiRow, PageHeader, type CommentAuthor, type ThreadComment } from '@gntik-ai/blocks';
|
|
2
2
|
import { RadarChart } from '@gntik-ai/charts';
|
|
3
|
+
import { Markdown } from '@gntik-ai/chat';
|
|
3
4
|
import { Download } from '@gntik-ai/icons';
|
|
4
5
|
import {
|
|
5
6
|
Card,
|
|
@@ -143,6 +144,7 @@ export default function ScorecardPage(props: Partial<ScorecardProps>) {
|
|
|
143
144
|
<CardBody>
|
|
144
145
|
<CommentThread
|
|
145
146
|
comments={comments}
|
|
147
|
+
renderBody={(comment) => <Markdown className="text-[13px]">{comment.body}</Markdown>}
|
|
146
148
|
currentUser={currentUser}
|
|
147
149
|
onSubmit={onComment}
|
|
148
150
|
label="Scorecard commentary"
|
package/src/scorecard/data.ts
CHANGED
|
@@ -66,7 +66,7 @@ export const scorecardComments: ThreadComment[] = [
|
|
|
66
66
|
{
|
|
67
67
|
id: 'c1',
|
|
68
68
|
author: { name: 'Priya Natarajan' },
|
|
69
|
-
body: 'Latency is finally under target after the cache rollout in August. Keep an eye on the EU region.',
|
|
69
|
+
body: 'Latency is finally under target after the cache rollout in August. See [runbook](https://example.test/runbook) for `backoff` settings. Keep an eye on the EU region.',
|
|
70
70
|
at: Date.now() - 3 * DAY,
|
|
71
71
|
},
|
|
72
72
|
{
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { NoResultsEmpty, PageHeader, SectionHeader } from '@gntik-ai/blocks';
|
|
2
|
-
import { Search } from '@gntik-ai/icons';
|
|
3
2
|
import {
|
|
4
3
|
matchText,
|
|
5
4
|
Checkbox,
|
|
6
5
|
CheckboxGroup,
|
|
7
6
|
Grid,
|
|
8
7
|
GridItem,
|
|
9
|
-
Input,
|
|
10
8
|
Kbd,
|
|
11
9
|
Link,
|
|
12
10
|
Page,
|
|
11
|
+
SearchField,
|
|
13
12
|
Stack,
|
|
14
13
|
useI18n,
|
|
15
14
|
type BreadcrumbItem,
|
|
@@ -123,11 +122,9 @@ export default function SearchResultsPage(props: Partial<SearchResultsProps>) {
|
|
|
123
122
|
}
|
|
124
123
|
>
|
|
125
124
|
<div role="search" aria-label="Workspace search">
|
|
126
|
-
<
|
|
127
|
-
type="search"
|
|
125
|
+
<SearchField
|
|
128
126
|
aria-label="Search the workspace"
|
|
129
127
|
aria-describedby={`${id}-hint`}
|
|
130
|
-
leadingIcon={Search}
|
|
131
128
|
value={query}
|
|
132
129
|
onValueChange={(v) => changeQuery(String(v))}
|
|
133
130
|
onKeyDown={(e) => {
|
|
@@ -150,7 +147,7 @@ export default function SearchResultsPage(props: Partial<SearchResultsProps>) {
|
|
|
150
147
|
<div key={facet.id}>
|
|
151
148
|
<p
|
|
152
149
|
id={`${id}-${facet.id}`}
|
|
153
|
-
className="mb-2.5 font-mono text-[10.5px] font-medium tracking-[0.12em] text-muted-foreground
|
|
150
|
+
className="mb-2.5 font-mono text-[10.5px] font-medium tracking-[0.12em] text-muted-foreground label-case"
|
|
154
151
|
>
|
|
155
152
|
{facet.label}
|
|
156
153
|
</p>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ThemeProvider } from '@gntik-ai/ui';
|
|
1
|
+
import { I18nProvider, ThemeProvider } from '@gntik-ai/ui';
|
|
2
2
|
import { render, screen, within } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import { describe, expect, it, vi } from 'vitest';
|
|
@@ -42,3 +42,38 @@ describe('SettingsAppearancePage', () => {
|
|
|
42
42
|
await expectNoAxeViolations(container);
|
|
43
43
|
}, 15000);
|
|
44
44
|
});
|
|
45
|
+
|
|
46
|
+
it('toggles the app motion preference with an accessible switch', async () => {
|
|
47
|
+
renderPage();
|
|
48
|
+
const control = screen.getByRole('switch', { name: 'Reduce motion' });
|
|
49
|
+
expect(control).not.toBeChecked();
|
|
50
|
+
await userEvent.click(control);
|
|
51
|
+
expect(control).toBeChecked();
|
|
52
|
+
expect(document.documentElement).toHaveAttribute('data-motion', 'reduce');
|
|
53
|
+
await userEvent.click(control);
|
|
54
|
+
expect(control).not.toBeChecked();
|
|
55
|
+
expect(document.documentElement).not.toHaveAttribute('data-motion');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it.each(['dark', 'light', 'high_contrast'] as const)('motion row is axe clean in %s', async (theme) => {
|
|
59
|
+
const { container } = render(
|
|
60
|
+
<ThemeProvider defaultMode={theme} storageKey={null} motionStorageKey={null}>
|
|
61
|
+
<SettingsAppearancePage />
|
|
62
|
+
</ThemeProvider>,
|
|
63
|
+
);
|
|
64
|
+
await expectNoAxeViolations(container);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('localizes the motion label and description in Spanish', () => {
|
|
68
|
+
render(
|
|
69
|
+
<I18nProvider locale="es">
|
|
70
|
+
<ThemeProvider defaultMotion="reduce" storageKey={null} motionStorageKey={null}>
|
|
71
|
+
<SettingsAppearancePage />
|
|
72
|
+
</ThemeProvider>
|
|
73
|
+
</I18nProvider>,
|
|
74
|
+
);
|
|
75
|
+
expect(screen.getByRole('switch', { name: 'Reducir movimiento' })).toBeChecked();
|
|
76
|
+
expect(screen.getByRole('switch', { name: 'Reducir movimiento' })).toHaveAccessibleDescription(
|
|
77
|
+
'Desactiva las animaciones y transiciones en esta aplicación, aunque tu dispositivo las permita.',
|
|
78
|
+
);
|
|
79
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SettingsRow } from '@gntik-ai/blocks';
|
|
2
|
-
import { Section, SimpleSelect, ThemeSwitcher, Toggle, ToggleGroup, useTheme } from '@gntik-ai/ui';
|
|
2
|
+
import { Section, SimpleSelect, Switch, ThemeSwitcher, Toggle, ToggleGroup, useI18n, useTheme } from '@gntik-ai/ui';
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import { SettingsFrame, type SettingsFrameOptions } from '../settings-profile/SettingsFrame';
|
|
5
5
|
import { THEME_LABELS, densities, languages as defaultLanguages, type Density, type LanguageOption } from './data';
|
|
@@ -24,7 +24,8 @@ export default function SettingsAppearancePage({
|
|
|
24
24
|
onLanguageChange,
|
|
25
25
|
...frame
|
|
26
26
|
}: Partial<SettingsAppearanceProps>) {
|
|
27
|
-
const { mode, resolved } = useTheme();
|
|
27
|
+
const { mode, resolved, motion, setMotion } = useTheme();
|
|
28
|
+
const { t } = useI18n();
|
|
28
29
|
const [density, setDensity] = useState<Density>(initialDensity);
|
|
29
30
|
const [language, setLanguage] = useState(initialLanguage);
|
|
30
31
|
|
|
@@ -44,6 +45,18 @@ export default function SettingsAppearancePage({
|
|
|
44
45
|
}
|
|
45
46
|
control={<ThemeSwitcher label="Theme" />}
|
|
46
47
|
/>
|
|
48
|
+
<SettingsRow
|
|
49
|
+
label={t('motion.reduce')}
|
|
50
|
+
description={t('motion.description')}
|
|
51
|
+
control={({ labelId, descriptionId }) => (
|
|
52
|
+
<Switch
|
|
53
|
+
aria-labelledby={labelId}
|
|
54
|
+
aria-describedby={descriptionId}
|
|
55
|
+
checked={motion === 'reduce'}
|
|
56
|
+
onCheckedChange={(checked) => setMotion(checked ? 'reduce' : 'system')}
|
|
57
|
+
/>
|
|
58
|
+
)}
|
|
59
|
+
/>
|
|
47
60
|
<SettingsRow
|
|
48
61
|
label="Density"
|
|
49
62
|
description="Compact fits more rows in tables and lists."
|
|
@@ -5,7 +5,8 @@ export const meta: TemplateMeta = {
|
|
|
5
5
|
family: 'Settings',
|
|
6
6
|
priority: 'P2',
|
|
7
7
|
status: 'beta',
|
|
8
|
-
description:
|
|
8
|
+
description:
|
|
9
|
+
'Theme switcher wired to the ThemeProvider, an in-app Reduce motion switch, table density and interface language.',
|
|
9
10
|
layout: 'SettingsLayout',
|
|
10
11
|
blocks: ['app-sidebar', 'app-topbar', 'page-header', 'settings-row'],
|
|
11
12
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { withoutForcedColors } from '../../test/without-forced-colors';
|
|
2
|
+
|
|
3
|
+
/** Ignore forced-colour classes and React's per-root IDs, preserving all other DOM. */
|
|
2
4
|
export function profileDOM(container: HTMLElement): string {
|
|
3
5
|
const ids = new Map<string, string>();
|
|
4
|
-
return container.innerHTML.replace(/_r_[a-z0-9]+_/g, (id) => {
|
|
6
|
+
return withoutForcedColors(container).innerHTML.replace(/_r_[a-z0-9]+_/g, (id) => {
|
|
5
7
|
if (!ids.has(id)) ids.set(id, `_r_${ids.size}_`);
|
|
6
8
|
return ids.get(id)!;
|
|
7
9
|
});
|