@xihan-ui/styles 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5146 -6
- package/README.md +22 -2
- package/component-tokens.d.ts +4212 -0
- package/component-tokens.js +2 -0
- package/components.tokens.json +80116 -0
- package/css/accordion.css +131 -75
- package/css/affix.css +16 -1
- package/css/alert.css +114 -67
- package/css/anchor.css +99 -27
- package/css/approval.css +461 -0
- package/css/avatar-group.css +14 -6
- package/css/avatar.css +33 -9
- package/css/back-top.css +103 -48
- package/css/badge.css +42 -14
- package/css/bar-code.css +62 -0
- package/css/breadcrumb.css +40 -21
- package/css/button-group.css +146 -24
- package/css/button.css +116 -99
- package/css/calendar-picker.css +448 -0
- package/css/calendar-range-picker.css +517 -0
- package/css/card.css +54 -77
- package/css/carousel.css +412 -68
- package/css/cascader.css +429 -246
- package/css/checkbox-group.css +225 -77
- package/css/checkbox.css +174 -37
- package/css/clipboard.css +266 -47
- package/css/code-view.css +279 -0
- package/css/collapsible.css +108 -63
- package/css/color-field.css +158 -0
- package/css/color-picker.css +172 -184
- package/css/color-slider.css +274 -0
- package/css/color-swatch-picker.css +243 -0
- package/css/color-swatch.css +35 -0
- package/css/combobox.css +267 -273
- package/css/command.css +399 -0
- package/css/context-menu.css +183 -108
- package/css/date-field.css +94 -121
- package/css/date-picker.css +486 -249
- package/css/date-range-picker.css +559 -0
- package/css/description.css +51 -0
- package/css/descriptions.css +133 -87
- package/css/dialog.css +247 -68
- package/css/diff-view.css +428 -0
- package/css/download-trigger.css +155 -46
- package/css/drawer.css +194 -111
- package/css/editable.css +172 -152
- package/css/empty-state.css +80 -11
- package/css/field-array.css +190 -0
- package/css/field.css +84 -31
- package/css/fieldset.css +51 -18
- package/css/file-upload.css +134 -36
- package/css/flex.css +20 -1
- package/css/float-button.css +238 -57
- package/css/floating-panel.css +173 -92
- package/css/focus.css +46 -0
- package/css/forced-colors.css +93 -0
- package/css/form.css +254 -77
- package/css/gradient-text.css +34 -10
- package/css/grid.css +516 -5
- package/css/heatmap.css +87 -29
- package/css/highlight.css +20 -5
- package/css/hover-card.css +97 -47
- package/css/icon-wrapper.css +15 -3
- package/css/icon.css +74 -8
- package/css/image-cropper.css +143 -29
- package/css/image-viewer.css +150 -89
- package/css/image.css +30 -1
- package/css/infinite-scroll.css +51 -1
- package/css/input-group.css +277 -0
- package/css/json-viewer.css +102 -45
- package/css/kbd.css +72 -0
- package/css/label.css +78 -0
- package/css/layers.css +5 -0
- package/css/layout.css +175 -31
- package/css/list.css +24 -3
- package/css/listbox.css +208 -67
- package/css/loading-bar.css +52 -3
- package/css/log.css +144 -9
- package/css/markdown-stream.css +149 -0
- package/css/marquee.css +27 -1
- package/css/masonry.css +7 -0
- package/css/matrix-code.css +67 -0
- package/css/mention.css +234 -152
- package/css/menu.css +180 -83
- package/css/menubar.css +204 -136
- package/css/message-feed.css +197 -0
- package/css/navigation-menu.css +144 -90
- package/css/notification.css +178 -100
- package/css/number-animation.css +7 -0
- package/css/number-field.css +120 -277
- package/css/overlay-arrow.css +12 -7
- package/css/page-header.css +99 -14
- package/css/pagination.css +175 -135
- package/css/password-input.css +222 -219
- package/css/pin-input.css +101 -67
- package/css/pointer.css +36 -0
- package/css/popconfirm.css +185 -94
- package/css/popover.css +121 -77
- package/css/progress.css +60 -12
- package/css/prompt-input.css +224 -0
- package/css/question-flow.css +513 -0
- package/css/radio-group.css +147 -30
- package/css/rating.css +193 -43
- package/css/reasoning.css +336 -0
- package/css/reset.css +84 -6
- package/css/resizable.css +237 -0
- package/css/scroll-area.css +68 -7
- package/css/scrollbar.css +47 -13
- package/css/segmented.css +94 -29
- package/css/select.css +288 -274
- package/css/separator.css +101 -1
- package/css/side-nav.css +133 -75
- package/css/signature-pad.css +74 -54
- package/css/skeleton.css +84 -11
- package/css/slider.css +132 -39
- package/css/sortable.css +198 -0
- package/css/spinner.css +126 -12
- package/css/splitter.css +29 -8
- package/css/statistic.css +55 -0
- package/css/steps.css +206 -72
- package/css/switch.css +268 -36
- package/css/table.css +695 -118
- package/css/tabs.css +604 -42
- package/css/tag-group.css +219 -0
- package/css/tag.css +118 -28
- package/css/tags-input.css +156 -274
- package/css/text-field.css +101 -249
- package/css/time-field.css +100 -128
- package/css/time-picker.css +323 -252
- package/css/time-range-picker.css +719 -0
- package/css/timeline.css +202 -68
- package/css/timer.css +56 -52
- package/css/timestamp.css +34 -0
- package/css/toast.css +373 -144
- package/css/toggle-group.css +309 -76
- package/css/toggle.css +116 -85
- package/css/tone.css +47 -0
- package/css/tool-call.css +421 -0
- package/css/toolbar.css +181 -33
- package/css/tooltip.css +107 -36
- package/css/tour.css +183 -152
- package/css/transfer.css +351 -138
- package/css/tree-select.css +323 -216
- package/css/tree.css +294 -62
- package/css/truncate.css +65 -0
- package/css/typography.css +228 -5
- package/css/undefined.css +10 -1
- package/css/virtualizer.css +9 -10
- package/css/visually-hidden.css +7 -0
- package/css/watermark.css +7 -0
- package/family/action-control.css +487 -0
- package/family/collection-item.css +721 -0
- package/family/field-chrome.css +298 -0
- package/family/motion.css +166 -0
- package/family/swatch.css +59 -0
- package/index.css +41705 -126
- package/index.unlayered.css +33692 -17339
- package/package.json +51 -17
- package/css/calendar.css +0 -367
- package/css/code-block.css +0 -91
- package/css/composer.css +0 -134
- package/css/countdown.css +0 -26
- package/css/dynamic-input.css +0 -220
- package/css/ellipsis.css +0 -52
- package/css/hotkeys.css +0 -90
- package/css/popselect.css +0 -391
- package/css/qr-code.css +0 -55
- package/css/result.css +0 -119
- package/css/space.css +0 -117
- package/css/thread.css +0 -120
- package/css/time.css +0 -25
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-Present XiHanFun and contributors.
|
|
3
|
+
* Licensed under the MIT License. See LICENSE in the project root for license information.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* 定义 color slider 样式。 */
|
|
7
|
+
|
|
8
|
+
@layer xihan.components {
|
|
9
|
+
/* 皮肤在场的标记:开发模式下按 scope 探一次,取不到就说明这份皮肤没被引入。 */
|
|
10
|
+
[data-scope='color-slider'] {
|
|
11
|
+
--xh-color-slider-skin: 1;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* 定位分工:拇指在**主轴**上的位置由连接层每帧写进内联样式——
|
|
15
|
+
水平是 inset-inline-start,竖直是 inset-block-end;轨道的渐变同样是连接层按当前颜色现算的内联值。
|
|
16
|
+
这份皮肤只管交叉轴的尺寸、拇指的描边与状态表现,以及透明度那一路垫在轨道底下的棋盘格。 */
|
|
17
|
+
|
|
18
|
+
/* 私有槽位:拇指直径与轨道厚度同时被 control / track / thumb 用到,收成两个槽位挂在 root 上,
|
|
19
|
+
尺寸档只改这两处,靠继承发到子部件。颜色带比普通滑杆的底槽厚:它画的是颜色本身,太细看不清走向 */
|
|
20
|
+
[data-scope='color-slider'][data-part='root'] {
|
|
21
|
+
--xh-_thumb-size: var(--xh-color-slider-thumb-size, var(--xh-track-thumb-size));
|
|
22
|
+
--xh-_track-thickness: var(--xh-color-slider-track-thickness, var(--xh-space-3));
|
|
23
|
+
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
/* 字段标签贴控件(§6.4 复合单字段) */
|
|
27
|
+
gap: var(--xh-color-slider-gap, var(--xh-space-1));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* 竖排时整条控件收成一块,不再撑满一行:宽度由拇指直径决定 */
|
|
31
|
+
[data-scope='color-slider'][data-part='root'][data-orientation='vertical'] {
|
|
32
|
+
display: inline-flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* 禁用不整体压暗(§7.2 第 9 条):标签是文字,换到禁用前景;颜色带与拇指画的是颜色本身,换不得色,
|
|
37
|
+
压暗只做一次、落在 control 上(track / thumb 各自再叠一层 opacity 会越叠越黑),拇指另收掉抬升 */
|
|
38
|
+
|
|
39
|
+
/* 字段标签:14 / 500 / fg-default(§6.4),禁用换到 --xh-fg-subtle */
|
|
40
|
+
[data-scope='color-slider'][data-part='label'] {
|
|
41
|
+
color: var(--xh-color-slider-label-fg, var(--xh-fg-default));
|
|
42
|
+
font-size: var(--xh-color-slider-label-font-size, var(--xh-text-label-size));
|
|
43
|
+
font-weight: var(--xh-color-slider-label-font-weight, var(--xh-text-label-weight));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[data-scope='color-slider'][data-part='label'][data-disabled] {
|
|
47
|
+
color: var(--xh-color-slider-label-fg-disabled, var(--xh-fg-subtle));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* 拇指以它为定位上下文(拇指常常浮出轨道,挂在 track 上会被轨道的盒子束住)。
|
|
51
|
+
厚度取拇指直径与轨道厚度里大的那个。touch-action 由连接层内联给,这里不写。 */
|
|
52
|
+
[data-scope='color-slider'][data-part='control'] {
|
|
53
|
+
position: relative;
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
block-size: max(var(--xh-_thumb-size), var(--xh-_track-thickness));
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
[data-scope='color-slider'][data-part='control'][data-orientation='vertical'] {
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
inline-size: max(var(--xh-_thumb-size), var(--xh-_track-thickness));
|
|
64
|
+
block-size: var(--xh-color-slider-vertical-length, var(--xh-overlay-menu-min-w));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* 按下轨道即跳,拖动中光标换成"抓着"的样子,手感与拇指一致 */
|
|
68
|
+
[data-scope='color-slider'][data-part='control'][data-dragging] {
|
|
69
|
+
cursor: grabbing;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
[data-scope='color-slider'][data-part='control'][data-readonly]:not([data-disabled]) {
|
|
73
|
+
cursor: default;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
[data-scope='color-slider'][data-part='control'][data-disabled] {
|
|
77
|
+
opacity: var(--xh-state-disabled-opacity);
|
|
78
|
+
cursor: not-allowed;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* 轨道画的是颜色本身:渐变由连接层内联给,这里只给形状与一圈细边把浅色端从底色里框出来。
|
|
82
|
+
透明度那一路的棋盘格垫在轨道底下(background-color 与后面几层 background-image 是同一个盒),
|
|
83
|
+
内联的渐变写的是 background-image 的第一层——连接层只写这一个属性,不会把这里的层盖掉 */
|
|
84
|
+
[data-scope='color-slider'][data-part='track'] {
|
|
85
|
+
position: relative;
|
|
86
|
+
border-radius: var(--xh-color-slider-track-radius, var(--xh-shape-pill));
|
|
87
|
+
box-shadow: inset 0 0 0 var(--xh-stroke-thin) var(--xh-color-slider-track-border, var(--xh-border-subtle));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
[data-scope='color-slider'][data-part='track'][data-orientation='horizontal'] {
|
|
91
|
+
inline-size: 100%;
|
|
92
|
+
block-size: var(--xh-_track-thickness);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
[data-scope='color-slider'][data-part='track'][data-orientation='vertical'] {
|
|
96
|
+
block-size: 100%;
|
|
97
|
+
inline-size: var(--xh-_track-thickness);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* 透明度那一路:轨道从全透明走到实色,透明那半正好把棋盘格露出来。
|
|
101
|
+
棋盘格铺在轨道自己身上而不是 control 上,圆角才裁得住。
|
|
102
|
+
注意连接层写的是 background-image(覆盖整个属性),所以格子走 background-color 加伪元素 */
|
|
103
|
+
[data-scope='color-slider'][data-part='track'][data-channel='alpha']::before {
|
|
104
|
+
content: '';
|
|
105
|
+
position: absolute;
|
|
106
|
+
inset: 0;
|
|
107
|
+
z-index: -1;
|
|
108
|
+
border-radius: inherit;
|
|
109
|
+
background-color: var(--xh-color-slider-checker-base, var(--xh-bg-surface));
|
|
110
|
+
background-image:
|
|
111
|
+
linear-gradient(45deg, var(--xh-color-slider-checker, var(--xh-color-neutral-300)) 25%, transparent 25%),
|
|
112
|
+
linear-gradient(-45deg, var(--xh-color-slider-checker, var(--xh-color-neutral-300)) 25%, transparent 25%),
|
|
113
|
+
linear-gradient(45deg, transparent 75%, var(--xh-color-slider-checker, var(--xh-color-neutral-300)) 75%),
|
|
114
|
+
linear-gradient(-45deg, transparent 75%, var(--xh-color-slider-checker, var(--xh-color-neutral-300)) 75%);
|
|
115
|
+
background-position: 0 0, 0 4px, 4px -4px, -4px 0;
|
|
116
|
+
background-size: 8px 8px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* 伪元素要压在 z-index 之下,轨道得自己成一个层叠上下文 */
|
|
120
|
+
[data-scope='color-slider'][data-part='track'][data-channel='alpha'] {
|
|
121
|
+
isolation: isolate;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* 圆点浮在轨道之上:轨道是流内的,拇指是绝对定位的,天然后来居上。
|
|
125
|
+
拇指填的是当前那一档的颜色(连接层写进私有槽),拇指是可拖起的 raised 面(§8):
|
|
126
|
+
--xh-border-default 描边把它从任何底色里框出来,raised 影只是加成、不作边界。
|
|
127
|
+
box-sizing 必须显式写:描边要吃进直径里,否则下面按半个直径回拉的负外边距就对不上圆心。 */
|
|
128
|
+
[data-scope='color-slider'][data-part='thumb'] {
|
|
129
|
+
--xh-_color-slider-thumb-color: transparent;
|
|
130
|
+
|
|
131
|
+
position: absolute;
|
|
132
|
+
box-sizing: border-box;
|
|
133
|
+
inline-size: var(--xh-_thumb-size);
|
|
134
|
+
block-size: var(--xh-_thumb-size);
|
|
135
|
+
border: var(--xh-stroke-thick) solid var(--xh-color-slider-thumb-border, var(--xh-border-default));
|
|
136
|
+
border-radius: var(--xh-color-slider-thumb-radius, var(--xh-shape-circle));
|
|
137
|
+
background: var(--xh-color-slider-thumb-bg, var(--xh-_color-slider-thumb-color));
|
|
138
|
+
box-shadow: var(--xh-color-slider-thumb-shadow, var(--xh-elevation-raised));
|
|
139
|
+
cursor: grab;
|
|
140
|
+
transition:
|
|
141
|
+
scale var(--xh-motion-duration-micro) var(--xh-motion-ease-enter-strong),
|
|
142
|
+
box-shadow var(--xh-motion-duration-micro) var(--xh-motion-ease-enter);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* 内联样式把 inset-inline-start 定在值所在的比例上,那是拇指的**起始边**不是圆心;
|
|
146
|
+
用负的逻辑外边距回拉半个直径,圆心才落在比例点上(rtl 下负的逻辑外边距自己跟着换向)。 */
|
|
147
|
+
[data-scope='color-slider'][data-part='thumb'][data-orientation='horizontal'] {
|
|
148
|
+
inset-block-start: 50%;
|
|
149
|
+
margin-block-start: calc(var(--xh-_thumb-size) / -2);
|
|
150
|
+
margin-inline-start: calc(var(--xh-_thumb-size) / -2);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* 竖排的主轴是 inset-block-end(值向上增大),回拉也就换到 block-end 那侧 */
|
|
154
|
+
[data-scope='color-slider'][data-part='thumb'][data-orientation='vertical'] {
|
|
155
|
+
inset-inline-start: 50%;
|
|
156
|
+
margin-inline-start: calc(var(--xh-_thumb-size) / -2);
|
|
157
|
+
margin-block-end: calc(var(--xh-_thumb-size) / -2);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* 放大用 scale 而不是改尺寸:变换绕自身中心发生,圆心不动。海拔从 raised 换到 lifted */
|
|
161
|
+
[data-scope='color-slider'][data-part='thumb'][data-dragging] {
|
|
162
|
+
scale: var(--xh-color-slider-thumb-scale-dragging, var(--xh-motion-scale-drag));
|
|
163
|
+
cursor: grabbing;
|
|
164
|
+
box-shadow: var(--xh-color-slider-thumb-shadow-dragging, var(--xh-elevation-lifted));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* 校验失败时描边换成无效色:拇指的面要保住当前颜色,只能动描边 */
|
|
168
|
+
[data-scope='color-slider'][data-part='thumb'][data-invalid] {
|
|
169
|
+
border-color: var(--xh-color-slider-thumb-border-invalid, var(--xh-border-invalid));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
[data-scope='color-slider'][data-part='thumb'][data-readonly]:not([data-disabled]) {
|
|
173
|
+
cursor: default;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* 禁用:拖不起来的东西不该看着像浮在轨道上,影收掉;面仍是当前颜色,压暗由 control 那一层给 */
|
|
177
|
+
[data-scope='color-slider'][data-part='thumb'][data-disabled] {
|
|
178
|
+
box-shadow: var(--xh-color-slider-thumb-shadow-disabled, none);
|
|
179
|
+
cursor: not-allowed;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* 值气泡:挂在拇指里,跟着拇指一起走位。默认只在推动那一刻露面 */
|
|
183
|
+
[data-scope='color-slider'][data-part='value-text'] {
|
|
184
|
+
position: absolute;
|
|
185
|
+
inset-block-end: 100%;
|
|
186
|
+
inset-inline: 50%;
|
|
187
|
+
inline-size: max-content;
|
|
188
|
+
margin-block-end: var(--xh-color-slider-value-text-offset, var(--xh-space-2));
|
|
189
|
+
margin-inline: auto;
|
|
190
|
+
padding-block: var(--xh-color-slider-value-text-py, var(--xh-space-0_5));
|
|
191
|
+
padding-inline: var(--xh-color-slider-value-text-px, var(--xh-space-2));
|
|
192
|
+
border-radius: var(--xh-color-slider-value-text-radius, var(--xh-shape-control));
|
|
193
|
+
background: var(--xh-color-slider-value-text-bg, var(--xh-bg-brand));
|
|
194
|
+
color: var(--xh-color-slider-value-text-fg, var(--xh-fg-on-brand));
|
|
195
|
+
font-size: var(--xh-color-slider-value-text-font-size, var(--xh-text-caption-size));
|
|
196
|
+
font-variant-numeric: tabular-nums;
|
|
197
|
+
line-height: var(--xh-leading-normal);
|
|
198
|
+
white-space: nowrap;
|
|
199
|
+
/* 气泡贴在拇指上方,指针要落到拇指上,不能被它挡住 */
|
|
200
|
+
pointer-events: none;
|
|
201
|
+
opacity: 0;
|
|
202
|
+
transition: opacity var(--xh-motion-duration-micro) var(--xh-motion-ease-enter);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
[data-scope='color-slider'][data-part='value-text'][hidden] {
|
|
206
|
+
display: none;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
[data-scope='color-slider'][data-part='value-text'][data-dragging] {
|
|
210
|
+
opacity: 1;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/* 竖排轨道的气泡挪到行侧:压在拇指上方会挡住上一档的值 */
|
|
214
|
+
[data-scope='color-slider'][data-part='value-text'][data-orientation='vertical'] {
|
|
215
|
+
inset-block: 50%;
|
|
216
|
+
inset-inline: 100% auto;
|
|
217
|
+
block-size: max-content;
|
|
218
|
+
margin-block: auto;
|
|
219
|
+
margin-inline: var(--xh-color-slider-value-text-offset, var(--xh-space-2)) 0;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/* —— 尺寸 —— */
|
|
223
|
+
/* 尺寸只改 root 上那两个槽位,control / track / thumb 跟着一起走;中间档不写规则,缺省即中档 */
|
|
224
|
+
[data-scope='color-slider'][data-part='root'][data-size='sm'] {
|
|
225
|
+
--xh-_thumb-size: var(--xh-color-slider-thumb-size, var(--xh-space-3));
|
|
226
|
+
--xh-_track-thickness: var(--xh-color-slider-track-thickness, var(--xh-space-2));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
[data-scope='color-slider'][data-part='root'][data-size='lg'] {
|
|
230
|
+
--xh-_thumb-size: var(--xh-color-slider-thumb-size, var(--xh-space-6));
|
|
231
|
+
--xh-_track-thickness: var(--xh-color-slider-track-thickness, var(--xh-space-4));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* display 会盖掉 UA 的 [hidden]{display:none},凡是被赋了 display 的角色节点都要显式让位 */
|
|
235
|
+
[data-scope='color-slider'][data-part='root'][hidden],
|
|
236
|
+
[data-scope='color-slider'][data-part='control'][hidden] {
|
|
237
|
+
display: none;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/* hidden-input 是 type=hidden 的原生输入,浏览器本就不渲染它,这里一条声明都不给。 */
|
|
241
|
+
|
|
242
|
+
@media (prefers-reduced-motion: reduce) {
|
|
243
|
+
[data-scope='color-slider'][data-part='thumb'],
|
|
244
|
+
[data-scope='color-slider'][data-part='value-text'] {
|
|
245
|
+
transition: none;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/*
|
|
250
|
+
* 高对比档:轨道画的就是颜色本身,被系统换掉之后整条滑杆不再能调色。
|
|
251
|
+
* 轨道与拇指退出强制着色保住原色,各补一圈系统描边把它们从背景里框出来。
|
|
252
|
+
*/
|
|
253
|
+
@media (forced-colors: active) {
|
|
254
|
+
[data-scope='color-slider'][data-part='track'],
|
|
255
|
+
[data-scope='color-slider'][data-part='track']::before,
|
|
256
|
+
[data-scope='color-slider'][data-part='thumb'] {
|
|
257
|
+
forced-color-adjust: none;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
[data-scope='color-slider'][data-part='track'] {
|
|
261
|
+
outline: var(--xh-stroke-thin) solid CanvasText;
|
|
262
|
+
outline-offset: calc(-1 * var(--xh-stroke-thin));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
[data-scope='color-slider'][data-part='thumb'] {
|
|
266
|
+
border-color: CanvasText;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
[data-scope='color-slider'][data-part='thumb']:focus-visible {
|
|
270
|
+
outline: var(--xh-ring-width) solid Highlight;
|
|
271
|
+
outline-offset: var(--xh-ring-offset);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-Present XiHanFun and contributors.
|
|
3
|
+
* Licensed under the MIT License. See LICENSE in the project root for license information.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* 定义 color swatch picker 样式。 */
|
|
7
|
+
|
|
8
|
+
@import '../family/swatch.css';
|
|
9
|
+
|
|
10
|
+
@layer xihan.components {
|
|
11
|
+
/* 皮肤在场的标记:开发模式下按 scope 探一次,取不到就说明这份皮肤没被引入。 */
|
|
12
|
+
[data-scope='color-swatch-picker'] {
|
|
13
|
+
--xh-color-swatch-picker-skin: 1;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* 一组固定颜色排成可换行的网格,每格是一颗 role=radio 的方块。
|
|
17
|
+
格子的边长跟着控件行高走(sm/md/lg 三档),一排色块与旁边的按钮、字段齐高;
|
|
18
|
+
色块面、棋盘格与描边由 Swatch 家族画,这份皮肤只管格子的命中区、选中描边与选中徽标 */
|
|
19
|
+
[data-scope='color-swatch-picker'][data-part='root'] {
|
|
20
|
+
/* 尺寸档只换这几个私有槽,格子与标记都从 root 继承它们;标题走字段标签角色,不随档 */
|
|
21
|
+
--xh-_color-swatch-picker-cell: var(--xh-control-h-md);
|
|
22
|
+
--xh-_color-swatch-picker-gap: var(--xh-control-gap-md);
|
|
23
|
+
--xh-_color-swatch-picker-indicator: var(--xh-control-indicator-md);
|
|
24
|
+
/* 勾从徽标里减去一圈内衬,徽标换档时勾跟着走 */
|
|
25
|
+
--xh-_color-swatch-picker-mark: calc(var(--xh-_color-swatch-picker-indicator) - var(--xh-space-1));
|
|
26
|
+
/* 徽标底随语气走。没写 data-tone 时 --xh-_tone 没被声明,退回品牌色 */
|
|
27
|
+
--xh-_color-swatch-picker-accent: var(--xh-_tone, var(--xh-bg-brand));
|
|
28
|
+
/* 作者往标记槽里换 XhIcon 时与兜底的勾同一把尺 */
|
|
29
|
+
--xh-icon-size: var(--xh-color-swatch-picker-icon-size, var(--xh-_color-swatch-picker-mark));
|
|
30
|
+
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-wrap: wrap;
|
|
33
|
+
align-items: center;
|
|
34
|
+
gap: var(--xh-color-swatch-picker-gap, var(--xh-_color-swatch-picker-gap));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[data-scope='color-swatch-picker'][data-part='root'][data-disabled] {
|
|
38
|
+
cursor: not-allowed;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* —— 尺寸 —— */
|
|
42
|
+
[data-scope='color-swatch-picker'][data-part='root'][data-size='sm'] {
|
|
43
|
+
--xh-_color-swatch-picker-cell: var(--xh-control-h-sm);
|
|
44
|
+
--xh-_color-swatch-picker-gap: var(--xh-control-gap-sm);
|
|
45
|
+
--xh-_color-swatch-picker-indicator: var(--xh-control-indicator-sm);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[data-scope='color-swatch-picker'][data-part='root'][data-size='lg'] {
|
|
49
|
+
--xh-_color-swatch-picker-cell: var(--xh-control-h-lg);
|
|
50
|
+
--xh-_color-swatch-picker-gap: var(--xh-control-gap-lg);
|
|
51
|
+
--xh-_color-swatch-picker-indicator: var(--xh-control-indicator-lg);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* 标题独占一行,格子从下一行起排。复合单字段的标签(§6.4):14 / 500 / fg-default,不随档;
|
|
55
|
+
与格子的距离贴控件 space-1——容器的 gap 归格子之间,标签在它之上补一段差值把距离收成目标值 */
|
|
56
|
+
[data-scope='color-swatch-picker'][data-part='label'] {
|
|
57
|
+
flex-basis: 100%;
|
|
58
|
+
margin-block-end: calc(
|
|
59
|
+
var(--xh-color-swatch-picker-label-gap, var(--xh-space-1))
|
|
60
|
+
- var(--xh-color-swatch-picker-gap, var(--xh-_color-swatch-picker-gap))
|
|
61
|
+
);
|
|
62
|
+
color: var(--xh-color-swatch-picker-label-fg, var(--xh-fg-default));
|
|
63
|
+
font-size: var(--xh-color-swatch-picker-label-font-size, var(--xh-text-label-size));
|
|
64
|
+
font-weight: var(--xh-color-swatch-picker-label-font-weight, var(--xh-text-label-weight));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[data-scope='color-swatch-picker'][data-part='label'][data-disabled] {
|
|
68
|
+
color: var(--xh-color-swatch-picker-label-fg-disabled, var(--xh-fg-subtle));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* 一格:正方形命中区,里面铺满色块面。
|
|
72
|
+
position 是给格内那份视觉隐藏的原生输入与压在色块上的标记做定位基准,别去掉。
|
|
73
|
+
色块的描边按格子的状态换(静息 / 悬停 / 按下 / 选中),四档都写在格子这一层的私有槽上,
|
|
74
|
+
色块面那条只读它——这一格的底色就是它要展示的那个颜色,交互回执只能落在描边上 */
|
|
75
|
+
[data-scope='color-swatch-picker'][data-part='item'] {
|
|
76
|
+
--xh-_color-swatch-picker-edge: var(--xh-color-swatch-picker-swatch-border, var(--xh-border-default));
|
|
77
|
+
|
|
78
|
+
position: relative;
|
|
79
|
+
display: inline-flex;
|
|
80
|
+
flex: none;
|
|
81
|
+
inline-size: var(--xh-color-swatch-picker-item-size, var(--xh-_color-swatch-picker-cell));
|
|
82
|
+
block-size: var(--xh-color-swatch-picker-item-size, var(--xh-_color-swatch-picker-cell));
|
|
83
|
+
/* 色块 item 的身份是 inset(§6.3:嵌在 control 内的小块) */
|
|
84
|
+
border-radius: var(--xh-color-swatch-picker-item-radius, var(--xh-shape-inset));
|
|
85
|
+
outline: none;
|
|
86
|
+
cursor: pointer;
|
|
87
|
+
transition: scale var(--xh-motion-duration-release) var(--xh-motion-ease-release);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* 指到哪一格:描边换到控件的悬停边(border-strong 只留给 contrast-more 与登记的强调边);
|
|
91
|
+
选中的那一格保留自己的品牌描边(§9.3 选中身份不被悬停盖掉) */
|
|
92
|
+
[data-scope='color-swatch-picker'][data-part='item']:not([data-disabled], [data-readonly], [data-state='checked']):hover {
|
|
93
|
+
--xh-_color-swatch-picker-edge: var(--xh-color-swatch-picker-swatch-border-hover, var(--xh-border-control-hover));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* 这一格的底色就是它要展示的那个颜色,换底等于把展示物盖掉(§9.1 的「同时换底」在这里落不下去),
|
|
97
|
+
交互回执只能落在别处:按下去看下压,描边同时换到品牌色作第二通道(按住即将选中的那一格)。
|
|
98
|
+
置灰与只读的都不压;指针 :active 与 Headless 投影的 data-pressed 看见同一副按压面 */
|
|
99
|
+
[data-scope='color-swatch-picker'][data-part='item']:not([data-disabled], [data-readonly]):is(:active, [data-pressed]) {
|
|
100
|
+
--xh-_color-swatch-picker-edge: var(--xh-color-swatch-picker-swatch-border-pressed, var(--xh-_tone, var(--xh-fg-brand)));
|
|
101
|
+
|
|
102
|
+
scale: var(--xh-motion-scale-press);
|
|
103
|
+
transition-duration: var(--xh-motion-duration-press);
|
|
104
|
+
transition-timing-function: var(--xh-motion-ease-press);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* 正被选中的那一格:色块自己的描边换成品牌色(语气组取语气色),与正中的徽标一起表达选中,
|
|
108
|
+
不再在盒子外面另画一圈——外圈 outline 留给焦点环独占 */
|
|
109
|
+
[data-scope='color-swatch-picker'][data-part='item'][data-state='checked'] {
|
|
110
|
+
--xh-_color-swatch-picker-edge: var(--xh-color-swatch-picker-ring, var(--xh-_tone, var(--xh-fg-brand)));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* 焦点环独占 outline:选中不再画外圈,由色块正中的徽标与色块自己的品牌描边表达 */
|
|
114
|
+
[data-scope='color-swatch-picker'][data-part='item']:focus-visible {
|
|
115
|
+
outline: var(--xh-ring-width) solid var(--xh-ring-focus);
|
|
116
|
+
outline-offset: var(--xh-ring-offset);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* 禁用走 aria-disabled 而非原生 disabled,格子仍可聚焦,样式由 data-disabled 表达 */
|
|
120
|
+
[data-scope='color-swatch-picker'][data-part='item'][data-disabled] {
|
|
121
|
+
cursor: not-allowed;
|
|
122
|
+
opacity: var(--xh-state-disabled-opacity);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* 只读整组都改不动,但不是禁用:颜色照常,只把"可点"这个暗示收回来。
|
|
126
|
+
排掉禁用项是因为这条选择器权重高过上面那条,不排就会把 not-allowed 覆盖回 default */
|
|
127
|
+
[data-scope='color-swatch-picker'][data-part='item'][data-readonly]:not([data-disabled]) {
|
|
128
|
+
cursor: default;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* 色块面铺满格子,圆角随格子;家族合同里的三把尺在这里接上组件自己的公开槽,
|
|
132
|
+
描边读格子按状态给的那一档 */
|
|
133
|
+
[data-scope='color-swatch-picker'][data-part='swatch'] {
|
|
134
|
+
--xh-swatch-size: 100%;
|
|
135
|
+
--xh-swatch-radius: var(--xh-color-swatch-picker-item-radius, var(--xh-shape-inset));
|
|
136
|
+
--xh-swatch-border: var(--xh-_color-swatch-picker-edge);
|
|
137
|
+
|
|
138
|
+
transition: border-color var(--xh-motion-duration-micro) var(--xh-motion-ease-enter);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* 校验失败:整组的描边转警示色,压过悬停、按下与选中那几档 */
|
|
142
|
+
[data-scope='color-swatch-picker'][data-part='swatch'][data-invalid] {
|
|
143
|
+
--xh-swatch-border: var(--xh-color-swatch-picker-swatch-border-invalid, var(--xh-border-invalid));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* 选中徽标:压在色块正中的一枚小圆徽——语气底加一圈画布色描边,
|
|
147
|
+
再往里是一个勾。徽标自带底色与描边,落在任何颜色的色块上都看得出来,
|
|
148
|
+
色块恰好是品牌色时那圈画布色把它从底上隔出来 */
|
|
149
|
+
[data-scope='color-swatch-picker'][data-part='indicator'] {
|
|
150
|
+
position: absolute;
|
|
151
|
+
inset: 0;
|
|
152
|
+
display: flex;
|
|
153
|
+
align-items: center;
|
|
154
|
+
justify-content: center;
|
|
155
|
+
pointer-events: none;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* 徽标本体画在 ::before 上,勾画在 ::after 上;作者往部件里塞自己的图形时只有勾让位 */
|
|
159
|
+
[data-scope='color-swatch-picker'][data-part='indicator']::before {
|
|
160
|
+
content: '';
|
|
161
|
+
position: absolute;
|
|
162
|
+
inline-size: var(--xh-color-swatch-picker-indicator-size, var(--xh-_color-swatch-picker-indicator));
|
|
163
|
+
block-size: var(--xh-color-swatch-picker-indicator-size, var(--xh-_color-swatch-picker-indicator));
|
|
164
|
+
border: var(--xh-stroke-thin) solid var(--xh-color-swatch-picker-indicator-border, var(--xh-bg-canvas));
|
|
165
|
+
/* 正方盒取 circle(§6.3:宽高同槽的盒不得用 pill 冒充圆) */
|
|
166
|
+
border-radius: var(--xh-shape-circle);
|
|
167
|
+
background: var(--xh-color-swatch-picker-indicator-bg, var(--xh-_color-swatch-picker-accent));
|
|
168
|
+
opacity: 0;
|
|
169
|
+
scale: 0;
|
|
170
|
+
transition:
|
|
171
|
+
opacity var(--xh-motion-duration-micro) var(--xh-motion-ease-enter),
|
|
172
|
+
scale var(--xh-motion-duration-micro) var(--xh-motion-ease-settle);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* 没写内容就由皮肤画勾;作者往部件里塞了自己的图形,这条规则即不命中 */
|
|
176
|
+
[data-scope='color-swatch-picker'][data-part='indicator']:empty::after {
|
|
177
|
+
content: '';
|
|
178
|
+
position: relative;
|
|
179
|
+
inline-size: var(--xh-icon-size, var(--xh-_color-swatch-picker-mark));
|
|
180
|
+
block-size: var(--xh-icon-size, var(--xh-_color-swatch-picker-mark));
|
|
181
|
+
background-color: var(--xh-color-swatch-picker-indicator-fg, var(--xh-_tone-on, var(--xh-fg-on-brand)));
|
|
182
|
+
-webkit-mask: var(--xh-glyph-mark-check) center / contain no-repeat;
|
|
183
|
+
mask: var(--xh-glyph-mark-check) center / contain no-repeat;
|
|
184
|
+
opacity: 0;
|
|
185
|
+
transition: opacity var(--xh-motion-duration-micro) var(--xh-motion-ease-enter);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* 作者塞进来的图形跟着勾同一套显隐 */
|
|
189
|
+
[data-scope='color-swatch-picker'][data-part='indicator'] > * {
|
|
190
|
+
position: relative;
|
|
191
|
+
color: var(--xh-color-swatch-picker-indicator-fg, var(--xh-_tone-on, var(--xh-fg-on-brand)));
|
|
192
|
+
opacity: 0;
|
|
193
|
+
transition: opacity var(--xh-motion-duration-micro) var(--xh-motion-ease-enter);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* 徽标出现时略微涨过 1 再收回,过冲量落在格内不碰描边 */
|
|
197
|
+
[data-scope='color-swatch-picker'][data-part='indicator'][data-state='checked']::before {
|
|
198
|
+
opacity: 1;
|
|
199
|
+
scale: 1;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
[data-scope='color-swatch-picker'][data-part='indicator'][data-state='checked']:empty::after,
|
|
203
|
+
[data-scope='color-swatch-picker'][data-part='indicator'][data-state='checked'] > * {
|
|
204
|
+
opacity: 1;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/* 声明过任何 display 就盖掉了 UA 的 [hidden]{display:none},收起态得自己还回去。
|
|
208
|
+
写在文件末尾:兜底必须排在该部件所有 display 声明之后 */
|
|
209
|
+
[data-scope='color-swatch-picker'][data-part='root'][hidden],
|
|
210
|
+
[data-scope='color-swatch-picker'][data-part='label'][hidden],
|
|
211
|
+
[data-scope='color-swatch-picker'][data-part='item'][hidden],
|
|
212
|
+
[data-scope='color-swatch-picker'][data-part='indicator'][hidden] {
|
|
213
|
+
display: none;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
@media print {
|
|
217
|
+
/* 打印默认丢底色:徽标那块语气底落到纸上会消失,勾就悬在色块上没了衬底。
|
|
218
|
+
徽标改画成一圈实边——边框印得出来,直径与圆心都不动(描边吃进盒里) */
|
|
219
|
+
[data-scope='color-swatch-picker'][data-part='indicator'][data-state='checked']::before {
|
|
220
|
+
border: var(--xh-stroke-thick) solid currentColor;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/*
|
|
225
|
+
* 高对比档:色块面由家族退出强制着色自己保住原色;选中描边与徽标换成系统的高亮色,
|
|
226
|
+
* 徽标那圈描边与勾各取系统墨色,选中的那一格在任何色块上都框得出来。
|
|
227
|
+
*/
|
|
228
|
+
@media (forced-colors: active) {
|
|
229
|
+
/* 家族在这一档把色块描边统一钉成 CanvasText,选中的那一格要在它之上换成高亮色 */
|
|
230
|
+
[data-scope='color-swatch-picker'][data-part='item'][data-state='checked'] > [data-part='swatch'] {
|
|
231
|
+
border-color: Highlight;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
[data-scope='color-swatch-picker'][data-part='indicator']::before {
|
|
235
|
+
border-color: Canvas;
|
|
236
|
+
background: Highlight;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
[data-scope='color-swatch-picker'][data-part='indicator']:empty::after {
|
|
240
|
+
background-color: HighlightText;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-Present XiHanFun and contributors.
|
|
3
|
+
* Licensed under the MIT License. See LICENSE in the project root for license information.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* 定义 color swatch 样式。 */
|
|
7
|
+
|
|
8
|
+
@import '../family/swatch.css';
|
|
9
|
+
|
|
10
|
+
@layer xihan.components {
|
|
11
|
+
/* 皮肤在场的标记:开发模式下按 scope 探一次,取不到就说明这份皮肤没被引入。 */
|
|
12
|
+
[data-scope='color-swatch'] {
|
|
13
|
+
--xh-color-swatch-skin: 1;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* 面、棋盘格、描边与尺寸档全由色块面家族画(root 带 data-xh-swatch);
|
|
17
|
+
组件层只把自己的公开槽映射到家族合同,并给行内排版补一个基线对齐。
|
|
18
|
+
棋盘格的两色是家族层的事(--xh-swatch-checker / --xh-swatch-checker-base),画的是「透明」本身,不随组件换 */
|
|
19
|
+
[data-scope='color-swatch'][data-part='root'] {
|
|
20
|
+
--xh-swatch-size: var(--xh-color-swatch-size, var(--xh-_swatch-size));
|
|
21
|
+
--xh-swatch-radius: var(--xh-color-swatch-radius, var(--xh-shape-inset));
|
|
22
|
+
--xh-swatch-border: var(--xh-color-swatch-border, var(--xh-border-default));
|
|
23
|
+
|
|
24
|
+
vertical-align: middle;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* 解析不出的颜色只剩棋盘格:描边换成危险色,看得出这里本该有个颜色 */
|
|
28
|
+
[data-scope='color-swatch'][data-part='root'][data-invalid] {
|
|
29
|
+
--xh-swatch-border: var(--xh-color-swatch-border-invalid, var(--xh-border-invalid));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[data-scope='color-swatch'][data-part='root'][hidden] {
|
|
33
|
+
display: none;
|
|
34
|
+
}
|
|
35
|
+
}
|