1010 <div class =" shadow-content__content" :style =" contentStyle" >
1111 <div class =" shadow-content__main" >
1212 <p class =" shadow-content__title" >{{ lang.shadow.title }}</p >
13- <!-- 顶部调整 -->
14- <div :style =" { display: 'flex' }" >
15- <div class =" shadow-panel__round" >
16- <div class =" shadow-panel__round-tag" >
17- <div class =" shadow-panel__round-box" :style =" { 'box-shadow': leftShadow }" ></div >
18- </div >
19- <div class =" shadow-panel__round-slider" >
20- <div
21- class =" slider-split"
22- :key =" i"
23- :style =" {
24- opacity: i == 0 || i === selectOptions.length - 2 ? 0 : 1,
25- }"
26- v-for =" (v, i) in selectOptions.slice(0, selectOptions.length - 1)"
27- ></div >
28-
29- <t-slider
30- :min =" 0"
31- :max =" selectOptions.length - 2"
32- :value =" step"
33- :label =" renderLabel"
34- :disabled =" forbidden"
35- :tooltipProps =" { attach: handleAttach }"
36- @change =" handleSliderChange"
37- ></t-slider >
38- </div >
39- <div class =" shadow-panel__round-tag" >
40- <div class =" shadow-panel__round-box" :style =" { 'box-shadow': rightShadow }" ></div >
41- </div >
42- </div >
43- <t-select
44- class =" shadow-panel__select"
45- :options =" selectOptions"
46- v-model =" step"
47- :keys =" isEn ? { label: 'enLabel' } : null"
48- :popup-props =" { attach: handleAttach }"
49- style =" width : 82px "
50- ></t-select >
51- </div >
13+ <SegmentSelection
14+ v-model =" step"
15+ :selectOptions =" selectOptions"
16+ :suspendedLabels =" suspendedLabels"
17+ :disabled =" forbidden"
18+ >
19+ <template #left >
20+ <div class =" shadow-panel__round-box" :style =" { 'box-shadow': leftShadow }" ></div >
21+ </template >
22+ <template #right >
23+ <div class =" shadow-panel__round-box" :style =" { 'box-shadow': rightShadow }" ></div >
24+ </template >
25+ </SegmentSelection >
5226 <shadow-card
5327 v-for =" (shadow, i) in shadowPalette"
5428 :key =" i"
6337</template >
6438
6539<script lang="jsx">
66- import { Select as TSelect, Slider as TSlider } from 'tdesign-vue';
67-
40+ import { SegmentSelection } from '@/common/components';
6841import { langMixin } from '@/common/i18n';
6942import { getOptionFromLocal, modifyToken, updateLocalOption } from '@/common/themes';
70- import { getTokenValue, handleAttach } from '@/common/utils';
43+ import { getTokenValue } from '@/common/utils';
7144
7245import {
7346 ShadowSelect,
@@ -84,8 +57,7 @@ export default {
8457 top: Number,
8558 },
8659 components: {
87- TSlider,
88- TSelect,
60+ SegmentSelection,
8961 ShadowCard,
9062 },
9163 mixins: [langMixin],
@@ -95,10 +67,15 @@ export default {
9567 selectOptions: ShadowSelect,
9668 selfDefined: ShadowSelectType,
9769 step: getOptionFromLocal('shadow') || ShadowSelectType.Default,
70+ suspendedLabels: {},
9871 };
9972 },
10073 created() {
10174 this.shadowTypeDetail = ShadowTypeDetail;
75+ this.suspendedLabels = this.selectOptions.reduce((acc, option) => {
76+ acc[option.value] = this.isEn ? option.enLabel : option.label;
77+ return acc;
78+ }, {});
10279 },
10380 computed: {
10481 contentStyle() {
@@ -155,14 +132,6 @@ export default {
155132 },
156133 },
157134 methods: {
158- handleAttach,
159- handleSliderChange(v) {
160- if (this.forbidden) return;
161- this.step = v;
162- },
163- renderLabel() {
164- return this.selectOptions[this.step].label;
165- },
166135 // 拆分 box-shadow 的值 0 1px 10px rgba(0, 0, 0, 0.05), 0 4px 5px rgba(0, 0, 0, 8%), 0 2px 4px -1px rgba(0, 0, 0, 12%)
167136 splitShadowValue(data) {
168137 const tempData = `${data},`;
@@ -248,93 +217,11 @@ export default {
248217 }
249218}
250219.shadow-panel {
251- &__round {
252- display : flex ;
253- height : 32px ;
254- > div {
255- display : flex ;
256- background-color : var (--bg-color-theme-secondary );
257- margin-right : 2px ;
258- align-items : center ;
259- justify-content : center ;
260- }
261- &-tag {
262- height : 100% ;
263- width : 32px ;
264- color : var (--text-primary );
265- & :first-child {
266- border-radius : 9px 0px 0px 9px ;
267- }
268- & :last-child {
269- border-radius : 0px 9px 9px 0px ;
270- margin-right : 0 ;
271- }
272- }
273- &-box {
274- width : 20px ;
275- height : 20px ;
276- background : var (--bg-color-theme-surface );
277- border-radius : 3px ;
278- }
279- &-slider {
280- width : 76px ;
281- padding : 6px ;
282- position : relative ;
283- display : flex ;
284- justify-content : space-between !important ;
285- .slider-split {
286- background-color : var (--bg-color-theme-secondary );
287- width : 2px ;
288- height : 8px ;
289- z-index : 2 ;
290- }
291- / deep/ .t-slider__container {
292- position : absolute ;
293- top : 6px ;
294- width : 60px ;
295- left : 8px ;
296- }
297- / deep/ .t-slider {
298- padding : 6px 0 ;
299- }
300- / deep/ .t-slider__rail {
301- height : 8px ;
302- background-color : var (--bg-color-theme-tertiary );
303- }
304- / deep/ .t-slider__track {
305- height : 8px ;
306- }
307- / deep/ .t-slider__button {
308- box-shadow : var (--shadow-1 );
309- border-color : var (--bg-color-tag );
310- }
311- }
312- }
313- &__select {
314- text-align : center ;
315- padding : 0 ;
316- margin-left : 8px ;
317- / deep/ .t-input {
318- background : var (--bg-color-theme-secondary );
319- border : 1px solid transparent ;
320- height : 32px ;
321- border-radius : 9px ;
322- padding : 0 8px ;
323- transition : border- color 0.2s ;
324- }
325- / deep/ .t-select :hover {
326- border-color : var (--component-border );
327- }
328- / deep/ .t-is-active {
329- border-color : var (--brand-main ) !important ;
330- }
331- / deep/ .t-select__right-icon {
332- color : var (--text-placeholder ) !important ;
333- }
334-
335- / deep/ .t-select__single {
336- margin-left : 0 ;
337- }
220+ &__round-box {
221+ width : 20px ;
222+ height : 20px ;
223+ background : var (--bg-color-theme-surface );
224+ border-radius : 3px ;
338225 }
339226}
340227 </style >
0 commit comments