Skip to content

Commit 6240ab2

Browse files
authored
[tabs] :less to cssinjs (#6288)
* update * switch * Style adjustment * refactor(Card): less to cssinjs * tabs: less to cssinjs 开发ing * add function cssinjs * Eliminate irrelevant code * Eliminate irrelevant code 2 * update components * Eliminate irrelevant input code
1 parent 328e42a commit 6240ab2

15 files changed

+765
-737
lines changed

components/style.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import './radio/style';
88
// import './pagination/style';
99
// import './avatar/style';
1010
// import './badge/style';
11-
import './tabs/style';
11+
//import './tabs/style';
1212
// import './input/style';
1313
// import './tooltip/style';
1414
// import './popover/style';

components/tabs/src/Tabs.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import pick from 'lodash-es/pick';
2828
import PropTypes from '../../_util/vue-types';
2929
import type { MouseEventHandler } from '../../_util/EventInterface';
3030
import omit from '../../_util/omit';
31-
31+
import useStyle from '../style';
3232
export type TabsType = 'line' | 'card' | 'editable-card';
3333
export type TabsPosition = 'top' | 'right' | 'bottom' | 'left';
3434

@@ -155,6 +155,7 @@ const InternalTabs = defineComponent({
155155
'`tabBarExtraContent` slot is deprecated. Please use `rightExtra` slot instead.',
156156
);
157157
const { prefixCls, direction, size, rootPrefixCls } = useConfigInject('tabs', props);
158+
const [wrapSSR, hashId] = useStyle(prefixCls);
158159
const rtl = computed(() => direction.value === 'rtl');
159160
const mergedAnimated = computed<AnimatedConfig>(() => {
160161
const { animated, tabPosition } = props;
@@ -297,14 +298,15 @@ const InternalTabs = defineComponent({
297298
}
298299
const pre = prefixCls.value;
299300

300-
return (
301+
return wrapSSR(
301302
<div
302303
{...attrs}
303304
id={id}
304305
class={classNames(
305306
pre,
306307
`${pre}-${mergedTabPosition.value}`,
307308
{
309+
[hashId.value]: true,
308310
[`${pre}-${size.value}`]: size.value,
309311
[`${pre}-card`]: ['card', 'editable-card'].includes(type as string),
310312
[`${pre}-editable-card`]: type === 'editable-card',
@@ -322,7 +324,7 @@ const InternalTabs = defineComponent({
322324
{...sharedProps}
323325
animated={mergedAnimated.value}
324326
/>
325-
</div>
327+
</div>,
326328
);
327329
};
328330
},

components/tabs/style/card.less

-98
This file was deleted.

components/tabs/style/card.tsx

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import type { CSSObject } from '../../_util/cssinjs';
2+
3+
export const tabsCardStyle:{tabsCardGutter:string}={
4+
tabsCardGutter: '2px'
5+
}
6+
export const genTabscardStyle = (token): CSSObject => {
7+
const { componentCls } = token;
8+
9+
return {
10+
[` ${componentCls}-nav,
11+
div > ${componentCls}-nav `]: {
12+
[`${componentCls}-tab `]: {
13+
margin: 0,
14+
background: `${token.colorFillAlter}`,
15+
padding: `${token.paddingXS}px ${token.padding}px`,
16+
border:`${token.lineWidth}px ${token.colorBorder} ${token.lineType} `,
17+
transition: `all ${token.motionDurationSlow} ${token.motionEaseInOut} `,
18+
19+
[`&-active `]: {
20+
color: ` ${token.colorInfoActive}`,
21+
background: `${token.colorBgContainer}`,
22+
},
23+
},
24+
25+
[`${componentCls}-ink-bar`]: {
26+
visibility: `hidden`,
27+
},
28+
},
29+
30+
// ========================== Top & Bottom ==========================
31+
[`&${componentCls}-top,
32+
&${componentCls}-bottom`]: {
33+
[`${componentCls}-nav,
34+
div > ${componentCls}-nav `]: {
35+
[` ${componentCls}-tab + ${componentCls}-tab `]: {
36+
marginLeft: `${tabsCardStyle.tabsCardGutter} `,
37+
},
38+
},
39+
},
40+
41+
[`&${componentCls}-top `]: {
42+
[`${componentCls}-nav,
43+
div > ${componentCls}-nav `]: {
44+
[`${componentCls}-tab `]: {
45+
borderRadius: ` ${token.radiusBase}px ${token.radiusBase}px 0 0`,
46+
[`&-active `]: {
47+
borderBottomColor: `${token.colorBgContainer}`,
48+
},
49+
},
50+
},
51+
},
52+
[`&${componentCls}-bottom`]: {
53+
[`${componentCls}-nav,
54+
div > ${componentCls}-nav`]: {
55+
[` ${componentCls}-tab `]: {
56+
borderRadius: `0 0 ${token.radiusBase}px ${token.radiusBase}px`,
57+
58+
[` &-active `]: {
59+
borderTopColor: `${token.colorBgContainer}`,
60+
},
61+
},
62+
},
63+
},
64+
65+
// ========================== Left & Right ==========================
66+
[`&${componentCls}-left,
67+
&${componentCls}-right`]: {
68+
[` ${componentCls}-nav,
69+
div > ${componentCls}-nav `]: {
70+
[` ${componentCls}-tab + ${componentCls}-tab`]: {
71+
marginTop: `${tabsCardStyle.tabsCardGutter}`,
72+
},
73+
},
74+
},
75+
76+
[`&${componentCls}-left`]: {
77+
[` > ${componentCls}-nav,
78+
> div > ${componentCls}-nav`]: {
79+
[` ${componentCls}-tab`]: {
80+
borderRadius: `${token.radiusBase}px 0 0 ${token.radiusBase}px`,
81+
82+
[` &-active`]: {
83+
borderRightColor: `${token.colorBgContainer}`,
84+
},
85+
},
86+
},
87+
},
88+
[` &${componentCls}-right `]: {
89+
[` ${componentCls}-nav,
90+
div > ${componentCls}-nav `]: {
91+
[` ${componentCls}-tab `]: {
92+
borderRadius: `0 ${token.radiusBase}px ${token.radiusBase}px 0`,
93+
94+
[` &-active `]: {
95+
borderLeftColor:`${token.colorBgContainer}`,
96+
},
97+
},
98+
},
99+
},
100+
};
101+
};

components/tabs/style/dropdown.less

-82
This file was deleted.

0 commit comments

Comments
 (0)