@beehexa/design-rules 2611.4.1 → 2611.5.3
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/catalog.json +602 -248
- package/dist/docs/public/_redirects +2 -0
- package/dist/docs/scripts/token-utils.d.mts +5 -1
- package/dist/docs/scripts/token-utils.mjs +28 -3
- package/dist/docs/src/brand/structure-proposal.md +1 -1
- package/dist/docs/src/components/ColorDemo.astro +52 -14
- package/dist/docs/src/components/MotionDemo.astro +135 -0
- package/dist/docs/src/components/NativeControlsDemo.astro +279 -0
- package/dist/docs/src/components/OpacityDemo.astro +8 -8
- package/dist/docs/src/components/RoleGuides.astro +2 -2
- package/dist/docs/src/components/ShapeDemo.astro +78 -35
- package/dist/docs/src/components/SiteHeader.astro +19 -4
- package/dist/docs/src/components/SystemAreas.astro +1 -1
- package/dist/docs/src/components/TokenTable.astro +16 -1
- package/dist/docs/src/components/TypeDemo.astro +15 -15
- package/dist/docs/src/components/ZIndexDemo.astro +1 -1
- package/dist/docs/src/components/logos/LogoInUse.astro +3 -3
- package/dist/docs/src/content/components/button/accessibility.mdx +41 -8
- package/dist/docs/src/content/components/button/code.mdx +8 -1
- package/dist/docs/src/content/components/button/examples.mdx +23 -4
- package/dist/docs/src/content/components/button/usage.mdx +26 -0
- package/dist/docs/src/content/components/resizable-panel/accessibility.mdx +61 -0
- package/dist/docs/src/content/components/resizable-panel/changelog.mdx +20 -0
- package/dist/docs/src/content/components/resizable-panel/code.mdx +79 -0
- package/dist/docs/src/content/components/resizable-panel/examples.mdx +85 -0
- package/dist/docs/src/content/components/resizable-panel/meta.json +5 -0
- package/dist/docs/src/content/components/resizable-panel/usage.mdx +101 -0
- package/dist/docs/src/content/foundations/guidelines/accessibility/keyboard-and-focus.mdx +75 -0
- package/dist/docs/src/content/foundations/guidelines/accessibility/statement.mdx +45 -0
- package/dist/docs/src/content/foundations/guidelines/accessibility/testing.mdx +58 -0
- package/dist/docs/src/content/foundations/guidelines/accessibility.mdx +100 -11
- package/dist/docs/src/content/foundations/guidelines/content.mdx +11 -2
- package/dist/docs/src/content/foundations/index.mdx +3 -3
- package/dist/docs/src/content/foundations/styles/border.mdx +10 -3
- package/dist/docs/src/content/foundations/styles/color/accessibility.mdx +4 -2
- package/dist/docs/src/content/foundations/styles/color/dark-mode.mdx +2 -2
- package/dist/docs/src/content/foundations/styles/color/index.mdx +14 -2
- package/dist/docs/src/content/foundations/styles/color/palette.mdx +4 -4
- package/dist/docs/src/content/foundations/styles/color/tokens.mdx +2 -2
- package/dist/docs/src/content/foundations/styles/color/usage.mdx +25 -3
- package/dist/docs/src/content/foundations/styles/data-visualization.mdx +76 -0
- package/dist/docs/src/content/foundations/styles/elevation.mdx +7 -1
- package/dist/docs/src/content/foundations/styles/icons/accessibility.mdx +1 -1
- package/dist/docs/src/content/foundations/styles/icons/code.mdx +6 -18
- package/dist/docs/src/content/foundations/styles/icons/index.mdx +2 -2
- package/dist/docs/src/content/foundations/styles/icons/usage.mdx +4 -2
- package/dist/docs/src/content/foundations/styles/interaction-states.mdx +82 -9
- package/dist/docs/src/content/foundations/styles/layout/app-frame.mdx +2 -4
- package/dist/docs/src/content/foundations/styles/layout/breakpoints.mdx +10 -7
- package/dist/docs/src/content/foundations/styles/layout/grid.mdx +4 -2
- package/dist/docs/src/content/foundations/styles/layout/index.mdx +3 -3
- package/dist/docs/src/content/foundations/styles/layout/overlays.mdx +28 -37
- package/dist/docs/src/content/foundations/styles/layout/page-widths.mdx +4 -4
- package/dist/docs/src/content/foundations/styles/logos/downloads-and-terms.mdx +7 -7
- package/dist/docs/src/content/foundations/styles/logos/index.mdx +13 -2
- package/dist/docs/src/content/foundations/styles/logos/placement-and-containers.mdx +4 -2
- package/dist/docs/src/content/foundations/styles/logos/product-logos.mdx +2 -2
- package/dist/docs/src/content/foundations/styles/logos/using-the-logo.mdx +3 -1
- package/dist/docs/src/content/foundations/styles/motion.mdx +131 -3
- package/dist/docs/src/content/foundations/styles/opacity.mdx +7 -1
- package/dist/docs/src/content/foundations/styles/radius.mdx +63 -15
- package/dist/docs/src/content/foundations/styles/scrollbars.mdx +176 -0
- package/dist/docs/src/content/foundations/styles/size-and-density.mdx +16 -6
- package/dist/docs/src/content/foundations/styles/spacing.mdx +17 -3
- package/dist/docs/src/content/foundations/styles/typography/code.mdx +4 -2
- package/dist/docs/src/content/foundations/styles/typography/index.mdx +13 -3
- package/dist/docs/src/content/foundations/styles/typography/usage.mdx +5 -3
- package/dist/docs/src/content/foundations/styles/typography/vietnamese.mdx +2 -2
- package/dist/docs/src/content/foundations/styles/z-index.mdx +4 -0
- package/dist/docs/src/content/foundations/tokens/all-tokens.mdx +11 -0
- package/dist/docs/src/content/foundations/tokens/index.mdx +17 -9
- package/dist/docs/src/content/get-started/design.mdx +1 -1
- package/dist/docs/src/content/get-started/develop.mdx +2 -6
- package/dist/docs/src/content/get-started/index.mdx +1 -1
- package/dist/docs/src/content/release-phases/index.mdx +1 -1
- package/dist/docs/src/content/tools/ant-design-vue-theme.mdx +474 -12
- package/dist/docs/src/content/tools/application-content.mdx +166 -32
- package/dist/docs/src/content/tools/editors.mdx +247 -3
- package/dist/docs/src/content/tools/eslint.mdx +1 -1
- package/dist/docs/src/content/tools/index.mdx +2 -2
- package/dist/docs/src/content/tools/mermaid.mdx +108 -13
- package/dist/docs/src/content/tools/vueflow.mdx +58 -0
- package/dist/docs/src/content-vi/foundations/guidelines/accessibility/keyboard-and-focus.mdx +75 -0
- package/dist/docs/src/content-vi/foundations/guidelines/accessibility/statement.mdx +45 -0
- package/dist/docs/src/content-vi/foundations/guidelines/accessibility/testing.mdx +58 -0
- package/dist/docs/src/content-vi/foundations/guidelines/accessibility.mdx +108 -0
- package/dist/docs/src/content-vi/foundations/guidelines/content.mdx +34 -0
- package/dist/docs/src/content-vi/foundations/index.mdx +9 -0
- package/dist/docs/src/content-vi/foundations/styles/border.mdx +9 -3
- package/dist/docs/src/content-vi/foundations/styles/color/accessibility.mdx +4 -2
- package/dist/docs/src/content-vi/foundations/styles/color/dark-mode.mdx +2 -2
- package/dist/docs/src/content-vi/foundations/styles/color/index.mdx +14 -2
- package/dist/docs/src/content-vi/foundations/styles/color/palette.mdx +5 -5
- package/dist/docs/src/content-vi/foundations/styles/color/tokens.mdx +2 -2
- package/dist/docs/src/content-vi/foundations/styles/color/usage.mdx +24 -2
- package/dist/docs/src/content-vi/foundations/styles/elevation.mdx +7 -1
- package/dist/docs/src/content-vi/foundations/styles/icons/accessibility.mdx +1 -1
- package/dist/docs/src/content-vi/foundations/styles/icons/code.mdx +6 -18
- package/dist/docs/src/content-vi/foundations/styles/icons/index.mdx +2 -2
- package/dist/docs/src/content-vi/foundations/styles/icons/usage.mdx +4 -2
- package/dist/docs/src/content-vi/foundations/styles/interaction-states.mdx +22 -8
- package/dist/docs/src/content-vi/foundations/styles/layout/app-frame.mdx +3 -1
- package/dist/docs/src/content-vi/foundations/styles/layout/breakpoints.mdx +10 -7
- package/dist/docs/src/content-vi/foundations/styles/layout/grid.mdx +4 -2
- package/dist/docs/src/content-vi/foundations/styles/layout/index.mdx +3 -3
- package/dist/docs/src/content-vi/foundations/styles/layout/overlays.mdx +36 -0
- package/dist/docs/src/content-vi/foundations/styles/layout/page-widths.mdx +5 -1
- package/dist/docs/src/content-vi/foundations/styles/logos/downloads-and-terms.mdx +7 -7
- package/dist/docs/src/content-vi/foundations/styles/logos/index.mdx +13 -2
- package/dist/docs/src/content-vi/foundations/styles/logos/placement-and-containers.mdx +4 -2
- package/dist/docs/src/content-vi/foundations/styles/logos/product-logos.mdx +2 -2
- package/dist/docs/src/content-vi/foundations/styles/logos/using-the-logo.mdx +3 -1
- package/dist/docs/src/content-vi/foundations/styles/motion.mdx +139 -0
- package/dist/docs/src/content-vi/foundations/styles/opacity.mdx +8 -2
- package/dist/docs/src/content-vi/foundations/styles/radius.mdx +63 -15
- package/dist/docs/src/content-vi/foundations/styles/size-and-density.mdx +16 -6
- package/dist/docs/src/content-vi/foundations/styles/spacing.mdx +17 -3
- package/dist/docs/src/content-vi/foundations/styles/typography/code.mdx +4 -2
- package/dist/docs/src/content-vi/foundations/styles/typography/index.mdx +14 -4
- package/dist/docs/src/content-vi/foundations/styles/typography/usage.mdx +4 -2
- package/dist/docs/src/content-vi/foundations/styles/typography/vietnamese.mdx +2 -2
- package/dist/docs/src/content-vi/foundations/styles/z-index.mdx +4 -0
- package/dist/docs/src/content-vi/foundations/tokens/all-tokens.mdx +47 -0
- package/dist/docs/src/content-vi/foundations/tokens/index.mdx +35 -0
- package/dist/docs/src/lib/i18n.ts +0 -1
- package/dist/docs/src/lib/token-descriptions-vi.ts +60 -9
- package/dist/docs/src/lib/tokens.ts +3 -0
- package/dist/docs/src/styles/chrome.css +10 -3
- package/dist/docs/src/styles/color.css +33 -23
- package/dist/docs/src/styles/docs.css +26 -28
- package/dist/docs/src/styles/elevation.css +4 -4
- package/dist/docs/src/styles/global.css +21 -1
- package/dist/docs/src/styles/icons.css +10 -9
- package/dist/docs/src/styles/kit.css +36 -32
- package/dist/docs/src/styles/layout.css +7 -7
- package/dist/docs/src/styles/motion.css +34 -0
- package/dist/docs/src/styles/opacity.css +3 -3
- package/dist/docs/src/styles/scrollbars.css +74 -0
- package/dist/docs/src/styles/shapes.css +21 -11
- package/dist/docs/src/styles/tokens.css +392 -12
- package/dist/docs/src/styles/tokens.js +185 -6
- package/dist/docs/src/styles/typography.css +4 -4
- package/dist/docs/src/styles/zindex.css +10 -7
- package/dist/docs/tokens/color.json +18 -1
- package/dist/docs/tokens/content.json +8 -3
- package/dist/docs/tokens/diagram.json +9 -3
- package/dist/docs/tokens/flow.json +2 -2
- package/dist/docs/tokens/layout.json +4 -0
- package/dist/docs/tokens/motion.json +37 -5
- package/dist/docs/tokens/radius.json +52 -8
- package/dist/docs/tokens/resize.json +12 -0
- package/dist/docs/tokens/scrollbar.json +40 -0
- package/dist/docs/tokens/size.json +1 -1
- package/dist/docs/tokens/spacing.json +31 -1
- package/dist/docs/tokens/switch.json +280 -0
- package/dist/index.js +602 -248
- package/package.json +1 -1
|
@@ -5,3 +5,5 @@
|
|
|
5
5
|
/foundations/styles/grid/ /foundations/styles/layout/grid/ 301
|
|
6
6
|
/foundations/styles/breakpoints/ /foundations/styles/layout/breakpoints/ 301
|
|
7
7
|
/foundations/styles/icons/creating-icons/ /foundations/styles/icons/code/#custom-icons 301
|
|
8
|
+
/tools/ant-design-vue-theme/ /tools/ 301
|
|
9
|
+
/vi/tools/ant-design-vue-theme/ /vi/tools/ 301
|
|
@@ -6,6 +6,10 @@ export interface FlatToken {
|
|
|
6
6
|
description: string;
|
|
7
7
|
dark?: string;
|
|
8
8
|
vi?: string;
|
|
9
|
+
/** Tier 2 family, such as control, overlay or modal. */
|
|
10
|
+
family?: string;
|
|
11
|
+
/** Tier 3: the component the token belongs to. */
|
|
12
|
+
component?: string;
|
|
9
13
|
}
|
|
10
14
|
export type TokenMode = 'light' | 'dark' | 'vi' | 'darkVi';
|
|
11
15
|
export interface TokenInfo extends FlatToken {
|
|
@@ -23,4 +27,4 @@ export function createTokenModel(tokens: FlatToken[]): {
|
|
|
23
27
|
tokens: { light: Record<string, string>; dark: Record<string, string>; vi: Record<string, string> };
|
|
24
28
|
tokenInfo: Record<string, TokenInfo>;
|
|
25
29
|
};
|
|
26
|
-
export function renderTokenCss(tokens: FlatToken[], options?: { pixels?: boolean }): string;
|
|
30
|
+
export function renderTokenCss(tokens: FlatToken[], options?: { pixels?: boolean; scopes?: boolean }): string;
|
|
@@ -9,14 +9,18 @@ export function flattenTokens(tree, path = [], inheritedType) {
|
|
|
9
9
|
if (key.startsWith('$') && key !== '$root') continue;
|
|
10
10
|
const nodePath = key === '$root' ? path : [...path, key];
|
|
11
11
|
if (node && typeof node === 'object' && '$value' in node) {
|
|
12
|
+
const ext = node.$extensions?.['design.beehexa'];
|
|
12
13
|
tokens.push({
|
|
13
14
|
name: nodePath.join('.'),
|
|
14
15
|
path: nodePath,
|
|
15
16
|
type: node.$type ?? groupType,
|
|
16
|
-
value:
|
|
17
|
+
value: compositeValue(node.$value),
|
|
17
18
|
description: node.$description ?? '',
|
|
18
|
-
dark:
|
|
19
|
-
vi:
|
|
19
|
+
dark: ext?.dark,
|
|
20
|
+
vi: ext?.vi,
|
|
21
|
+
// Tier 2 family (control, item, card, overlay, modal, stack, table.cell...) or tier 3 component.
|
|
22
|
+
...(ext?.family ? { family: ext.family } : {}),
|
|
23
|
+
...(ext?.component ? { component: ext.component } : {}),
|
|
20
24
|
});
|
|
21
25
|
} else if (node && typeof node === 'object') {
|
|
22
26
|
tokens.push(...flattenTokens(node, nodePath, groupType));
|
|
@@ -25,6 +29,16 @@ export function flattenTokens(tree, path = [], inheritedType) {
|
|
|
25
29
|
return tokens;
|
|
26
30
|
}
|
|
27
31
|
|
|
32
|
+
// A DTCG transition composite becomes one CSS value, "duration timing-function [delay]", so it can
|
|
33
|
+
// follow the property name in a transition shorthand. Other values are kept as strings.
|
|
34
|
+
function compositeValue(value) {
|
|
35
|
+
if (value && typeof value === 'object' && 'duration' in value && 'timingFunction' in value) {
|
|
36
|
+
const delay = value.delay && !/^0(ms|s)?$/.test(String(value.delay)) ? ` ${value.delay}` : '';
|
|
37
|
+
return `${value.duration} ${value.timingFunction}${delay}`;
|
|
38
|
+
}
|
|
39
|
+
return String(value);
|
|
40
|
+
}
|
|
41
|
+
|
|
28
42
|
export function cssVarName(tokenName) {
|
|
29
43
|
return `--${PREFIX}-${tokenName.replaceAll('.', '-')}`;
|
|
30
44
|
}
|
|
@@ -112,6 +126,16 @@ export function renderTokenCss(flatTokens, { pixels = false, scopes = false } =
|
|
|
112
126
|
`.bh-scope-light {\n${scopeLight.join('\n')}\n color-scheme: light;\n}`,
|
|
113
127
|
`.bh-scope-dark {\n${scopeLight.join('\n')}\n${dark.join('\n')}\n color-scheme: dark;\n}`,
|
|
114
128
|
] : [];
|
|
129
|
+
// Reduced motion: every duration becomes 0, so anything built on the duration tokens changes at
|
|
130
|
+
// once. The class lets a product offer its own "reduce motion" setting.
|
|
131
|
+
const still = flatTokens.filter((token) => token.name.startsWith('motion.duration.')).map((token) => ` ${cssVarName(token.name)}: 0ms;`);
|
|
132
|
+
// A var() is resolved where it is declared, so the class must redeclare the transition tokens
|
|
133
|
+
// too, or they keep the durations from :root.
|
|
134
|
+
const stillComposites = flatTokens.filter((token) => token.value.includes('{motion.duration.')).map((token) => decl(token, token.value));
|
|
135
|
+
const stillCss = still.length ? [
|
|
136
|
+
`@media (prefers-reduced-motion: reduce) {\n :root {\n${still.map((line) => ` ${line}`).join('\n')}\n }\n}`,
|
|
137
|
+
`.bh-motion-reduced {\n${[...still, ...stillComposites].join('\n')}\n}`,
|
|
138
|
+
] : [];
|
|
115
139
|
return [
|
|
116
140
|
'/* Generated from beehexa.design tokens/*.json. Do not edit by hand. */',
|
|
117
141
|
`:root {\n${light.join('\n')}\n}`,
|
|
@@ -119,6 +143,7 @@ export function renderTokenCss(flatTokens, { pixels = false, scopes = false } =
|
|
|
119
143
|
`@media (prefers-color-scheme: dark) {\n :root:not([data-theme='light']) {\n${dark.map((line) => ` ${line}`).join('\n')}\n }\n}`,
|
|
120
144
|
`:lang(vi) {\n${vi.join('\n')}\n}`,
|
|
121
145
|
`[lang]:not(:lang(vi)) {\n${reset.join('\n')}\n}`,
|
|
146
|
+
...stillCss,
|
|
122
147
|
...scopeCss,
|
|
123
148
|
...(flatTokens.some(token => token.name === 'font.features') ? [
|
|
124
149
|
'/* Preserve source character variants through semantic font shorthands. */',
|
|
@@ -33,7 +33,7 @@ Components
|
|
|
33
33
|
One page per component, tabs: Examples, Code, Usage, Accessibility, Changelog
|
|
34
34
|
Atlassian tabs + Material Accessibility tab
|
|
35
35
|
Tools
|
|
36
|
-
Stylelint and ESLint rules,
|
|
36
|
+
Stylelint and ESLint rules, docs for AI agents
|
|
37
37
|
Atlassian
|
|
38
38
|
Release phases
|
|
39
39
|
Early Access, Beta, General Availability, Deprecated
|
|
@@ -13,12 +13,14 @@ import CircleCheck from '@lucide/astro/icons/circle-check';
|
|
|
13
13
|
import TriangleAlert from '@lucide/astro/icons/triangle-alert';
|
|
14
14
|
import CircleX from '@lucide/astro/icons/circle-x';
|
|
15
15
|
import Circle from '@lucide/astro/icons/circle';
|
|
16
|
+
import X from '@lucide/astro/icons/x';
|
|
17
|
+
import Check from '@lucide/astro/icons/check';
|
|
16
18
|
import { langOf } from '../lib/i18n';
|
|
17
19
|
|
|
18
20
|
interface Props {
|
|
19
21
|
kind: 'brand' | 'scales' | 'roles' | 'status' | 'labels' | 'actions' | 'tokens' | 'pairing' | 'dodont' | 'example'
|
|
20
22
|
| 'balance' | 'anatomy' | 'surfaces' | 'states' | 'banners' | 'steps' | 'themes' | 'contrast'
|
|
21
|
-
| 'palette' | 'ramps' | 'emphasis';
|
|
23
|
+
| 'palette' | 'ramps' | 'emphasis' | 'label-tag-chip';
|
|
22
24
|
group?: 'text' | 'icon' | 'surface' | 'background' | 'border';
|
|
23
25
|
/** For kind="dodont": which pair to show. */
|
|
24
26
|
item?: 'yellow' | 'meaning' | 'alone' | 'tokens' | 'primary' | 'pairing' | 'warning';
|
|
@@ -186,7 +188,7 @@ const statusRoles = [
|
|
|
186
188
|
// Token reference: every role and component token split into the four parts of its name,
|
|
187
189
|
// color.{property}.{role}.{emphasis}.{state}. A part that is left out takes its default.
|
|
188
190
|
const PROPS = ['text', 'icon', 'link', 'surface', 'background', 'border', 'skeleton', 'code'];
|
|
189
|
-
const ROLES = ['neutral', 'brand', 'danger', 'warning', 'success', 'info', 'inverse', 'disabled', 'page', 'overlay', 'scrim', 'on-bold', 'on-brand', 'background', 'text'];
|
|
191
|
+
const ROLES = ['neutral', 'primary', 'brand', 'danger', 'warning', 'success', 'info', 'inverse', 'disabled', 'page', 'overlay', 'scrim', 'on-bold', 'on-brand', 'background', 'text'];
|
|
190
192
|
const EMPHASIS = ['subtle', 'subtlest', 'bold'];
|
|
191
193
|
const STATES = ['hover', 'pressed', 'selected', 'focus'];
|
|
192
194
|
const SCALE_NAMES = Object.keys(scaleNames);
|
|
@@ -267,7 +269,13 @@ const DangerIcon = icon.danger;
|
|
|
267
269
|
// Palette: the ink that reads best on each swatch, and where the brand colours sit.
|
|
268
270
|
const INK_DARK = '#2b2a28';
|
|
269
271
|
const INK_LIGHT = '#ffffff';
|
|
270
|
-
|
|
272
|
+
// Text drawn on a sample colour: white or graphite, whichever contrasts more. Mid steps (9) reach
|
|
273
|
+
// 4.5:1 with neither, so they take black, which they meet at about 5.7:1 (WCAG 1.4.3).
|
|
274
|
+
const INK_BLACK = '#000000';
|
|
275
|
+
const ink = (bg: string) => {
|
|
276
|
+
const best = contrast(INK_LIGHT, bg) >= contrast(INK_DARK, bg) ? INK_LIGHT : INK_DARK;
|
|
277
|
+
return contrast(best, bg) >= 4.5 ? best : INK_BLACK;
|
|
278
|
+
};
|
|
271
279
|
const brandStep: Record<'light' | 'dark', Record<string, number>> = { light: { yellow: 7, graphite: 12 }, dark: { yellow: 11 } };
|
|
272
280
|
|
|
273
281
|
// Role specimens: each role token drawn as what it paints, on the background it is checked on.
|
|
@@ -364,7 +372,7 @@ const actions = [
|
|
|
364
372
|
return (
|
|
365
373
|
<td data-label={mode === 'light' ? L('Light', 'Sáng') : L('Dark', 'Tối')}>
|
|
366
374
|
<span class={`c-spec is-${group}`} style={sp.style} aria-hidden="true">
|
|
367
|
-
{group === 'icon' ? <SuccessIcon size={20} /> : sp.body === 'fill' ? <span class="c-spec-fill" /> : sp.body}
|
|
375
|
+
{group === 'icon' ? <SuccessIcon size={20} /> : sp.body === 'fill' ? <span class="c-spec-fill" /> : <span data-sample={sp.body} />}
|
|
368
376
|
</span>
|
|
369
377
|
<span class="c-num">{up(r[mode])}</span>
|
|
370
378
|
</td>
|
|
@@ -448,6 +456,36 @@ const actions = [
|
|
|
448
456
|
</div>
|
|
449
457
|
)}
|
|
450
458
|
|
|
459
|
+
{kind === 'label-tag-chip' && (
|
|
460
|
+
<div class="c-ltc">
|
|
461
|
+
<figure class="c-label-set">
|
|
462
|
+
<figcaption><b>{L('Label', 'Nhãn')}</b> · {L('a status the system sets; people only read it', 'trạng thái do hệ thống gán; người dùng chỉ đọc')}</figcaption>
|
|
463
|
+
<div class="c-label-row">
|
|
464
|
+
<span class="bh-label is-success">{L('Synced', 'Đã đồng bộ')}</span>
|
|
465
|
+
<span class="bh-label is-danger">{L('Failed', 'Thất bại')}</span>
|
|
466
|
+
<span class="bh-label is-warning">{L('Expiring', 'Sắp hết hạn')}</span>
|
|
467
|
+
</div>
|
|
468
|
+
</figure>
|
|
469
|
+
<figure class="c-label-set">
|
|
470
|
+
<figcaption><b>Tag</b> · {L('a category on an item; read it, or click it to filter when it links', 'phân loại gắn vào đối tượng; đọc, hoặc bấm để lọc khi tag là link')}</figcaption>
|
|
471
|
+
<div class="c-label-row">
|
|
472
|
+
<span class="kit-tag">{L('Orders', 'Đơn hàng')}</span>
|
|
473
|
+
<span class="kit-tag">Staging</span>
|
|
474
|
+
<span class="kit-tag">Backend</span>
|
|
475
|
+
</div>
|
|
476
|
+
</figure>
|
|
477
|
+
<figure class="c-label-set">
|
|
478
|
+
<figcaption><b>Chip</b> · {L('a value people picked; remove it, or turn it on and off', 'giá trị người dùng đã chọn; gỡ ra, hoặc bật và tắt')}</figcaption>
|
|
479
|
+
<div class="c-label-row">
|
|
480
|
+
<span class="c-chip">{L('Status: Failed', 'Trạng thái: Thất bại')}<X size={14} aria-hidden="true" /></span>
|
|
481
|
+
<span class="c-chip is-on"><Check size={14} aria-hidden="true" />{L('Failed', 'Thất bại')}</span>
|
|
482
|
+
<span class="c-chip">{L('Synced', 'Đã đồng bộ')}</span>
|
|
483
|
+
</div>
|
|
484
|
+
<p class="c-ltc-note">{L('Removable chip · filter chip on · filter chip off', 'Chip gỡ được · chip lọc đang bật · chip lọc đang tắt')}</p>
|
|
485
|
+
</figure>
|
|
486
|
+
</div>
|
|
487
|
+
)}
|
|
488
|
+
|
|
451
489
|
{kind === 'tokens' && (
|
|
452
490
|
<div class="c-tokens">
|
|
453
491
|
{vi
|
|
@@ -545,13 +583,13 @@ const actions = [
|
|
|
545
583
|
<figure class="c-dd-panel is-dont">
|
|
546
584
|
<figcaption><span aria-hidden="true">✕</span> {L('Don’t', 'Không nên')}</figcaption>
|
|
547
585
|
<div class="c-dd-stage">
|
|
548
|
-
{item === 'yellow' && (<span class="c-dd-yellow-text"
|
|
586
|
+
{item === 'yellow' && (<span class="c-dd-yellow-text" role="img" aria-label={L('Yellow link text: Sync now', 'Chữ link màu vàng: Đồng bộ ngay')} data-sample={L('Sync now', 'Đồng bộ ngay')} />)}
|
|
549
587
|
{item === 'meaning' && (<span class="bh-label is-danger">{L('New', 'Mới')}</span>)}
|
|
550
|
-
{item === 'alone' && (<span class="c-dd-dot" aria-label={L('Red dot only', 'Chỉ có chấm đỏ')} />)}
|
|
588
|
+
{item === 'alone' && (<span class="c-dd-dot" role="img" aria-label={L('Red dot only', 'Chỉ có chấm đỏ')} />)}
|
|
551
589
|
{item === 'tokens' && (<code class="c-dd-code">color: #5f5e5c;<br />color: var(--bh-color-graphite-11);</code>)}
|
|
552
|
-
{item === 'primary' && (<span class="c-dd-row"><span class="bh-button bh-button-primary">{L('Save', 'Lưu')}</span><span class="bh-button bh-button-primary">{L('Publish', 'Xuất bản')}</span><span class="c-dd-yellow-button"
|
|
553
|
-
{item === 'pairing' && (<span class="c-dd-fill is-wrong"
|
|
554
|
-
{item === 'warning' && (<span class="c-dd-yellow-label"
|
|
590
|
+
{item === 'primary' && (<span class="c-dd-row"><span class="bh-button bh-button-primary">{L('Save', 'Lưu')}</span><span class="bh-button bh-button-primary">{L('Publish', 'Xuất bản')}</span><span class="c-dd-yellow-button" role="img" aria-label={L('Yellow button: Export', 'Nút màu vàng: Xuất file')} data-sample={L('Export', 'Xuất file')} /></span>)}
|
|
591
|
+
{item === 'pairing' && (<span class="c-dd-fill is-wrong" role="img" aria-label={L('Dark red text on a red fill: Sync failed, 3 orders skipped', 'Chữ đỏ sẫm trên nền đỏ: Đồng bộ lỗi, bỏ qua 3 đơn hàng')}><span data-sample={L('Sync failed', 'Đồng bộ lỗi')} /><small data-sample={L('3 orders skipped', 'Bỏ qua 3 đơn hàng')} /></span>)}
|
|
592
|
+
{item === 'warning' && (<span class="c-dd-yellow-label" role="img" aria-label={L('Yellow label: Partial', 'Nhãn màu vàng: Một phần')} data-sample={L('Partial', 'Một phần')} />)}
|
|
555
593
|
</div>
|
|
556
594
|
<p>
|
|
557
595
|
{item === 'yellow' && L('Yellow text or links: 1.85:1 on white, unreadable.', 'Chữ hoặc link màu vàng: 1.85:1 trên nền trắng, không đọc được.')}
|
|
@@ -651,7 +689,7 @@ const actions = [
|
|
|
651
689
|
<td><span class="bh-button bh-button-primary" style="background: var(--bh-color-background-neutral-bold-hover); border-color: var(--bh-color-background-neutral-bold-hover)">{L('Save', 'Lưu')}</span></td>
|
|
652
690
|
<td><span class="bh-button bh-button-primary" style="background: var(--bh-color-background-neutral-bold-pressed); border-color: var(--bh-color-background-neutral-bold-pressed)">{L('Save', 'Lưu')}</span></td>
|
|
653
691
|
<td><span class="bh-button bh-button-primary c-focus">{L('Save', 'Lưu')}</span></td>
|
|
654
|
-
<td><span class="bh-button c-disabled">{L('Save', 'Lưu')}</span></td>
|
|
692
|
+
<td><span class="bh-button c-disabled" aria-disabled="true">{L('Save', 'Lưu')}</span></td>
|
|
655
693
|
</tr>
|
|
656
694
|
<tr>
|
|
657
695
|
<th scope="row">{L('Default', 'Nút mặc định')}</th>
|
|
@@ -659,7 +697,7 @@ const actions = [
|
|
|
659
697
|
<td><span class="bh-button" style="background: var(--bh-color-background-neutral-subtle-hover)">{L('Cancel', 'Huỷ')}</span></td>
|
|
660
698
|
<td><span class="bh-button" style="background: var(--bh-color-background-neutral-subtle-pressed)">{L('Cancel', 'Huỷ')}</span></td>
|
|
661
699
|
<td><span class="bh-button c-focus">{L('Cancel', 'Huỷ')}</span></td>
|
|
662
|
-
<td><span class="bh-button c-disabled">{L('Cancel', 'Huỷ')}</span></td>
|
|
700
|
+
<td><span class="bh-button c-disabled" aria-disabled="true">{L('Cancel', 'Huỷ')}</span></td>
|
|
663
701
|
</tr>
|
|
664
702
|
<tr>
|
|
665
703
|
<th scope="row">{L('Row', 'Dòng')}</th>
|
|
@@ -702,7 +740,7 @@ const actions = [
|
|
|
702
740
|
{step <= 2 && <span class="c-step-bg" style={`background: ${v}`} />}
|
|
703
741
|
{step >= 3 && step <= 5 && <span class="c-step-pill" style={`background: ${v}`}>Tag</span>}
|
|
704
742
|
{step >= 6 && step <= 8 && <span class="c-step-line" style={`border-color: ${v}`} />}
|
|
705
|
-
{step >= 9 && step <= 10 && <span class="c-step-fill" style={`background: ${v}`}>{L('Go', 'Đi')}</span>}
|
|
743
|
+
{step >= 9 && step <= 10 && <span class="c-step-fill" style={`background: ${v}; --fill-ink-light: ${ink(tok(`${sc}.${step}`).light)}; --fill-ink-dark: ${ink(tok(`${sc}.${step}`).dark)}`}>{L('Go', 'Đi')}</span>}
|
|
706
744
|
{step >= 11 && <span class="c-step-text" style={`color: ${v}`}>Aa</span>}
|
|
707
745
|
<small>{step}</small>
|
|
708
746
|
</div>
|
|
@@ -724,8 +762,8 @@ const actions = [
|
|
|
724
762
|
<div class="c-contrast">
|
|
725
763
|
{contrastSamples.map((c) => (
|
|
726
764
|
<figure class={c.pass ? 'is-pass' : 'is-fail'}>
|
|
727
|
-
<div class="c-contrast-chip" style={c.min === 3 ? `background: ${c.bgVal}` : `background: ${c.bgVal}; color: ${c.fgVal}`}>
|
|
728
|
-
{c.min === 3 ? <span class="c-contrast-box" style={`border-color: ${c.fgVal}`} /> : L('Synced 2 min ago', 'Đồng bộ 2 phút trước')}
|
|
765
|
+
<div class="c-contrast-chip" role="img" aria-label={`${L('Sample', 'Mẫu')}: ${c.text}`} style={c.min === 3 ? `background: ${c.bgVal}` : `background: ${c.bgVal}; color: ${c.fgVal}`}>
|
|
766
|
+
{c.min === 3 ? <span class="c-contrast-box" style={`border-color: ${c.fgVal}`} /> : <span data-sample={L('Synced 2 min ago', 'Đồng bộ 2 phút trước')} />}
|
|
729
767
|
</div>
|
|
730
768
|
<figcaption><b>{c.pass ? L('Pass', 'Đạt') : L('Fail', 'Không đạt')} {ratio(c.r)}</b> {c.text} ({L('needs', 'cần')} {c.min}:1)</figcaption>
|
|
731
769
|
</figure>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Illustrations for the Motion page. Durations and curves come from the motion tokens, so the demos
|
|
3
|
+
// stop when reduced motion is on, like the product does.
|
|
4
|
+
import '../styles/layout.css';
|
|
5
|
+
import '../styles/shapes.css';
|
|
6
|
+
import '../styles/elevation.css';
|
|
7
|
+
import '../styles/motion.css';
|
|
8
|
+
import { langOf } from '../lib/i18n';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
kind: 'curves' | 'durations' | 'enterexit' | 'dodont';
|
|
12
|
+
/** dodont: 'exit' | 'stagger'. */
|
|
13
|
+
item?: string;
|
|
14
|
+
}
|
|
15
|
+
const { kind, item } = Astro.props;
|
|
16
|
+
const vi = langOf(Astro.url.pathname) === 'vi';
|
|
17
|
+
const L = (en: string, viText: string) => (vi ? viText : en);
|
|
18
|
+
const curves = [
|
|
19
|
+
['standard', '0.4, 0, 0.2, 1', L('Moves within the screen', 'Di chuyển trong màn hình')],
|
|
20
|
+
['enter', '0, 0, 0.2, 1', L('Comes onto the screen', 'Đi vào màn hình')],
|
|
21
|
+
['exit', '0.4, 0, 1, 1', L('Leaves the screen', 'Rời khỏi màn hình')],
|
|
22
|
+
['linear', '0, 0, 1, 1', L('Fades, progress, loops', 'Mờ dần, tiến trình, vòng lặp')],
|
|
23
|
+
['emphasized', '0.05, 0.7, 0.1, 1', L('Rare emphasized moments', 'Khoảnh khắc nhấn mạnh hiếm gặp')],
|
|
24
|
+
];
|
|
25
|
+
const durations = ['fast', 'default', 'slow', 'slower', 'slowest'];
|
|
26
|
+
const S = 100, P = 8;
|
|
27
|
+
const path = (v: string) => {
|
|
28
|
+
const [x1, y1, x2, y2] = v.split(',').map(Number);
|
|
29
|
+
const X = (t: number) => P + t * S, Y = (t: number) => P + S - t * S;
|
|
30
|
+
return `M${X(0)} ${Y(0)} C${X(x1)} ${Y(y1)} ${X(x2)} ${Y(y2)} ${X(1)} ${Y(1)}`;
|
|
31
|
+
};
|
|
32
|
+
const play = L('Play', 'Chạy');
|
|
33
|
+
const menuItems = [L('Run sync now', 'Đồng bộ ngay'), L('Pause', 'Tạm dừng'), L('Edit mapping', 'Sửa mapping')];
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
{kind === 'curves' && (
|
|
37
|
+
<div class="mo-root" data-mo>
|
|
38
|
+
<div class="mo-curves">
|
|
39
|
+
{curves.map(([name, v, use]) => (
|
|
40
|
+
<div class="mo-curve">
|
|
41
|
+
<svg viewBox={`0 0 ${S + 2 * P} ${S + 2 * P}`} role="img" aria-label={L(`Curve ${name}: distance over time`, `Đường cong ${name}: quãng đường theo thời gian`)}><rect class="mo-grid" x={P} y={P} width={S} height={S} /><path class="mo-line" d={path(v)} /></svg>
|
|
42
|
+
<b>{name}</b><span>{use}</span>
|
|
43
|
+
</div>
|
|
44
|
+
))}
|
|
45
|
+
</div>
|
|
46
|
+
<div class="mo-lanes">
|
|
47
|
+
{curves.map(([name]) => (
|
|
48
|
+
<div class="mo-lane"><code>{name}</code><div class="mo-track"><span class="mo-dot" style={`--mo-d: var(--bh-motion-duration-slower); --mo-e: var(--bh-motion-easing-${name})`}></span></div></div>
|
|
49
|
+
))}
|
|
50
|
+
</div>
|
|
51
|
+
<div class="mo-actions"><button type="button" class="kit-btn" data-mo-toggle>{play}</button><span>{L('All five run for 400 ms.', 'Cả năm chạy cùng 400 ms.')}</span></div>
|
|
52
|
+
</div>
|
|
53
|
+
)}
|
|
54
|
+
|
|
55
|
+
{kind === 'durations' && (
|
|
56
|
+
<div class="mo-root" data-mo>
|
|
57
|
+
<div class="mo-lanes">
|
|
58
|
+
{durations.map((d) => (
|
|
59
|
+
<div class="mo-lane"><code>{d}</code><div class="mo-track"><span class="mo-dot" style={`--mo-d: var(--bh-motion-duration-${d}); --mo-e: var(--bh-motion-easing-standard)`}></span></div></div>
|
|
60
|
+
))}
|
|
61
|
+
</div>
|
|
62
|
+
<div class="mo-actions"><button type="button" class="kit-btn" data-mo-toggle>{play}</button><span>{L('Same curve, standard.', 'Cùng đường cong standard.')}</span></div>
|
|
63
|
+
</div>
|
|
64
|
+
)}
|
|
65
|
+
|
|
66
|
+
{kind === 'enterexit' && (
|
|
67
|
+
<div class="mo-pair">
|
|
68
|
+
<div class="mo-root" data-mo>
|
|
69
|
+
<div class="mo-stage" data-mo-stage>
|
|
70
|
+
<span class="el-menu">{menuItems.map((m) => <span>{m}</span>)}</span>
|
|
71
|
+
</div>
|
|
72
|
+
<div class="mo-actions"><button type="button" class="kit-btn" data-mo-toggle data-open={L('Open menu', 'Mở menu')} data-close={L('Close menu', 'Đóng menu')}>{L('Open menu', 'Mở menu')}</button><span>{L('In: default, slide 8 px. Out: fast, 4 px.', 'Vào: default, trượt 8 px. Ra: fast, 4 px.')}</span></div>
|
|
73
|
+
</div>
|
|
74
|
+
<div class="mo-root" data-mo>
|
|
75
|
+
<div class="mo-stage" data-mo-stage>
|
|
76
|
+
<div class="el-dialog"><b>{L('Disconnect the store?', 'Ngắt kết nối cửa hàng?')}</b><span>{L('Orders stop syncing.', 'Đơn hàng sẽ ngừng đồng bộ.')}</span></div>
|
|
77
|
+
</div>
|
|
78
|
+
<div class="mo-actions"><button type="button" class="kit-btn" data-mo-toggle data-open={L('Open dialog', 'Mở dialog')} data-close={L('Close dialog', 'Đóng dialog')}>{L('Open dialog', 'Mở dialog')}</button><span>{L('In: slow, from 95%. Out: default.', 'Vào: slow, phóng từ 95%. Ra: default.')}</span></div>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
)}
|
|
82
|
+
|
|
83
|
+
{kind === 'dodont' && (
|
|
84
|
+
<div class="sp-dd sh-root">
|
|
85
|
+
{['do', 'dont'].map((side) => (
|
|
86
|
+
<figure class={`sp-dd-panel is-${side}`}>
|
|
87
|
+
<figcaption><span aria-hidden="true">{side === 'do' ? '✓' : '✕'}</span> {side === 'do' ? L('Do', 'Nên') : L('Don’t', 'Không nên')}</figcaption>
|
|
88
|
+
<div class="sp-dd-stage mo-root" data-mo>
|
|
89
|
+
{item === 'exit' && (
|
|
90
|
+
<div class="mo-stage" data-mo-stage style={side === 'do' ? undefined : '--mo-out: var(--bh-motion-duration-slowest) var(--bh-motion-easing-exit)'}>
|
|
91
|
+
<span class="el-menu">{menuItems.map((m) => <span>{m}</span>)}</span>
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
{item === 'stagger' && (
|
|
95
|
+
<div class="mo-stage" data-mo-stage data-step={side === 'do' ? '50' : '200'}>
|
|
96
|
+
<div class="mo-list">{Array.from({ length: 6 }, () => <span></span>)}</div>
|
|
97
|
+
</div>
|
|
98
|
+
)}
|
|
99
|
+
<div class="mo-actions"><button type="button" class="kit-btn is-small" data-mo-toggle data-open={play} data-close={L('Reset', 'Đặt lại')}>{play}</button></div>
|
|
100
|
+
</div>
|
|
101
|
+
<p>
|
|
102
|
+
{item === 'exit' && side === 'do' && L('Close faster than you open. People wait for what arrives, not for what leaves.', 'Đóng nhanh hơn lúc mở. Người dùng chờ thứ đang tới, không chờ thứ đang đi.')}
|
|
103
|
+
{item === 'exit' && side === 'dont' && L('A menu that takes 600 ms to close blocks the next click.', 'Menu mất 600 ms mới đóng sẽ chặn cú bấm tiếp theo.')}
|
|
104
|
+
{item === 'stagger' && side === 'do' && L('Stagger items by 50 ms, and keep the whole sequence under 500 ms.', 'So le mỗi mục 50 ms, cả chuỗi không quá 500 ms.')}
|
|
105
|
+
{item === 'stagger' && side === 'dont' && L('A long stagger makes people wait for the list they asked for.', 'So le quá dài bắt người dùng chờ danh sách họ vừa yêu cầu.')}
|
|
106
|
+
</p>
|
|
107
|
+
</figure>
|
|
108
|
+
))}
|
|
109
|
+
</div>
|
|
110
|
+
)}
|
|
111
|
+
|
|
112
|
+
<script>
|
|
113
|
+
// One handler for every demo on the page: toggles the open state; staggered lists get their delays here.
|
|
114
|
+
// Under reduced motion the tokens already make every duration 0; the stagger delay is set here
|
|
115
|
+
// in script, so it has to check the setting itself.
|
|
116
|
+
const still = matchMedia('(prefers-reduced-motion: reduce)');
|
|
117
|
+
document.querySelectorAll<HTMLElement>('[data-mo]').forEach((root) => {
|
|
118
|
+
const button = root.querySelector<HTMLButtonElement>('[data-mo-toggle]');
|
|
119
|
+
const stage = root.querySelector<HTMLElement>('[data-mo-stage]');
|
|
120
|
+
if (!button || button.dataset.bound) return;
|
|
121
|
+
button.dataset.bound = '1';
|
|
122
|
+
button.addEventListener('click', () => {
|
|
123
|
+
if (!stage) { root.classList.toggle('is-on'); return; }
|
|
124
|
+
const open = !stage.classList.contains('is-open');
|
|
125
|
+
const menu = stage.querySelector<HTMLElement>('.el-menu');
|
|
126
|
+
if (open && menu) { menu.classList.add('is-far'); void menu.offsetWidth; menu.classList.remove('is-far'); }
|
|
127
|
+
const step = Number(stage.dataset.step || 0);
|
|
128
|
+
stage.querySelectorAll<HTMLElement>('.mo-list span').forEach((el, i) => {
|
|
129
|
+
el.style.transitionDelay = open && step && !still.matches ? `${i * step}ms` : '0ms';
|
|
130
|
+
});
|
|
131
|
+
stage.classList.toggle('is-open', open);
|
|
132
|
+
if (button.dataset.open) button.textContent = open ? button.dataset.close! : button.dataset.open;
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
</script>
|