@beehexa/design-rules 2611.3.3 → 2611.5.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/README.md +1 -1
- package/dist/AGENTS.md +1 -7
- package/dist/catalog.json +703 -321
- package/dist/docs/public/_redirects +2 -0
- package/dist/docs/scripts/color-pairs.mjs +5 -1
- package/dist/docs/scripts/token-utils.d.mts +5 -1
- package/dist/docs/scripts/token-utils.mjs +44 -4
- package/dist/docs/src/brand/structure-proposal.md +1 -1
- package/dist/docs/src/components/ColorDemo.astro +56 -18
- package/dist/docs/src/components/ElevationDemo.astro +196 -0
- package/dist/docs/src/components/LayoutDemo.astro +1 -1
- 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 +95 -0
- package/dist/docs/src/components/RoleGuides.astro +2 -2
- package/dist/docs/src/components/ShapeDemo.astro +88 -44
- package/dist/docs/src/components/ShapePin.astro +5 -3
- 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 +102 -0
- 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 +13 -6
- 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 +34 -5
- package/dist/docs/src/content/foundations/styles/data-visualization.mdx +150 -6
- package/dist/docs/src/content/foundations/styles/elevation.mdx +72 -3
- 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 +13 -8
- package/dist/docs/src/content/foundations/styles/interaction-states.mdx +82 -9
- package/dist/docs/src/content/foundations/styles/layout/app-frame.mdx +12 -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 +49 -5
- 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 +23 -6
- package/dist/docs/src/content/foundations/styles/spacing.mdx +17 -3
- package/dist/docs/src/content/foundations/styles/typography/code.mdx +5 -3
- 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 +67 -5
- 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 +571 -19
- package/dist/docs/src/content/tools/application-content.mdx +176 -0
- package/dist/docs/src/content/tools/editors.mdx +271 -0
- 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 +190 -0
- package/dist/docs/src/content/tools/vueflow.mdx +179 -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 +12 -6
- 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 +34 -5
- package/dist/docs/src/content-vi/foundations/styles/data-visualization.mdx +75 -6
- package/dist/docs/src/content-vi/foundations/styles/elevation.mdx +81 -0
- 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 +13 -8
- 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 +13 -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 +49 -5
- package/dist/docs/src/content-vi/foundations/styles/radius.mdx +63 -15
- package/dist/docs/src/content-vi/foundations/styles/size-and-density.mdx +23 -6
- package/dist/docs/src/content-vi/foundations/styles/spacing.mdx +17 -3
- package/dist/docs/src/content-vi/foundations/styles/typography/code.mdx +5 -3
- 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 +67 -5
- 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 +81 -14
- package/dist/docs/src/lib/tokens.ts +3 -0
- package/dist/docs/src/styles/chrome.css +21 -14
- package/dist/docs/src/styles/color.css +50 -53
- package/dist/docs/src/styles/docs.css +37 -55
- package/dist/docs/src/styles/elevation.css +83 -0
- package/dist/docs/src/styles/global.css +21 -10
- package/dist/docs/src/styles/icons.css +20 -23
- package/dist/docs/src/styles/kit.css +116 -0
- package/dist/docs/src/styles/layout.css +8 -13
- package/dist/docs/src/styles/motion.css +34 -0
- package/dist/docs/src/styles/opacity.css +43 -0
- package/dist/docs/src/styles/scrollbars.css +74 -0
- package/dist/docs/src/styles/shapes.css +35 -29
- package/dist/docs/src/styles/tokens.css +1663 -4
- package/dist/docs/src/styles/tokens.js +538 -4
- package/dist/docs/src/styles/typography.css +8 -11
- package/dist/docs/src/styles/zindex.css +59 -0
- package/dist/docs/tokens/border.json +1 -1
- package/dist/docs/tokens/color.json +75 -4
- package/dist/docs/tokens/content.json +24 -0
- package/dist/docs/tokens/diagram.json +54 -0
- package/dist/docs/tokens/editor.json +129 -0
- package/dist/docs/tokens/elevation.json +15 -5
- package/dist/docs/tokens/flow.json +497 -0
- package/dist/docs/tokens/layout.json +4 -0
- package/dist/docs/tokens/motion.json +37 -5
- package/dist/docs/tokens/opacity.json +9 -0
- package/dist/docs/tokens/radius.json +52 -8
- package/dist/docs/tokens/resize.json +79 -0
- package/dist/docs/tokens/scrollbar.json +40 -0
- package/dist/docs/tokens/size.json +7 -1
- package/dist/docs/tokens/spacing.json +35 -5
- package/dist/docs/tokens/switch.json +280 -0
- package/dist/docs/tokens/typography.json +5 -0
- package/dist/docs/tokens/visualization.json +123 -0
- package/dist/docs/tokens/z-index.json +49 -0
- package/dist/index.js +703 -321
- package/package.json +1 -1
|
@@ -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>
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
<div data-native-control-family aria-label="Native control family demonstration"></div>
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import { computed, createApp, defineComponent, h, onBeforeUnmount, ref, useId } from 'vue';
|
|
5
|
+
import { Alert, Avatar, Button, Card, ConfigProvider, Dropdown, Empty, Flex, InputNumber, InputSearch, Menu, MenuItem, Modal, Progress, Select, Space, Switch, Tag, TypographyText, type SelectProps } from 'ant-design-vue';
|
|
6
|
+
import { ClearOutlined, GlobalOutlined, RightOutlined } from '@ant-design/icons-vue';
|
|
7
|
+
import { tokenPixels } from '@beehexa/design-tokens';
|
|
8
|
+
import { createAntDesignVueTheme, getAntDesignVueStepProgressSize, useAntDesignVueRootFontSize } from '@beehexa/ant-design-vue-tokens';
|
|
9
|
+
import { getStatusColor } from '@beehexa/ant-design-vue-tokens/visualization';
|
|
10
|
+
import { getFlowCategoryBadgeStyles } from '@beehexa/vueflow-tokens';
|
|
11
|
+
import '@beehexa/ant-design-vue-tokens/css';
|
|
12
|
+
|
|
13
|
+
const Demo = defineComponent({
|
|
14
|
+
setup() {
|
|
15
|
+
const rootFontSize = useAntDesignVueRootFontSize();
|
|
16
|
+
const dark = ref(document.documentElement.dataset.theme === 'dark');
|
|
17
|
+
const locale = ref<'en' | 'vi'>(document.documentElement.lang.startsWith('vi') ? 'vi' : 'en');
|
|
18
|
+
const language = ref('English');
|
|
19
|
+
const query = ref('');
|
|
20
|
+
const status = ref<SelectProps['value']>('all');
|
|
21
|
+
const details = ref(false);
|
|
22
|
+
const controlId = useId();
|
|
23
|
+
const languageOpen = ref(false);
|
|
24
|
+
const languageTrigger = ref<{ focus: () => void } | null>(null);
|
|
25
|
+
const closeLanguage = () => { languageOpen.value = false; languageTrigger.value?.focus(); };
|
|
26
|
+
const selectedChoice = ref('flow');
|
|
27
|
+
const buttonSize = ref<'small' | 'middle' | 'large'>('middle');
|
|
28
|
+
const buttonPresses = ref(0);
|
|
29
|
+
const activateButton = () => { buttonPresses.value += 1; };
|
|
30
|
+
const buttonSizeOptions = ['small', 'middle', 'large'].map(value => ({ value, label: value }));
|
|
31
|
+
const buttonAvailability = ['enabled', 'loading', 'disabled'] as const;
|
|
32
|
+
const buttonCases = (['default', 'primary', 'dashed', 'link', 'text'] as const).flatMap(type =>
|
|
33
|
+
[false, true].map(danger => ({ key: `${type}${danger ? '-danger' : ''}`, type, danger, ghost: false, inverse: false })));
|
|
34
|
+
buttonCases.push(
|
|
35
|
+
{ key: 'primary-ghost', type: 'primary', danger: false, ghost: true, inverse: false },
|
|
36
|
+
{ key: 'primary-ghost-danger', type: 'primary', danger: true, ghost: true, inverse: false },
|
|
37
|
+
{ key: 'inverse-ghost', type: 'default', danger: false, ghost: true, inverse: true }
|
|
38
|
+
);
|
|
39
|
+
const buttonWords = computed(() => locale.value === 'vi' ? {
|
|
40
|
+
title: 'Một họ Nút gốc, các vai trò khác nhau',
|
|
41
|
+
help: 'Nền chính sáng trong giao diện tối là có chủ đích; đường xanh phía dưới khi chưa lấy nét thì không. Di chuột, nhấn giữ và dùng Tab/Enter/Space. Chỉ nút khả dụng được tăng bộ đếm.',
|
|
42
|
+
default: 'Chi tiết', primary: 'Tiếp tục', dashed: 'Thêm ứng dụng', link: 'Hủy', text: 'Chọn ứng dụng khác',
|
|
43
|
+
enabled: 'Khả dụng', loading: 'Đang xử lý', disabled: 'Vô hiệu hóa', danger: 'Nguy hiểm', ghost: 'Viền trong suốt',
|
|
44
|
+
size: 'Cỡ nút', presses: 'Lần kích hoạt', anchor: 'Liên kết đã vô hiệu hóa'
|
|
45
|
+
} : {
|
|
46
|
+
title: 'One native Button family, distinct roles',
|
|
47
|
+
help: 'A light primary fill in dark mode is intentional; a blue lower stripe while unfocused is not. Hover, hold a press and use Tab/Enter/Space. Only available buttons may increment the counter.',
|
|
48
|
+
default: 'Details', primary: 'Continue', dashed: 'Add app', link: 'Cancel', text: 'Choose another app',
|
|
49
|
+
enabled: 'Available', loading: 'Loading', disabled: 'Disabled', danger: 'Danger', ghost: 'Ghost',
|
|
50
|
+
size: 'Button size', presses: 'Activations', anchor: 'Disabled link'
|
|
51
|
+
});
|
|
52
|
+
const stepTotal = ref(5);
|
|
53
|
+
const stepIndex = ref(2);
|
|
54
|
+
const stepSize = computed(() => getAntDesignVueStepProgressSize(rootFontSize.value));
|
|
55
|
+
const stepWords = computed(() => locale.value === 'vi' ? {
|
|
56
|
+
title: 'Tiến độ từng bước chỉ đọc', total: 'Tổng số bước', first: 'Đầu', middle: 'Giữa', last: 'Cuối',
|
|
57
|
+
current: `Bước ${stepIndex.value}/${stepTotal.value}`, optedIn: 'Thanh ngang có chọn dùng', base: 'Progress small gốc, không chọn dùng'
|
|
58
|
+
} : {
|
|
59
|
+
title: 'Read-only step progress', total: 'Total steps', first: 'First', middle: 'Middle', last: 'Last',
|
|
60
|
+
current: `Step ${stepIndex.value} of ${stepTotal.value}`, optedIn: 'Opt-in horizontal marks', base: 'Native small Progress, no opt-in'
|
|
61
|
+
});
|
|
62
|
+
const emptyWords = computed(() => locale.value === 'vi' ? {
|
|
63
|
+
title: 'Empty gốc trong vùng được cấp', description: 'Chọn một mục để xem chi tiết',
|
|
64
|
+
base: 'Empty gốc, không chọn dùng', simple: 'Hình đơn giản gốc'
|
|
65
|
+
} : {
|
|
66
|
+
title: 'Native Empty in allocated slots', description: 'Select an item to view details',
|
|
67
|
+
base: 'Native Empty, no opt-in', simple: 'Native simple illustration'
|
|
68
|
+
});
|
|
69
|
+
const expandedChoices = ref<string[]>(['flow']);
|
|
70
|
+
const choices = computed(() => locale.value === 'vi'
|
|
71
|
+
? [{ key: 'transform', title: 'Biến đổi dữ liệu đầu-cuối', shortcut: 'Ctrl+2' }, { key: 'flow', title: 'Luồng đồng bộ', shortcut: 'Ctrl+3' }]
|
|
72
|
+
: [{ key: 'transform', title: 'End-to-end transformations', shortcut: 'Ctrl+2' }, { key: 'flow', title: 'Sync flow', shortcut: 'Ctrl+3' }]);
|
|
73
|
+
const switchChanges = ref(0);
|
|
74
|
+
const switchSaves = ref(0);
|
|
75
|
+
const switchSaved = ref(false);
|
|
76
|
+
const switchSaving = ref(false);
|
|
77
|
+
let switchSaveTimer: ReturnType<typeof setTimeout> | undefined;
|
|
78
|
+
const switchExamples = (['default', 'small'] as const).flatMap(size =>
|
|
79
|
+
(['enabled', 'loading', 'disabled'] as const).flatMap(availability =>
|
|
80
|
+
[false, true].map(initialChecked => ({
|
|
81
|
+
id: `${controlId}-switch-${size}-${availability}-${initialChecked}`,
|
|
82
|
+
size, availability, initialChecked, checked: ref(initialChecked)
|
|
83
|
+
}))));
|
|
84
|
+
const switchWords = computed(() => locale.value === 'vi' ? {
|
|
85
|
+
title: 'Công tắc gốc: bật không có nghĩa là thành công',
|
|
86
|
+
help: 'Đổi giao diện sáng/tối và ngôn ngữ của trang. Di chuột, nhấn giữ hoặc dùng Tab, Space/Enter và phím trái/phải. Công tắc đang xử lý hoặc bị vô hiệu hóa không được tăng bộ đếm.',
|
|
87
|
+
on: 'Bật', off: 'Tắt', normal: 'Cỡ thường', small: 'Cỡ nhỏ',
|
|
88
|
+
enabled: 'Có thể dùng', loading: 'Đang xử lý', disabled: 'Vô hiệu hóa',
|
|
89
|
+
initialOn: 'ban đầu bật', initialOff: 'ban đầu tắt',
|
|
90
|
+
save: 'Lưu có kiểm soát (mô phỏng 1,2 giây)', callbacks: 'Lần gọi thay đổi', saves: 'Lần lưu', saving: 'Đang lưu', saved: 'Đã lưu'
|
|
91
|
+
} : {
|
|
92
|
+
title: 'Native Switch: ON does not mean success',
|
|
93
|
+
help: 'Change the site light/dark theme and language. Hover, hold a press or use Tab, Space/Enter and Left/Right. Loading and disabled switches must not increment the counter.',
|
|
94
|
+
on: 'On', off: 'Off', normal: 'Normal', small: 'Small',
|
|
95
|
+
enabled: 'Available', loading: 'Loading', disabled: 'Disabled',
|
|
96
|
+
initialOn: 'initially on', initialOff: 'initially off',
|
|
97
|
+
save: 'Controlled save (1.2-second simulation)', callbacks: 'Change callbacks', saves: 'Saves', saving: 'Saving', saved: 'Saved'
|
|
98
|
+
});
|
|
99
|
+
const switchExampleLabel = (sample: typeof switchExamples[number]) => {
|
|
100
|
+
const words = switchWords.value;
|
|
101
|
+
return `${sample.size === 'small' ? words.small : words.normal} / ${words[sample.availability]} / ${sample.initialChecked ? words.initialOn : words.initialOff}`;
|
|
102
|
+
};
|
|
103
|
+
const saveSwitch = (checked: boolean | string | number) => {
|
|
104
|
+
switchSaves.value += 1;
|
|
105
|
+
switchSaving.value = true;
|
|
106
|
+
switchSaveTimer = setTimeout(() => {
|
|
107
|
+
switchSaved.value = checked === true;
|
|
108
|
+
switchSaving.value = false;
|
|
109
|
+
switchSaveTimer = undefined;
|
|
110
|
+
}, 1200);
|
|
111
|
+
};
|
|
112
|
+
const syncContext = () => {
|
|
113
|
+
dark.value = document.documentElement.dataset.theme === 'dark';
|
|
114
|
+
locale.value = document.documentElement.lang.startsWith('vi') ? 'vi' : 'en';
|
|
115
|
+
};
|
|
116
|
+
const observer = new MutationObserver(syncContext);
|
|
117
|
+
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme', 'lang'] });
|
|
118
|
+
onBeforeUnmount(() => {
|
|
119
|
+
observer.disconnect();
|
|
120
|
+
if (switchSaveTimer !== undefined) clearTimeout(switchSaveTimer);
|
|
121
|
+
});
|
|
122
|
+
const theme = computed(() => createAntDesignVueTheme({ dark: dark.value, locale: locale.value, rootFontSize: rootFontSize.value }));
|
|
123
|
+
const gap = () => tokenPixels('space.100', locale.value, rootFontSize.value);
|
|
124
|
+
const clearFilters = () => { query.value = ''; status.value = 'all'; };
|
|
125
|
+
return () => h(ConfigProvider, { theme: theme.value }, () => h(Flex, { vertical: true, style: { gap: 'var(--bh-space-200)' } }, () => [
|
|
126
|
+
h(Alert, { type: 'info', message: 'Real native controls: utility triggers and page controls share one family; avatar actions remain frameless.' }),
|
|
127
|
+
h(Space, { size: gap(), wrap: true, align: 'center' }, () => [
|
|
128
|
+
h(Dropdown, { trigger: ['click'], open: languageOpen.value, 'onUpdate:open': (open: boolean) => { languageOpen.value = open; } }, {
|
|
129
|
+
default: () => h(Button, { ref: languageTrigger, 'data-bh-target': 'responsive', 'aria-label': 'Choose demonstration language', 'aria-haspopup': 'menu', 'aria-expanded': languageOpen.value }, {
|
|
130
|
+
icon: () => h(GlobalOutlined), default: () => language.value
|
|
131
|
+
}),
|
|
132
|
+
overlay: () => h(Menu, { selectedKeys: [language.value], onKeydown: (event: KeyboardEvent) => { if (event.key === 'Escape') { event.stopPropagation(); closeLanguage(); } }, onClick: ({ key }: { key: string | number }) => { language.value = String(key); closeLanguage(); } }, () => [
|
|
133
|
+
h(MenuItem, { key: 'English', lang: 'en' }, () => 'English'),
|
|
134
|
+
h(MenuItem, { key: 'Tiếng Việt', lang: 'vi' }, () => 'Tiếng Việt')
|
|
135
|
+
])
|
|
136
|
+
}),
|
|
137
|
+
h(Button, { 'data-bh-target': 'responsive', 'aria-label': 'Clear demonstration filters', onClick: clearFilters }, { icon: () => h(ClearOutlined) }),
|
|
138
|
+
h(Button, { type: 'text', 'data-bh-target': 'responsive', onClick: () => { details.value = true; } }, () => h(Space, { size: gap(), align: 'center' }, () => [
|
|
139
|
+
h(Avatar, { size: tokenPixels('size.control.small', locale.value, rootFontSize.value) }, () => 'BH'), 'Sample account'
|
|
140
|
+
]))
|
|
141
|
+
]),
|
|
142
|
+
...(['small', 'middle', 'large'] as const).map(size => h(Space, { size: gap(), wrap: true, align: 'center' }, () => [
|
|
143
|
+
h(Button, { size, onClick: () => { details.value = true; } }, () => 'Default action'),
|
|
144
|
+
h(Button, { size, type: 'primary', onClick: () => { details.value = true; } }, () => 'Primary action'),
|
|
145
|
+
h(InputSearch, { size, value: query.value, 'aria-label': `${size} search`, placeholder: 'Search', 'onUpdate:value': (value: string) => { query.value = value; }, onSearch: () => { details.value = true; }, style: { width: 'min(100%, 14rem)' } }),
|
|
146
|
+
h('label', { for: `${controlId}-${size}`, 'data-bh-font': 'label-default' }, `${size} status`),
|
|
147
|
+
h(Select, { id: `${controlId}-${size}`, size, value: status.value, options: [{ value: 'all', label: 'All statuses' }, { value: 'active', label: 'Active' }], 'onUpdate:value': (value: SelectProps['value']) => { status.value = value; }, style: { width: 'min(100%, 10rem)' } })
|
|
148
|
+
])),
|
|
149
|
+
h(Space, { size: gap(), wrap: true }, () => [
|
|
150
|
+
h(Button, { disabled: true }, () => 'Disabled'),
|
|
151
|
+
h(Button, { loading: true }, () => 'Loading'),
|
|
152
|
+
h(Button, { type: 'text', onClick: clearFilters }, () => 'Frameless action'),
|
|
153
|
+
h(Button, { type: 'link', onClick: () => { details.value = true; } }, () => 'Link-style action')
|
|
154
|
+
]),
|
|
155
|
+
h(Flex, { vertical: true, style: { gap: 'var(--bh-space-100)' } }, () => [
|
|
156
|
+
h('h3', { 'data-bh-font': 'heading-small' }, buttonWords.value.title),
|
|
157
|
+
h('p', { 'data-bh-font': 'body-small' }, buttonWords.value.help),
|
|
158
|
+
h(Space, { size: gap(), wrap: true }, () => [
|
|
159
|
+
h('label', { for: `${controlId}-button-size` }, buttonWords.value.size),
|
|
160
|
+
h(Select, {
|
|
161
|
+
id: `${controlId}-button-size`, value: buttonSize.value, style: { width: '8rem' },
|
|
162
|
+
options: buttonSizeOptions,
|
|
163
|
+
'onUpdate:value': (value: SelectProps['value']) => { if (value === 'small' || value === 'middle' || value === 'large') buttonSize.value = value; }
|
|
164
|
+
})
|
|
165
|
+
]),
|
|
166
|
+
...buttonCases.map(sample => h(Space, {
|
|
167
|
+
key: sample.key, size: gap(), wrap: true, align: 'center',
|
|
168
|
+
style: sample.inverse ? { background: 'var(--bh-color-surface-inverse)', padding: 'var(--bh-space-100)' } : undefined
|
|
169
|
+
}, () => [
|
|
170
|
+
h('span', { 'data-bh-font': 'label-small', style: sample.inverse ? { color: 'var(--bh-color-text-inverse)' } : undefined },
|
|
171
|
+
`${sample.type}${sample.danger ? ` / ${buttonWords.value.danger}` : ''}${sample.ghost ? ` / ${buttonWords.value.ghost}` : ''}`),
|
|
172
|
+
...buttonAvailability.map(availability => h(Button, {
|
|
173
|
+
type: sample.type, danger: sample.danger, ghost: sample.ghost, size: buttonSize.value,
|
|
174
|
+
loading: availability === 'loading', disabled: availability === 'disabled',
|
|
175
|
+
'data-native-button-case': `${sample.key}-${availability}`,
|
|
176
|
+
onClick: activateButton
|
|
177
|
+
}, { icon: () => h(RightOutlined), default: () => `${buttonWords.value[sample.type]} / ${buttonWords.value[availability]}` }))
|
|
178
|
+
])),
|
|
179
|
+
h(Button, { href: `#${controlId}-activations`, type: 'link', disabled: true, 'data-native-button-case': 'disabled-anchor' }, () => buttonWords.value.anchor),
|
|
180
|
+
h('output', { id: `${controlId}-activations`, role: 'status', 'data-bh-font': 'body-small' }, `${buttonWords.value.presses}: ${buttonPresses.value}`)
|
|
181
|
+
]),
|
|
182
|
+
h(Flex, { vertical: true, style: { gap: 'var(--bh-space-100)' } }, () => [
|
|
183
|
+
h('h3', { 'data-bh-font': 'heading-small' }, stepWords.value.title),
|
|
184
|
+
h(Space, { size: gap(), wrap: true, align: 'center' }, () => [
|
|
185
|
+
h('label', { for: `${controlId}-step-total` }, stepWords.value.total),
|
|
186
|
+
h(InputNumber, {
|
|
187
|
+
id: `${controlId}-step-total`, min: 1, precision: 0, value: stepTotal.value,
|
|
188
|
+
onChange: (value: number | string | null) => {
|
|
189
|
+
if (typeof value === 'number' && value >= 1) { stepTotal.value = value; stepIndex.value = Math.min(stepIndex.value, value); }
|
|
190
|
+
}
|
|
191
|
+
}),
|
|
192
|
+
h(Button, { onClick: () => { stepIndex.value = 1; } }, () => stepWords.value.first),
|
|
193
|
+
h(Button, { onClick: () => { stepIndex.value = Math.ceil(stepTotal.value / 2); } }, () => stepWords.value.middle),
|
|
194
|
+
h(Button, { onClick: () => { stepIndex.value = stepTotal.value; } }, () => stepWords.value.last)
|
|
195
|
+
]),
|
|
196
|
+
h('span', { 'data-bh-font': 'label-small' }, stepWords.value.optedIn),
|
|
197
|
+
h(Space, { size: gap(), wrap: true, align: 'center' }, () => [
|
|
198
|
+
h('span', { 'data-bh-font': 'label-small' }, stepWords.value.current),
|
|
199
|
+
h(Progress, {
|
|
200
|
+
class: 'bh-ant-step-progress', steps: stepTotal.value, percent: stepIndex.value / stepTotal.value * 100,
|
|
201
|
+
size: stepSize.value, showInfo: false, 'aria-hidden': true,
|
|
202
|
+
strokeColor: getStatusColor('info', 'border', { dark: dark.value })
|
|
203
|
+
})
|
|
204
|
+
]),
|
|
205
|
+
h('span', { 'data-bh-font': 'label-small' }, stepWords.value.base),
|
|
206
|
+
h(Progress, {
|
|
207
|
+
steps: stepTotal.value, percent: stepIndex.value / stepTotal.value * 100, size: 'small',
|
|
208
|
+
showInfo: false, 'aria-hidden': true, strokeColor: getStatusColor('info', 'border', { dark: dark.value })
|
|
209
|
+
})
|
|
210
|
+
]),
|
|
211
|
+
h(Flex, { vertical: true, style: { gap: 'var(--bh-space-100)' } }, () => [
|
|
212
|
+
h('h3', { 'data-bh-font': 'heading-small' }, emptyWords.value.title),
|
|
213
|
+
...[2, 4, 12].map(rows => h(Card, { size: 'small', title: `${rows} rem` }, () =>
|
|
214
|
+
h('div', { 'data-native-empty-fit': rows, style: { display: 'flex', alignItems: 'center', justifyContent: 'center', blockSize: `${rows}rem`, minBlockSize: 0, overflow: 'auto' } },
|
|
215
|
+
h(Empty, { class: 'bh-ant-fit-empty', description: emptyWords.value.description })))),
|
|
216
|
+
h(Card, { size: 'small', title: emptyWords.value.simple }, () =>
|
|
217
|
+
h('div', { 'data-native-empty-fit': 'simple', style: { display: 'flex', alignItems: 'center', justifyContent: 'center', blockSize: '4rem', minBlockSize: 0, overflow: 'auto' } },
|
|
218
|
+
h(Empty, { class: 'bh-ant-fit-empty', image: Empty.PRESENTED_IMAGE_SIMPLE, description: emptyWords.value.description }))),
|
|
219
|
+
h(Card, { size: 'small', title: emptyWords.value.base }, () =>
|
|
220
|
+
h(Empty, { description: emptyWords.value.description }))
|
|
221
|
+
]),
|
|
222
|
+
h(Card, { title: locale.value === 'vi' ? 'Nhãn loại luồng' : 'Flow category badges', 'data-native-flow-categories': '' }, () =>
|
|
223
|
+
h(Space, { size: gap(), wrap: true }, () =>
|
|
224
|
+
['task', 'dependency', 'transformation', 'validation', 'pushStep', 'decision', 'loop', 'grouped'].map(category =>
|
|
225
|
+
h(Tag, { key: category, style: getFlowCategoryBadgeStyles(category) }, () => category)))),
|
|
226
|
+
h(Flex, { vertical: true, style: { gap: 'var(--bh-space-100)' } }, () => choices.value.map(choice => {
|
|
227
|
+
const expanded = expandedChoices.value.includes(choice.key);
|
|
228
|
+
return h(Card, { key: choice.key, size: 'small' }, {
|
|
229
|
+
title: () => h('div', { style: { display: 'grid', gridTemplateColumns: 'auto minmax(0, 1fr) max-content', alignItems: 'center', gap: 'var(--bh-space-100)' } }, [
|
|
230
|
+
h(Button, {
|
|
231
|
+
type: 'text', size: 'small', 'data-bh-target': 'responsive', 'aria-expanded': expanded,
|
|
232
|
+
'aria-controls': expanded ? `${controlId}-choice-${choice.key}` : undefined,
|
|
233
|
+
'aria-label': `${locale.value === 'vi' ? (expanded ? 'Thu gọn' : 'Mở rộng') : (expanded ? 'Collapse' : 'Expand')} ${choice.title}`,
|
|
234
|
+
onClick: () => { expandedChoices.value = expanded ? expandedChoices.value.filter(key => key !== choice.key) : [...expandedChoices.value, choice.key]; }
|
|
235
|
+
}, { icon: () => h(RightOutlined, { rotate: expanded ? 90 : 0 }) }),
|
|
236
|
+
h(Button, {
|
|
237
|
+
type: 'text', block: true, 'data-bh-layout': 'content',
|
|
238
|
+
'aria-current': selectedChoice.value === choice.key ? 'true' : undefined,
|
|
239
|
+
onClick: () => { selectedChoice.value = choice.key; }
|
|
240
|
+
}, { icon: () => h(GlobalOutlined), default: () => h(TypographyText, { strong: selectedChoice.value === choice.key }, () => choice.title) }),
|
|
241
|
+
h(Tag, () => choice.shortcut)
|
|
242
|
+
]),
|
|
243
|
+
...(expanded ? {
|
|
244
|
+
default: () => h('p', { id: `${controlId}-choice-${choice.key}` }, locale.value === 'vi'
|
|
245
|
+
? 'Nút mũi tên mở hoặc thu gọn chi tiết; nút tiêu đề chọn chế độ xem độc lập. Nhãn phím tắt minh họa căn cột, không gán phím của trình duyệt.'
|
|
246
|
+
: 'The arrow opens or closes details; the title independently selects the view. Shortcut labels demonstrate column alignment; this sample does not bind browser shortcuts.')
|
|
247
|
+
} : {})
|
|
248
|
+
});
|
|
249
|
+
})),
|
|
250
|
+
h(Flex, { vertical: true, style: { gap: 'var(--bh-space-100)' } }, () => [
|
|
251
|
+
h('h3', { 'data-bh-font': 'heading-small' }, switchWords.value.title),
|
|
252
|
+
h('p', { 'data-bh-font': 'body-small' }, switchWords.value.help),
|
|
253
|
+
...switchExamples.map(sample => h(Space, { key: sample.id, size: gap(), wrap: true, align: 'center' }, () => [
|
|
254
|
+
h('label', { for: sample.id, 'data-bh-font': 'label-small' }, switchExampleLabel(sample)),
|
|
255
|
+
h(Switch, {
|
|
256
|
+
id: sample.id, size: sample.size, checked: sample.checked.value,
|
|
257
|
+
checkedChildren: switchWords.value.on, unCheckedChildren: switchWords.value.off,
|
|
258
|
+
loading: sample.availability === 'loading', disabled: sample.availability === 'disabled',
|
|
259
|
+
'data-native-switch-case': `${sample.size}-${sample.availability}-${sample.initialChecked}`,
|
|
260
|
+
'onUpdate:checked': (checked: boolean | string | number) => { sample.checked.value = checked === true; },
|
|
261
|
+
onChange: () => { switchChanges.value += 1; }
|
|
262
|
+
})
|
|
263
|
+
])),
|
|
264
|
+
h(Space, { size: gap(), wrap: true, align: 'center' }, () => [
|
|
265
|
+
h('label', { for: `${controlId}-switch-save`, 'data-bh-font': 'label-small' }, switchWords.value.save),
|
|
266
|
+
h(Switch, {
|
|
267
|
+
id: `${controlId}-switch-save`, checked: switchSaved.value, loading: switchSaving.value,
|
|
268
|
+
checkedChildren: switchWords.value.on, unCheckedChildren: switchWords.value.off,
|
|
269
|
+
'data-native-switch-case': 'controlled-save', onChange: saveSwitch
|
|
270
|
+
})
|
|
271
|
+
]),
|
|
272
|
+
h('output', { role: 'status', 'data-bh-font': 'body-small' }, `${switchWords.value.callbacks}: ${switchChanges.value}; ${switchWords.value.saves}: ${switchSaves.value}; ${switchSaving.value ? switchWords.value.saving : switchWords.value.saved}: ${switchSaved.value ? switchWords.value.on : switchWords.value.off}.`)
|
|
273
|
+
]),
|
|
274
|
+
h(Modal, { open: details.value, title: 'Native action details', onCancel: () => { details.value = false; }, onOk: () => { details.value = false; } }, () => `Search: ${query.value || '(empty)'}; status: ${status.value}; language label: ${language.value}.`)
|
|
275
|
+
]));
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
for (const host of document.querySelectorAll<HTMLElement>('[data-native-control-family]')) createApp(Demo).mount(host);
|
|
279
|
+
</script>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Illustrations for the Opacity page. Transparency comes only from opacity.disabled and
|
|
3
|
+
// color.surface.scrim; everything else is a colour, border or size token.
|
|
4
|
+
import '../styles/layout.css';
|
|
5
|
+
import '../styles/shapes.css';
|
|
6
|
+
import '../styles/elevation.css';
|
|
7
|
+
import '../styles/opacity.css';
|
|
8
|
+
import Pin from './ShapePin.astro';
|
|
9
|
+
import { langOf } from '../lib/i18n';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
kind: 'screen' | 'tile' | 'scrim' | 'dodont';
|
|
13
|
+
/** dodont: 'container' | 'controls'. */
|
|
14
|
+
item?: string;
|
|
15
|
+
}
|
|
16
|
+
const { kind, item } = Astro.props;
|
|
17
|
+
const vi = langOf(Astro.url.pathname) === 'vi';
|
|
18
|
+
const L = (en: string, viText: string) => (vi ? viText : en);
|
|
19
|
+
const on = L('Connected', 'Đã kết nối');
|
|
20
|
+
const off = L('Turned off', 'Đã tắt');
|
|
21
|
+
const conns = [['ST', 'Store A', 'a', true], ['ER', 'ERP', 'b', true], ['AC', L('Accounting', 'Kế toán'), 'c', false], ['MK', 'Marketplace', 'd', true], ['CR', 'CRM', 'e', false], ['WH', L('Warehouse', 'Kho'), 'f', true]] as const;
|
|
22
|
+
const users = [['LN', 'Linh Nguyen', 'Admin', true], ['TP', 'Tuan Pham', 'Editor', true], ['MH', 'Mai Ho', L('Viewer · deactivated', 'Viewer · đã vô hiệu'), false]] as const;
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
{kind === 'screen' && (
|
|
26
|
+
<div class="op-wrap" role="img" aria-label={L('Connections with two turned off, and a team list with one deactivated member', 'Danh sách kết nối có hai kết nối đã tắt, và danh sách thành viên có một người đã bị vô hiệu')}>
|
|
27
|
+
<span class="op-label">{L('Connections', 'Kết nối')}</span>
|
|
28
|
+
<div class="op-grid">
|
|
29
|
+
{conns.map(([code, name, tone, isOn]) => (
|
|
30
|
+
<div class={isOn ? 'op-tile' : 'op-tile is-off'}>
|
|
31
|
+
<span class="op-tile-top"><span class={`op-logo is-${tone}`} data-sample={code} /><span class="op-switch"></span></span>
|
|
32
|
+
<b data-sample={name} /><span class="op-status" data-sample={isOn ? on : off} />
|
|
33
|
+
</div>
|
|
34
|
+
))}
|
|
35
|
+
</div>
|
|
36
|
+
<span class="op-label">{L('Team members', 'Thành viên')}</span>
|
|
37
|
+
<div class="op-list">
|
|
38
|
+
{users.map(([ini, name, role, isOn]) => (
|
|
39
|
+
<div class={isOn ? 'op-row' : 'op-row is-off'}><span class="op-avatar" data-sample={ini} /><span class="op-name" data-sample={name} /><span class="op-role" data-sample={role} /></div>
|
|
40
|
+
))}
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
)}
|
|
44
|
+
|
|
45
|
+
{kind === 'tile' && (
|
|
46
|
+
<div class="sh-ex-grid is-one sh-root">
|
|
47
|
+
<div class="sh-ex op-ex">
|
|
48
|
+
<div class="op-tile is-off op-tile-lg" role="img" aria-label={L('A turned-off connection: the logo is faded, the text uses the disabled colour', 'Một kết nối đã tắt: logo mờ đi, chữ dùng màu disabled')}>
|
|
49
|
+
<span class="op-tile-top"><Pin solid label={`${L('Opacity', 'Độ mờ')}: opacity.disabled`} at="top" len="200"><span class="op-logo is-c" data-sample="AC" /></Pin><span class="op-switch"></span></span>
|
|
50
|
+
<b data-sample={L('Accounting', 'Kế toán')} />
|
|
51
|
+
<Pin solid label={`${L('Text', 'Chữ')}: color.text.disabled`} at="bottom" len="300"><span class="op-status" data-sample={off} /></Pin>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
)}
|
|
56
|
+
|
|
57
|
+
{kind === 'scrim' && (
|
|
58
|
+
<div class="el-themes sh-root">
|
|
59
|
+
{['light', 'dark'].map((mode) => (
|
|
60
|
+
<figure class={`el-theme bh-scope-${mode}`}>
|
|
61
|
+
<figcaption>{mode === 'light' ? L('Light: graphite at 40%', 'Light: graphite 40%') : L('Dark: black at 60%', 'Dark: đen 60%')}</figcaption>
|
|
62
|
+
<div class="op-scrim-box" role="img" aria-label={L('A dialog over the scrim', 'Dialog nằm trên lớp phủ mờ')}>
|
|
63
|
+
<div class="op-lines"><span style="width: 80%"></span><span style="width: 60%"></span><span style="width: 70%"></span></div>
|
|
64
|
+
<div class="op-scrim"></div>
|
|
65
|
+
<div class="op-dialog">Dialog</div>
|
|
66
|
+
<span class="op-scrim-pin"><Pin solid label={`${L('Background', 'Nền')}: color.surface.scrim`} at="bottom" len="200"><i class="el-dot"></i></Pin></span>
|
|
67
|
+
</div>
|
|
68
|
+
</figure>
|
|
69
|
+
))}
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
|
|
73
|
+
{kind === 'dodont' && (
|
|
74
|
+
<div class="sp-dd sh-root">
|
|
75
|
+
{['do', 'dont'].map((side) => (
|
|
76
|
+
<figure class={`sp-dd-panel is-${side}`}>
|
|
77
|
+
<figcaption><span aria-hidden="true">{side === 'do' ? '✓' : '✕'}</span> {side === 'do' ? L('Do', 'Nên') : L('Don’t', 'Không nên')}</figcaption>
|
|
78
|
+
<div class="sp-dd-stage">
|
|
79
|
+
{item === 'container' && (
|
|
80
|
+
<div class={side === 'do' ? 'op-tile is-off' : 'op-tile is-wrong'} role="img" aria-label={side === 'do' ? L('Accounting connection, turned off: only the logo is faded', 'Kết nối Kế toán đã tắt: chỉ logo mờ đi') : L('Accounting connection, turned off: the whole tile is faded', 'Kết nối Kế toán đã tắt: cả ô bị làm mờ')}><span class="op-tile-top"><span class="op-logo is-c" data-sample="AC" /><span class="op-switch"></span></span><b data-sample={L('Accounting', 'Kế toán')} /><span class="op-status" data-sample={off} /></div>
|
|
81
|
+
)}
|
|
82
|
+
{item === 'controls' && (
|
|
83
|
+
<div class="op-band" role="img" aria-label={L('Sync paused for 2 stores, with a disabled Resume button', 'Đã tạm dừng đồng bộ 2 cửa hàng, nút Tiếp tục bị vô hiệu')}><span class="op-band-text">{L('Sync paused for 2 stores', 'Đã tạm dừng đồng bộ 2 cửa hàng')}</span><span class={side === 'do' ? 'sp-btn op-btn-off' : 'sp-btn is-primary op-btn-faded'} data-sample={L('Resume', 'Tiếp tục')} /></div>
|
|
84
|
+
)}
|
|
85
|
+
</div>
|
|
86
|
+
<p>
|
|
87
|
+
{item === 'container' && side === 'do' && L('Fade the logo only. The card keeps its border, and the text uses the disabled colour.', 'Chỉ làm mờ logo. Card giữ nguyên viền, chữ dùng màu disabled.')}
|
|
88
|
+
{item === 'container' && side === 'dont' && L('Don’t fade the whole card. Its border and text fade too, and the page shows through.', 'Không làm mờ cả card. Viền và chữ cũng mờ theo, và nền trang lộ ra phía sau.')}
|
|
89
|
+
{item === 'controls' && side === 'do' && L('Turn a control off with the disabled colours. It looks the same on any background.', 'Tắt một control bằng các màu disabled. Nó trông giống nhau trên mọi nền.')}
|
|
90
|
+
{item === 'controls' && side === 'dont' && L('Don’t fade a control with opacity. The background shows through, and the text loses contrast.', 'Không làm mờ control bằng opacity. Nền phía sau lộ ra và chữ mất độ tương phản.')}
|
|
91
|
+
</p>
|
|
92
|
+
</figure>
|
|
93
|
+
))}
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
@@ -15,10 +15,10 @@ const roles = [
|
|
|
15
15
|
{
|
|
16
16
|
title: 'Develop',
|
|
17
17
|
href: '/get-started/develop/',
|
|
18
|
-
summary: 'Ship the tokens
|
|
18
|
+
summary: 'Ship the tokens and lint rules.',
|
|
19
19
|
links: [
|
|
20
20
|
['Use the token CSS', '/foundations/tokens/all-tokens/'],
|
|
21
|
-
['
|
|
21
|
+
['Build for keyboard and focus', '/foundations/guidelines/accessibility/keyboard-and-focus/'],
|
|
22
22
|
['Add the lint rules', '/tools/stylelint/'],
|
|
23
23
|
['Docs for AI agents', '/tools/ai-agents/'],
|
|
24
24
|
],
|