Skip to content

Commit cb08f85

Browse files
authored
refactor(crad): less to cssinjs (#6258)
* update * switch * Style adjustment * refactor(Card): less to cssinjs * Eliminate invalid code * optimization and adjustment css * Adjust the css * Optimize each item * adjustment css
1 parent f0e5da3 commit cb08f85

File tree

8 files changed

+382
-343
lines changed

8 files changed

+382
-343
lines changed

components/card/Card.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { SizeType } from '../config-provider';
99
import isPlainObject from 'lodash-es/isPlainObject';
1010
import useConfigInject from '../config-provider/hooks/useConfigInject';
1111
import devWarning from '../vc-util/devWarning';
12+
import useStyle from './style';
1213
export interface CardTabListType {
1314
key: string;
1415
tab: any;
@@ -51,10 +52,12 @@ export type CardProps = Partial<ExtractPropTypes<ReturnType<typeof cardProps>>>;
5152
const Card = defineComponent({
5253
compatConfig: { MODE: 3 },
5354
name: 'ACard',
55+
inheritAttrs: false,
5456
props: cardProps(),
5557
slots: ['title', 'extra', 'tabBarExtraContent', 'actions', 'cover', 'customTab'],
56-
setup(props, { slots }) {
58+
setup(props, { slots, attrs }) {
5759
const { prefixCls, direction, size } = useConfigInject('card', props);
60+
const [wrapSSR, hashId] = useStyle(prefixCls);
5861
const getAction = (actions: VNodeTypes[]) => {
5962
const actionList = actions.map((action, index) =>
6063
(isVNode(action) && !isEmptyElement(action)) || !isVNode(action) ? (
@@ -99,6 +102,7 @@ const Card = defineComponent({
99102
const pre = prefixCls.value;
100103
const classString = {
101104
[`${pre}`]: true,
105+
[hashId.value]: true,
102106
[`${pre}-loading`]: loading,
103107
[`${pre}-bordered`]: bordered,
104108
[`${pre}-hoverable`]: !!hoverable,
@@ -190,13 +194,13 @@ const Card = defineComponent({
190194
const actionDom =
191195
actions && actions.length ? <ul class={`${pre}-actions`}>{getAction(actions)}</ul> : null;
192196

193-
return (
194-
<div class={classString} ref="cardContainerRef">
197+
return wrapSSR(
198+
<div ref="cardContainerRef" {...attrs} class={classString}>
195199
{head}
196200
{coverDom}
197201
{children && children.length ? body : null}
198202
{actionDom}
199-
</div>
203+
</div>,
200204
);
201205
};
202206
},

components/card/style/index.less

-308
This file was deleted.

0 commit comments

Comments
 (0)