@snowui-design-system/components 0.2.0-alpha.7 → 0.2.0-alpha.9
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 +27 -22
- package/component-catalog.json +1066 -0
- package/package.json +12 -4
- package/src/assets/gradient-avatar/blue.svg +1 -0
- package/src/assets/gradient-avatar/cyan.svg +1 -0
- package/src/assets/gradient-avatar/green.svg +1 -0
- package/src/assets/gradient-avatar/orange.svg +1 -0
- package/src/assets/gradient-avatar/purple.svg +1 -0
- package/src/assets/gradient-avatar/red.svg +1 -0
- package/src/components/Accordion.md +1 -1
- package/src/components/Accordion.svelte +5 -1
- package/src/components/Avatar.md +95 -58
- package/src/components/Avatar.svelte +286 -92
- package/src/components/Avatar.test.ts +24 -3
- package/src/components/Badge.md +31 -2
- package/src/components/Badge.svelte +38 -3
- package/src/components/Badge.test.ts +14 -1
- package/src/components/Button.md +42 -19
- package/src/components/Button.svelte +56 -50
- package/src/components/Button.test.ts +38 -27
- package/src/components/Card.test.ts +1 -1
- package/src/components/CodeBlock.md +50 -14
- package/src/components/CodeBlock.svelte +213 -34
- package/src/components/CodeBlock.test.ts +43 -2
- package/src/components/ColorSchemeButton.md +50 -0
- package/src/components/ColorSchemeButton.svelte +144 -0
- package/src/components/ColorSchemeButton.test.ts +39 -0
- package/src/components/CopyButton.md +5 -1
- package/src/components/CopyButton.svelte +6 -2
- package/src/components/Dialog.svelte +1 -0
- package/src/components/Dialog.test.ts +2 -2
- package/src/components/ExpandButton.md +5 -1
- package/src/components/ExpandButton.svelte +1 -0
- package/src/components/Form.test.ts +4 -4
- package/src/components/Gradient.md +278 -0
- package/src/components/Gradient.svelte +1283 -0
- package/src/components/Gradient.test.ts +77 -0
- package/src/components/Icon.svelte +3 -1
- package/src/components/Image.svelte +11 -8
- package/src/components/Image.test.ts +1 -1
- package/src/components/Indicator.md +18 -4
- package/src/components/Indicator.svelte +151 -11
- package/src/components/Indicator.test.ts +25 -0
- package/src/components/Input.md +15 -5
- package/src/components/Input.svelte +10 -1
- package/src/components/Input.test.ts +2 -2
- package/src/components/Listbox.md +5 -0
- package/src/components/Listbox.svelte +26 -0
- package/src/components/Listbox.test.ts +14 -0
- package/src/components/MenuItem.md +5 -0
- package/src/components/MenuItem.svelte +6 -0
- package/src/components/OverflowAction.md +41 -0
- package/src/components/OverflowAction.svelte +209 -0
- package/src/components/OverflowAction.test.ts +11 -0
- package/src/components/OverflowActions.md +95 -0
- package/src/components/OverflowActions.svelte +501 -0
- package/src/components/OverflowActions.test.ts +87 -0
- package/src/components/Pagination.md +2 -2
- package/src/components/Pagination.svelte +2 -2
- package/src/components/Pagination.test.ts +2 -2
- package/src/components/Popover.md +5 -0
- package/src/components/Popover.svelte +25 -0
- package/src/components/Popover.test.ts +14 -0
- package/src/components/ScrollArea.md +7 -3
- package/src/components/ScrollArea.test.ts +3 -2
- package/src/components/SearchInput.md +14 -1
- package/src/components/SearchInput.svelte +104 -2
- package/src/components/SearchInput.test.ts +16 -1
- package/src/components/SelectButton.md +1 -1
- package/src/components/SelectButton.svelte +8 -2
- package/src/components/Skeleton.md +13 -1
- package/src/components/Skeleton.svelte +30 -2
- package/src/components/Slider.md +68 -6
- package/src/components/Slider.svelte +329 -21
- package/src/components/Slider.test.ts +65 -0
- package/src/components/SnowUILogo.md +210 -0
- package/src/components/SnowUILogo.svelte +478 -0
- package/src/components/SnowUILogo.test.ts +62 -0
- package/src/components/StyleButton.md +58 -0
- package/src/components/StyleButton.svelte +144 -0
- package/src/components/StyleButton.test.ts +39 -0
- package/src/components/Table.md +23 -7
- package/src/components/Table.svelte +22 -1
- package/src/components/TableBody.md +12 -1
- package/src/components/TableBody.svelte +26 -2
- package/src/components/TableBody.test.ts +3 -0
- package/src/components/TableCell.md +9 -3
- package/src/components/TableCell.svelte +139 -78
- package/src/components/TableCell.test.ts +4 -4
- package/src/components/TableHead.md +9 -3
- package/src/components/TableHead.svelte +56 -43
- package/src/components/TableHead.test.ts +5 -5
- package/src/components/TableRow.md +15 -5
- package/src/components/TableRow.svelte +47 -10
- package/src/components/TableRow.test.ts +2 -2
- package/src/components/TableToolbar.svelte +20 -8
- package/src/components/Text.md +7 -1
- package/src/components/Text.svelte +17 -7
- package/src/components/Tooltip.md +37 -9
- package/src/components/Tooltip.svelte +145 -35
- package/src/components/Tooltip.test.ts +54 -4
- package/src/i18n/messages.ts +12 -0
- package/src/index.ts +24 -0
- package/src/internal/StyleButtonLogo.svelte +49 -0
- package/src/lib/color.md +2 -2
- package/src/lib/edge-fade.md +1 -0
- package/src/lib/overlay-scrollbar.md +6 -1
- package/src/lib/table-context.svelte.ts +36 -0
- package/src/lib/table-role-blur.ts +46 -0
- package/src/lib/table-truncation.md +14 -0
- package/src/lib/table-truncation.ts +83 -0
- package/src/lib/tooltip-delay.md +7 -1
- package/src/lib/tooltip-motion-dismiss.md +33 -0
- package/src/lib/tooltip-motion-dismiss.ts +160 -0
- package/src/lib/tooltip-overlay.md +21 -3
- package/src/lib/tooltip-overlay.ts +13 -2
- package/src/logic/README.md +4 -1
- package/src/logic/continuous-hover.svelte.md +22 -0
- package/src/logic/continuous-hover.svelte.ts +436 -0
- package/src/logic/frame-inline-style.svelte.ts +2 -2
- package/src/logic/frame-truncation.md +9 -3
- package/src/logic/frame-truncation.svelte.ts +6 -0
- package/src/logic/layout-flip.ts +182 -5
- package/src/logic/overflow-actions.svelte.ts +33 -0
- package/src/motion/presets/README.md +6 -2
- package/src/motion/presets/continuous-hover.md +11 -0
- package/src/motion/presets/continuous-hover.ts +18 -0
- package/src/motion/presets/tooltip.md +40 -2
- package/src/motion/presets/tooltip.ts +0 -2
- package/src/motion/tokens.md +9 -4
- package/src/motion/tokens.ts +4 -1
- package/src/styles/README.md +16 -2
- package/src/styles/auto-layout.css +10 -1
- package/src/styles/components.css +920 -0
- package/src/styles/index.css +3 -1
- package/src/styles/layout.css +44 -0
- package/src/styles/scrollbar.css +27 -7
- package/src/styles/themes.css +146 -0
- package/src/styles/tokens.css +33 -33
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Button.test.ts
|
|
3
|
-
* v1.
|
|
3
|
+
* v1.6.0
|
|
4
|
+
* 变更记录 (2026-08-11): icon-only 改为显式 iconOnly=true;未声明等同于 false。
|
|
5
|
+
* 变更记录 (2026-08-09): bare 默认 100% 不透明,新增 emphasis="muted" 示例覆盖 40% → hover 100%。
|
|
4
6
|
* 变更记录 (2026-07-05): 新增 backgroundBlur 开启状态示例。
|
|
5
7
|
* 变更记录 (2026-05-18): 新增 B6 复制按钮示例,覆盖 P0.2 瞬时反馈模式:副作用挂 onclick,状态切换与内容回弹由 Frame 接管。
|
|
6
8
|
* 变更记录 (2026-03-15): 修复 B3 图标按钮示例运行时错误,示例下拉图标改为 test 沙箱已注入的 `ArrowLineDown`。
|
|
@@ -25,7 +27,7 @@ export const examples = [
|
|
|
25
27
|
<Button variant="outline">Outline</Button>
|
|
26
28
|
<Button variant="borderless">Borderless</Button>
|
|
27
29
|
<Button bare>Bare</Button>
|
|
28
|
-
<Button bare aria-label="减少"><Minus /></Button>`,
|
|
30
|
+
<Button bare iconOnly aria-label="减少"><Minus /></Button>`,
|
|
29
31
|
|
|
30
32
|
logic: ["Style"],
|
|
31
33
|
},
|
|
@@ -64,14 +66,15 @@ export const examples = [
|
|
|
64
66
|
code: `A4
|
|
65
67
|
<div class="flex-row gap-12 items-center">
|
|
66
68
|
<Button bare>All</Button>
|
|
67
|
-
<Button bare><FourLeafClover size={24} /></Button>
|
|
69
|
+
<Button bare iconOnly aria-label="四叶草"><FourLeafClover size={24} /></Button>
|
|
70
|
+
<Button bare emphasis="muted">Muted</Button>
|
|
68
71
|
<Button bare disabled>Disabled</Button>
|
|
69
72
|
</div>`,
|
|
70
73
|
|
|
71
74
|
expected: {
|
|
72
|
-
render: "无外壳按钮可包含文字或 Icon,无 padding
|
|
75
|
+
render: "无外壳按钮可包含文字或 Icon,无 padding、圆角、背景和边框;默认保持 100% 不透明,muted 为 40%。",
|
|
73
76
|
layout: "按钮尺寸由内部内容自然撑开。",
|
|
74
|
-
interaction: "
|
|
77
|
+
interaction: "默认按钮 hover 时透明度不变;muted hover 时由 40% 提升到 100%,禁用按钮不响应 hover。",
|
|
75
78
|
performance: "仅通过 Button class 与 CSS 变量切换视觉。",
|
|
76
79
|
responsive: "字号与行高继续跟随 Button size。",
|
|
77
80
|
},
|
|
@@ -120,16 +123,24 @@ export const examples = [
|
|
|
120
123
|
{
|
|
121
124
|
name: "B2: 纯图标按钮 (Icon Only)",
|
|
122
125
|
code: `B2
|
|
123
|
-
<Button
|
|
126
|
+
<Button aria-label="未声明 iconOnly">
|
|
124
127
|
<FourLeafClover />
|
|
125
128
|
</Button>
|
|
126
|
-
<Button size="
|
|
129
|
+
<Button iconOnly size="sm" aria-label="四叶草">
|
|
127
130
|
<FourLeafClover />
|
|
128
131
|
</Button>
|
|
129
|
-
<Button size="
|
|
132
|
+
<Button iconOnly size="md" aria-label="四叶草">
|
|
133
|
+
<FourLeafClover />
|
|
134
|
+
</Button>
|
|
135
|
+
<Button iconOnly size="lg" aria-label="四叶草">
|
|
130
136
|
<FourLeafClover />
|
|
131
137
|
</Button>`,
|
|
132
138
|
|
|
139
|
+
expected: {
|
|
140
|
+
render: "未声明 iconOnly 的 Button 使用普通内容布局;后三个显式 iconOnly Button 使用对应尺寸的对称 padding。",
|
|
141
|
+
layout: "iconOnly=false 不根据单个 SVG 自动改变布局;iconOnly=true 的 sm/md/lg 使用 4/8/12px 四边 padding。",
|
|
142
|
+
interaction: "所有按钮保持普通 Button 交互;纯图标按钮通过 aria-label 提供可访问名称。",
|
|
143
|
+
},
|
|
133
144
|
logic: ["Composition"],
|
|
134
145
|
},
|
|
135
146
|
{
|
|
@@ -137,25 +148,25 @@ export const examples = [
|
|
|
137
148
|
code: `B3
|
|
138
149
|
<div class="flex-col gap-12">
|
|
139
150
|
<div class="flex-row gap-8 items-center">
|
|
140
|
-
<Button bare aria-label="减少">
|
|
151
|
+
<Button bare iconOnly aria-label="减少">
|
|
141
152
|
<Minus size={12} />
|
|
142
153
|
</Button>
|
|
143
|
-
<Button bare aria-label="筛选">
|
|
154
|
+
<Button bare iconOnly aria-label="筛选">
|
|
144
155
|
<FourLeafClover size={16} />
|
|
145
156
|
</Button>
|
|
146
|
-
<Button bare size="lg" variant="filled" aria-label="展开">
|
|
157
|
+
<Button bare iconOnly size="lg" variant="filled" aria-label="展开">
|
|
147
158
|
<ArrowLineDown />
|
|
148
159
|
</Button>
|
|
149
|
-
<Button bare aria-label="增加">
|
|
160
|
+
<Button bare iconOnly aria-label="增加">
|
|
150
161
|
<Plus size={24} />
|
|
151
162
|
</Button>
|
|
152
163
|
</div>
|
|
153
164
|
<div class="flex-row gap-8 items-center p-8 rounded-12 bg-surface-1">
|
|
154
165
|
<Input placeholder="搜索内容" />
|
|
155
|
-
<Button bare size="md" variant="outline" aria-label="展开筛选">
|
|
166
|
+
<Button bare iconOnly size="md" variant="outline" aria-label="展开筛选">
|
|
156
167
|
<ArrowLineDown />
|
|
157
168
|
</Button>
|
|
158
|
-
<Button bare aria-label="清空输入">
|
|
169
|
+
<Button bare iconOnly aria-label="清空输入">
|
|
159
170
|
<Minus size={16} />
|
|
160
171
|
</Button>
|
|
161
172
|
</div>
|
|
@@ -169,7 +180,7 @@ export const examples = [
|
|
|
169
180
|
</Button>
|
|
170
181
|
</div>
|
|
171
182
|
<div class="text-12 text-black-40">
|
|
172
|
-
说明:bare 忽略 filled/outline 等 variant
|
|
183
|
+
说明:bare 忽略 filled/outline 等 variant 的视觉结果。显式 iconOnly 的单视觉内容继承当前 size 档位的 12/16/20px 尺寸上下文,并获得至少 16×16px 的透明点击热区;未声明 iconOnly 等同于 false。精确尺寸直接声明在子 Icon 上,Icon + 文字继续保留普通 Button 的内容 gap。
|
|
173
184
|
</div>
|
|
174
185
|
</div>`,
|
|
175
186
|
|
|
@@ -361,7 +372,7 @@ export const examples = [
|
|
|
361
372
|
>
|
|
362
373
|
{#snippet children({ currentState })}
|
|
363
374
|
<div class="flex-row gap-16 items-center bg-background-1 p-16 rounded-12 border-black-10 w-hug">
|
|
364
|
-
<Button variant="gray" size="lg">
|
|
375
|
+
<Button iconOnly variant="gray" size="lg" aria-label="减少">
|
|
365
376
|
<Minus />
|
|
366
377
|
</Button>
|
|
367
378
|
<div class="text-24 font-semibold min-w-48" style="text-align: center;">
|
|
@@ -370,7 +381,7 @@ export const examples = [
|
|
|
370
381
|
duration={500}
|
|
371
382
|
/>
|
|
372
383
|
</div>
|
|
373
|
-
<Button variant="gray" size="lg">
|
|
384
|
+
<Button iconOnly variant="gray" size="lg" aria-label="增加">
|
|
374
385
|
<Plus />
|
|
375
386
|
</Button>
|
|
376
387
|
</div>
|
|
@@ -606,17 +617,17 @@ export const examples = [
|
|
|
606
617
|
<FourLeafClover />
|
|
607
618
|
</Icon>Gray</Button
|
|
608
619
|
>
|
|
609
|
-
<Button variant="filled" size="lg"
|
|
620
|
+
<Button iconOnly aria-label="四叶草" variant="filled" size="lg"
|
|
610
621
|
><Icon>
|
|
611
622
|
<FourLeafClover />
|
|
612
623
|
</Icon>Filled</Button
|
|
613
624
|
>
|
|
614
|
-
<Button variant="outline" size="lg"
|
|
625
|
+
<Button iconOnly aria-label="四叶草" variant="outline" size="lg"
|
|
615
626
|
><Icon>
|
|
616
627
|
<FourLeafClover />
|
|
617
628
|
</Icon>Outline</Button
|
|
618
629
|
>
|
|
619
|
-
<Button variant="borderless" size="lg"
|
|
630
|
+
<Button iconOnly aria-label="四叶草" variant="borderless" size="lg"
|
|
620
631
|
><Icon>
|
|
621
632
|
<FourLeafClover />
|
|
622
633
|
</Icon>Borderless</Button
|
|
@@ -708,13 +719,13 @@ export const examples = [
|
|
|
708
719
|
},
|
|
709
720
|
{
|
|
710
721
|
name: "Custom 23-00-59",
|
|
711
|
-
code: `<Button bare><FourLeafClover size={16} /></Button>
|
|
712
|
-
<Button bare><FourLeafClover size={20} /></Button>
|
|
713
|
-
<Button bare><FourLeafClover size={24} /></Button>
|
|
714
|
-
<Button bare><FourLeafClover size={32} /></Button>
|
|
715
|
-
<Button bare><FourLeafClover size={40} /></Button>
|
|
716
|
-
<Button bare><FourLeafClover size={48} /></Button>
|
|
717
|
-
<Button bare><FourLeafClover size={80} /></Button>
|
|
722
|
+
code: `<Button bare iconOnly aria-label="四叶草"><FourLeafClover size={16} /></Button>
|
|
723
|
+
<Button bare iconOnly aria-label="四叶草"><FourLeafClover size={20} /></Button>
|
|
724
|
+
<Button bare iconOnly aria-label="四叶草"><FourLeafClover size={24} /></Button>
|
|
725
|
+
<Button bare iconOnly aria-label="四叶草"><FourLeafClover size={32} /></Button>
|
|
726
|
+
<Button bare iconOnly aria-label="四叶草"><FourLeafClover size={40} /></Button>
|
|
727
|
+
<Button bare iconOnly aria-label="四叶草"><FourLeafClover size={48} /></Button>
|
|
728
|
+
<Button bare iconOnly aria-label="四叶草"><FourLeafClover size={80} /></Button>
|
|
718
729
|
<Button bare>文字</Button>`,
|
|
719
730
|
logic: ["UserCreated"],
|
|
720
731
|
},] as const;
|
|
@@ -108,7 +108,7 @@ export const examples = [
|
|
|
108
108
|
<Frame row>
|
|
109
109
|
<Icon as="leading" size={16}><Paperclip /></Icon>
|
|
110
110
|
<Text>Attachment.pdf</Text>
|
|
111
|
-
<Button as="trailing" bare variant="borderless">
|
|
111
|
+
<Button as="trailing" bare iconOnly emphasis="muted" variant="borderless" aria-label="下载">
|
|
112
112
|
<Icon size={16}><ArrowLineDown /></Icon>
|
|
113
113
|
</Button>
|
|
114
114
|
</Frame>
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
- `parts.Indicator`:配置内置 resize Indicator。
|
|
6
6
|
- 需要替换手柄结构时使用文档既有 Indicator `as` 职责;外置显式 Props 高于 part。
|
|
7
7
|
|
|
8
|
-
> **版本**: v1.
|
|
9
|
-
> **更新**: 2026-
|
|
10
|
-
> **布局模型**:
|
|
8
|
+
> **版本**: v1.6.1
|
|
9
|
+
> **更新**: 2026-08-12
|
|
10
|
+
> **布局模型**: 默认态为复合管理布局;`singleLine` 为槽位宿主布局
|
|
11
11
|
> **文档**: ./CodeBlock.md
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
代码块组件,支持语法显示、基础语法着色、行号、复制到剪贴板与全屏放大。全屏放大/缩小使用共享元素转场的 `layout` 策略:实际过渡位置与尺寸,不缩放代码字形;图标切换动效使用 `REPLACEMENT_APPEAR_MOTION`,避免继承浮层类动效语义。
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
> **以下内容供 AI 阅读,用户可忽略。**
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
|:---|:---|
|
|
24
24
|
| **内容** | `code`, `language`, `children` |
|
|
25
25
|
| **功能开关** | `showLanguage`, `showLineNumbers`, `showCopyButton`, `showExpandButton` |
|
|
26
|
-
| **布局** | `visibleLines`,
|
|
26
|
+
| **布局** | `variant="default|singleLine"`, `visibleLines`, 默认态拖拽高度 |
|
|
27
27
|
| **行为** | `copyTimeout`;复制能力由默认内置 CopyButton 承担 |
|
|
28
28
|
| **默认内置组件** | `parts.CopyButton` 配置内置 bare CopyButton;`parts.ExpandButton` 配置内置 bare ExpandButton;`parts.Indicator` 配置缩放手柄 |
|
|
29
|
-
|
|
|
29
|
+
| **外置配件槽位** | `singleLine` 支持 `as="leading"`;全部变体支持 `as="trailing"`;兼容 `data-as="copy-icon"`, `data-as="copied-icon"`, `data-as="expand-icon"`, `data-as="collapse-icon"`,前两者映射到 CopyButton icon/successIcon |
|
|
30
30
|
| **Frame 透传** | `class`, `style`, `...rest` |
|
|
31
31
|
|
|
32
32
|
---
|
|
@@ -35,10 +35,11 @@
|
|
|
35
35
|
|
|
36
36
|
| 关键字 | 类型 | 默认值 | 描述 |
|
|
37
37
|
|:---|:---|:---|:---|
|
|
38
|
+
| `variant` | `"default" \| "singleLine"` | `"default"` | `singleLine` 使用 Input 同类 Leading / Content / Trailing 三槽布局;固定为单行展示,不生成高度拖拽、语言、行号、全屏或纵向滚动结构 |
|
|
38
39
|
| `code` | `string` | `""` | 要显示的代码字符串 |
|
|
39
40
|
| `language` | `string` | — | 语言标识,显示在工具栏(如 `"tsx"`, `"css"`) |
|
|
40
41
|
| `showLanguage` | `boolean` | `true` | 是否显示语言标识 |
|
|
41
|
-
| `showLineNumbers` | `boolean` | `false` |
|
|
42
|
+
| `showLineNumbers` | `boolean` | `false` | 是否显示代码行号;普通态与全屏态保持一致,避免切换末帧发生代码横向跳变 |
|
|
42
43
|
| `showCopyButton` | `boolean` | `true` | 是否显示复制按钮 |
|
|
43
44
|
| `showExpandButton` | `boolean` | `true` | 是否显示全屏放大按钮 |
|
|
44
45
|
| `visibleLines` | `number` | `15` | 默认状态最多显示几行代码;内容不足时自适应高度,超出后滚动;全屏模式不受此限制 |
|
|
@@ -48,6 +49,37 @@
|
|
|
48
49
|
|
|
49
50
|
---
|
|
50
51
|
|
|
52
|
+
## `singleLine` 单行变体
|
|
53
|
+
|
|
54
|
+
`variant="singleLine"` 面向 import、install command、短配置值等独占一行的只读代码条。它仍使用 `<pre><code>`、内置轻量语法着色和 CopyButton,不改用 Input,也不引入表单语义。
|
|
55
|
+
|
|
56
|
+
布局参考 Input 的三槽协议:
|
|
57
|
+
|
|
58
|
+
| 槽位 | 尺寸 | 内容 |
|
|
59
|
+
|:---|:---|:---|
|
|
60
|
+
| Leading | Hug | 可选外置 `as="leading"` 配件 |
|
|
61
|
+
| Content | Fill / `min-width: 0` | 单行高亮代码;超宽时仅横向滚动 |
|
|
62
|
+
| Trailing | Hug | 外置 `as="trailing"`,否则为默认内置 CopyButton |
|
|
63
|
+
|
|
64
|
+
单行态固定隐藏语言、行号和全屏按钮;`visibleLines`、`showLanguage`、`showLineNumbers`、`showExpandButton` 在该变体中不产生对应结构。根层不生成 Indicator,不接受拖拽高度,也不创建纵向 scrollbar / fade。默认 padding 与 Input 标准态一致:上下 `--padding-3`(12px)、左右 `--padding-4`(16px);gap 为 `--gap-2`(8px),圆角为 `--radius-4`(16px)。
|
|
65
|
+
|
|
66
|
+
```svelte
|
|
67
|
+
<CodeBlock
|
|
68
|
+
variant="singleLine"
|
|
69
|
+
code="import { Button } from '@snowui-design-system/components';"
|
|
70
|
+
/>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
需要 Leading 配件时:
|
|
74
|
+
|
|
75
|
+
```svelte
|
|
76
|
+
<CodeBlock variant="singleLine" code="pnpm add @snowui-design-system/components">
|
|
77
|
+
<Icon as="leading"><Package /></Icon>
|
|
78
|
+
</CodeBlock>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
51
83
|
## 语法着色
|
|
52
84
|
|
|
53
85
|
当使用 `code` prop 时,组件内置轻量语法着色规则,覆盖 JS / TS / JSON / HTML / CSS 常见 token。规则来自参考仓库中 `shiki` / `rehype-pretty-code` 的高亮分层思路,但当前实现不新增依赖。
|
|
@@ -61,7 +93,7 @@
|
|
|
61
93
|
| 行号 | `--black-20` |
|
|
62
94
|
| 注释 / 灰色代码 | `--black-40` |
|
|
63
95
|
| 语言标识 | `--black-40` |
|
|
64
|
-
| 按钮区 |
|
|
96
|
+
| 按钮区 | 内置操作显式使用 `Button bare emphasis="muted"`:`--black-100` × `opacity: 0.4`(视觉等同 `--black-40`) |
|
|
65
97
|
| 关键字 / 数字 / literal | `#ff32c6` |
|
|
66
98
|
| 函数 / 调用对象 | `#ffac60` |
|
|
67
99
|
| 属性 / 方法 | `#1ac69c` |
|
|
@@ -70,7 +102,7 @@
|
|
|
70
102
|
|
|
71
103
|
代码块根容器默认设置 `font-size: var(--text-12)` 与 `line-height: var(--leading-12)`;内部行号、`pre`、`code`、代码行全部继承根容器排版。`font-family` 默认继承外部上下文,不设置具体字体族,忽略设计稿中的字体设置。
|
|
72
104
|
|
|
73
|
-
按钮 hover 对齐 Button `bare` 模式:关闭背景叠加,默认 `opacity: 0.4`,hover 提升到 `1`,并使用 Frame color motion 变量过渡。
|
|
105
|
+
按钮 hover 对齐 Button 的 `bare emphasis="muted"` 模式:关闭背景叠加,默认 `opacity: 0.4`,hover 提升到 `1`,并使用 Frame color motion 变量过渡。
|
|
74
106
|
|
|
75
107
|
工具栏使用内部 Pin 布局固定到 `pin-top-right`,偏移为 `var(--padding-2)`;右下角尺寸手柄复用 `Indicator axis="height" appearance="corner"`,宿主 hover 时以 1px / Black/20% 显示,自身 hover、focus 或 dragging 时变为 2px / Black/40%。
|
|
76
108
|
|
|
@@ -118,8 +150,8 @@
|
|
|
118
150
|
| 复制超时 | Check 消失 → Copy 出现(同上) |
|
|
119
151
|
| 点击放大 | ArrowsOutSimple 消失 → ArrowsInSimple 出现(同上) |
|
|
120
152
|
| 点击缩小 / Esc | ArrowsInSimple 消失 → ArrowsOutSimple 出现(同上) |
|
|
121
|
-
| 全屏进入 |
|
|
122
|
-
| 全屏退出 |
|
|
153
|
+
| 全屏进入 | 先捕获普通态位置;全屏覆盖层使用共享元素 `layout` 策略实际过渡 `top / left / width / height`,代码字号和行高保持不变 |
|
|
154
|
+
| 全屏退出 | 全屏覆盖层以同一 `layout` 策略缩回普通态位置后卸载;普通态代码结构始终保持最终布局,不在末帧增删行号 |
|
|
123
155
|
|
|
124
156
|
图标替换进入动效引用 `REPLACEMENT_APPEAR_MOTION`。具体 duration / easing / scale 以 motion preset catalog 为准,Frame appear 桥接变量名仅作为兼容入口保留。
|
|
125
157
|
|
|
@@ -149,13 +181,13 @@ CodeBlock 只声明轨道定位,滚动条尺寸、显隐、hover 形态与鼠
|
|
|
149
181
|
|
|
150
182
|
| Frame 能力 | 接入层 | 说明 |
|
|
151
183
|
|:---|:---|:---|
|
|
152
|
-
| 普通 Frame | 根 Frame | 容器不触发默认 hover
|
|
184
|
+
| 普通 Frame | 根 Frame | 容器不触发默认 hover 动效;`singleLine` 固定启用 row + Auto Layout 三槽协议 |
|
|
153
185
|
| `enableResponsive` | 根 Frame | 默认 `false`(代码块本身不需要容器断点响应) |
|
|
154
186
|
| `enableContext` | 根 Frame | 默认 `false` |
|
|
155
187
|
| `enableScaleObserver` | 根 Frame | 默认 `false` |
|
|
156
188
|
| `enableDefaultMotion` | 根 Frame | 默认 `true` |
|
|
157
189
|
| `stateContent` | 复制按钮内部 Frame | 驱动 Copy ↔ Check 图标交叉淡化 |
|
|
158
|
-
|
|
|
190
|
+
| 共享元素布局转场 | 根 Frame / 全屏覆盖层 Frame | 捕获普通态矩形,并使用 `strategy: "layout"` 实际过渡位置和尺寸;避免 `scale()` 缩放代码 |
|
|
159
191
|
| `Appear` | 全屏覆盖层 Frame | 提供布局转场时序桥接变量 |
|
|
160
192
|
| Icon 按钮 | `<button>` 直接渲染 | 不使用 Button 组件(内置 Icon 规范 §2.7) |
|
|
161
193
|
|
|
@@ -222,7 +254,7 @@ pnpm build`}
|
|
|
222
254
|
|
|
223
255
|
## 布局模型
|
|
224
256
|
|
|
225
|
-
|
|
257
|
+
默认态主布局模型:**复合管理布局**(参见 [LayoutProtocol.md §12.6](../../../specs/LayoutProtocol.md))。`singleLine` 改用**槽位宿主布局**,根层直接管理 Leading / Content / Trailing,且不生成下列默认态的滚动、全屏与 resize 子树。
|
|
226
258
|
|
|
227
259
|
组件内部包含:
|
|
228
260
|
- 工具栏区域(固定在顶部,不随代码滚动)
|
|
@@ -235,6 +267,10 @@ pnpm build`}
|
|
|
235
267
|
|
|
236
268
|
| 日期 | 版本 | 说明 |
|
|
237
269
|
|:---|:---|:---|
|
|
270
|
+
| 2026-08-12 | v1.6.1 | `singleLine` 的 padding、gap 与圆角对齐 Input 标准态:上下 12px、左右 16px、gap 8px、圆角 16px |
|
|
271
|
+
| 2026-08-12 | v1.6.0 | 新增 `variant="singleLine"`;参考 Input 实现 Leading / Content / Trailing 三槽布局,保留高亮与复制,移除语言、行号、全屏、纵向滚动及高度拖拽结构 |
|
|
272
|
+
| 2026-08-09 | v1.5.1 | Button bare 默认改为 100% 后,内置复制 / 放大操作显式使用 `emphasis="muted"` 保留原 40% → hover 100% 的次级操作视觉 |
|
|
273
|
+
| 2026-07-30 | v1.5.0 | 全屏展开/收起改用共享元素 `layout` 策略,实际过渡位置与尺寸,代码字形不参与缩放;普通态与全屏态统一遵循 `showLineNumbers`,消除退出末帧横向突变 |
|
|
238
274
|
| 2026-07-08 | v1.4.7 | 顶部操作按钮容器的 `pin-top-right` 偏移从 `--padding-2`(8px)调整为 `--padding-3`(12px),普通态与全屏态保持一致 |
|
|
239
275
|
| 2026-07-08 | v1.4.6 | 顶部复制 / 放大操作按钮统一使用 Button bare 默认 16×16 尺寸;移除 CodeBlock 私有按钮外壳尺寸,按钮组间距改为 `--gap-2`(8px)并接入 `--snowui-code-block-gap-override` |
|
|
240
276
|
| 2026-06-21 | v1.4.4 | 右下角私有 resize icon 与 pointer 算法迁移到统一 Indicator corner;复用宿主 hover、1px→2px、颜色、键盘和 ARIA 协议 |
|