123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.prepareComponentToken = exports.default = void 0;
- var _cssinjs = require("@ant-design/cssinjs");
- var _style = require("../../style");
- var _internal = require("../../theme/internal");
- // ============================== Styles ==============================
- // ============================== Head ==============================
- const genCardHeadStyle = token => {
- const {
- antCls,
- componentCls,
- headerHeight,
- headerPadding,
- tabsMarginBottom
- } = token;
- return Object.assign(Object.assign({
- display: 'flex',
- justifyContent: 'center',
- flexDirection: 'column',
- minHeight: headerHeight,
- marginBottom: -1,
- padding: `0 ${(0, _cssinjs.unit)(headerPadding)}`,
- color: token.colorTextHeading,
- fontWeight: token.fontWeightStrong,
- fontSize: token.headerFontSize,
- background: token.headerBg,
- borderBottom: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${token.colorBorderSecondary}`,
- borderRadius: `${(0, _cssinjs.unit)(token.borderRadiusLG)} ${(0, _cssinjs.unit)(token.borderRadiusLG)} 0 0`
- }, (0, _style.clearFix)()), {
- '&-wrapper': {
- width: '100%',
- display: 'flex',
- alignItems: 'center'
- },
- '&-title': Object.assign(Object.assign({
- display: 'inline-block',
- flex: 1
- }, _style.textEllipsis), {
- [`
- > ${componentCls}-typography,
- > ${componentCls}-typography-edit-content
- `]: {
- insetInlineStart: 0,
- marginTop: 0,
- marginBottom: 0
- }
- }),
- [`${antCls}-tabs-top`]: {
- clear: 'both',
- marginBottom: tabsMarginBottom,
- color: token.colorText,
- fontWeight: 'normal',
- fontSize: token.fontSize,
- '&-bar': {
- borderBottom: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${token.colorBorderSecondary}`
- }
- }
- });
- };
- // ============================== Grid ==============================
- const genCardGridStyle = token => {
- const {
- cardPaddingBase,
- colorBorderSecondary,
- cardShadow,
- lineWidth
- } = token;
- return {
- width: '33.33%',
- padding: cardPaddingBase,
- border: 0,
- borderRadius: 0,
- boxShadow: `
- ${(0, _cssinjs.unit)(lineWidth)} 0 0 0 ${colorBorderSecondary},
- 0 ${(0, _cssinjs.unit)(lineWidth)} 0 0 ${colorBorderSecondary},
- ${(0, _cssinjs.unit)(lineWidth)} ${(0, _cssinjs.unit)(lineWidth)} 0 0 ${colorBorderSecondary},
- ${(0, _cssinjs.unit)(lineWidth)} 0 0 0 ${colorBorderSecondary} inset,
- 0 ${(0, _cssinjs.unit)(lineWidth)} 0 0 ${colorBorderSecondary} inset;
- `,
- transition: `all ${token.motionDurationMid}`,
- '&-hoverable:hover': {
- position: 'relative',
- zIndex: 1,
- boxShadow: cardShadow
- }
- };
- };
- // ============================== Actions ==============================
- const genCardActionsStyle = token => {
- const {
- componentCls,
- iconCls,
- actionsLiMargin,
- cardActionsIconSize,
- colorBorderSecondary,
- actionsBg
- } = token;
- return Object.assign(Object.assign({
- margin: 0,
- padding: 0,
- listStyle: 'none',
- background: actionsBg,
- borderTop: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${colorBorderSecondary}`,
- display: 'flex',
- borderRadius: `0 0 ${(0, _cssinjs.unit)(token.borderRadiusLG)} ${(0, _cssinjs.unit)(token.borderRadiusLG)}`
- }, (0, _style.clearFix)()), {
- '& > li': {
- margin: actionsLiMargin,
- color: token.colorTextDescription,
- textAlign: 'center',
- '> span': {
- position: 'relative',
- display: 'block',
- minWidth: token.calc(token.cardActionsIconSize).mul(2).equal(),
- fontSize: token.fontSize,
- lineHeight: token.lineHeight,
- cursor: 'pointer',
- '&:hover': {
- color: token.colorPrimary,
- transition: `color ${token.motionDurationMid}`
- },
- [`a:not(${componentCls}-btn), > ${iconCls}`]: {
- display: 'inline-block',
- width: '100%',
- color: token.colorIcon,
- lineHeight: (0, _cssinjs.unit)(token.fontHeight),
- transition: `color ${token.motionDurationMid}`,
- '&:hover': {
- color: token.colorPrimary
- }
- },
- [`> ${iconCls}`]: {
- fontSize: cardActionsIconSize,
- lineHeight: (0, _cssinjs.unit)(token.calc(cardActionsIconSize).mul(token.lineHeight).equal())
- }
- },
- '&:not(:last-child)': {
- borderInlineEnd: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${colorBorderSecondary}`
- }
- }
- });
- };
- // ============================== Meta ==============================
- const genCardMetaStyle = token => Object.assign(Object.assign({
- margin: `${(0, _cssinjs.unit)(token.calc(token.marginXXS).mul(-1).equal())} 0`,
- display: 'flex'
- }, (0, _style.clearFix)()), {
- '&-avatar': {
- paddingInlineEnd: token.padding
- },
- '&-detail': {
- overflow: 'hidden',
- flex: 1,
- '> div:not(:last-child)': {
- marginBottom: token.marginXS
- }
- },
- '&-title': Object.assign({
- color: token.colorTextHeading,
- fontWeight: token.fontWeightStrong,
- fontSize: token.fontSizeLG
- }, _style.textEllipsis),
- '&-description': {
- color: token.colorTextDescription
- }
- });
- // ============================== Inner ==============================
- const genCardTypeInnerStyle = token => {
- const {
- componentCls,
- colorFillAlter,
- headerPadding,
- bodyPadding
- } = token;
- return {
- [`${componentCls}-head`]: {
- padding: `0 ${(0, _cssinjs.unit)(headerPadding)}`,
- background: colorFillAlter,
- '&-title': {
- fontSize: token.fontSize
- }
- },
- [`${componentCls}-body`]: {
- padding: `${(0, _cssinjs.unit)(token.padding)} ${(0, _cssinjs.unit)(bodyPadding)}`
- }
- };
- };
- // ============================== Loading ==============================
- const genCardLoadingStyle = token => {
- const {
- componentCls
- } = token;
- return {
- overflow: 'hidden',
- [`${componentCls}-body`]: {
- userSelect: 'none'
- }
- };
- };
- // ============================== Basic ==============================
- const genCardStyle = token => {
- const {
- componentCls,
- cardShadow,
- cardHeadPadding,
- colorBorderSecondary,
- boxShadowTertiary,
- bodyPadding,
- extraColor
- } = token;
- return {
- [componentCls]: Object.assign(Object.assign({}, (0, _style.resetComponent)(token)), {
- position: 'relative',
- background: token.colorBgContainer,
- borderRadius: token.borderRadiusLG,
- [`&:not(${componentCls}-bordered)`]: {
- boxShadow: boxShadowTertiary
- },
- [`${componentCls}-head`]: genCardHeadStyle(token),
- [`${componentCls}-extra`]: {
- // https://stackoverflow.com/a/22429853/3040605
- marginInlineStart: 'auto',
- color: extraColor,
- fontWeight: 'normal',
- fontSize: token.fontSize
- },
- [`${componentCls}-body`]: Object.assign({
- padding: bodyPadding,
- borderRadius: `0 0 ${(0, _cssinjs.unit)(token.borderRadiusLG)} ${(0, _cssinjs.unit)(token.borderRadiusLG)}`
- }, (0, _style.clearFix)()),
- [`${componentCls}-grid`]: genCardGridStyle(token),
- [`${componentCls}-cover`]: {
- '> *': {
- display: 'block',
- width: '100%',
- borderRadius: `${(0, _cssinjs.unit)(token.borderRadiusLG)} ${(0, _cssinjs.unit)(token.borderRadiusLG)} 0 0`
- }
- },
- [`${componentCls}-actions`]: genCardActionsStyle(token),
- [`${componentCls}-meta`]: genCardMetaStyle(token)
- }),
- [`${componentCls}-bordered`]: {
- border: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${colorBorderSecondary}`,
- [`${componentCls}-cover`]: {
- marginTop: -1,
- marginInlineStart: -1,
- marginInlineEnd: -1
- }
- },
- [`${componentCls}-hoverable`]: {
- cursor: 'pointer',
- transition: `box-shadow ${token.motionDurationMid}, border-color ${token.motionDurationMid}`,
- '&:hover': {
- borderColor: 'transparent',
- boxShadow: cardShadow
- }
- },
- [`${componentCls}-contain-grid`]: {
- borderRadius: `${(0, _cssinjs.unit)(token.borderRadiusLG)} ${(0, _cssinjs.unit)(token.borderRadiusLG)} 0 0 `,
- [`${componentCls}-body`]: {
- display: 'flex',
- flexWrap: 'wrap'
- },
- [`&:not(${componentCls}-loading) ${componentCls}-body`]: {
- marginBlockStart: token.calc(token.lineWidth).mul(-1).equal(),
- marginInlineStart: token.calc(token.lineWidth).mul(-1).equal(),
- padding: 0
- }
- },
- [`${componentCls}-contain-tabs`]: {
- [`> div${componentCls}-head`]: {
- minHeight: 0,
- [`${componentCls}-head-title, ${componentCls}-extra`]: {
- paddingTop: cardHeadPadding
- }
- }
- },
- [`${componentCls}-type-inner`]: genCardTypeInnerStyle(token),
- [`${componentCls}-loading`]: genCardLoadingStyle(token),
- [`${componentCls}-rtl`]: {
- direction: 'rtl'
- }
- };
- };
- // ============================== Size ==============================
- const genCardSizeStyle = token => {
- const {
- componentCls,
- bodyPaddingSM,
- headerPaddingSM,
- headerHeightSM,
- headerFontSizeSM
- } = token;
- return {
- [`${componentCls}-small`]: {
- [`> ${componentCls}-head`]: {
- minHeight: headerHeightSM,
- padding: `0 ${(0, _cssinjs.unit)(headerPaddingSM)}`,
- fontSize: headerFontSizeSM,
- [`> ${componentCls}-head-wrapper`]: {
- [`> ${componentCls}-extra`]: {
- fontSize: token.fontSize
- }
- }
- },
- [`> ${componentCls}-body`]: {
- padding: bodyPaddingSM
- }
- },
- [`${componentCls}-small${componentCls}-contain-tabs`]: {
- [`> ${componentCls}-head`]: {
- [`${componentCls}-head-title, ${componentCls}-extra`]: {
- paddingTop: 0,
- display: 'flex',
- alignItems: 'center'
- }
- }
- }
- };
- };
- const prepareComponentToken = token => {
- var _a, _b;
- return {
- headerBg: 'transparent',
- headerFontSize: token.fontSizeLG,
- headerFontSizeSM: token.fontSize,
- headerHeight: token.fontSizeLG * token.lineHeightLG + token.padding * 2,
- headerHeightSM: token.fontSize * token.lineHeight + token.paddingXS * 2,
- actionsBg: token.colorBgContainer,
- actionsLiMargin: `${token.paddingSM}px 0`,
- tabsMarginBottom: -token.padding - token.lineWidth,
- extraColor: token.colorText,
- bodyPaddingSM: 12,
- // Fixed padding.
- headerPaddingSM: 12,
- bodyPadding: (_a = token.bodyPadding) !== null && _a !== void 0 ? _a : token.paddingLG,
- headerPadding: (_b = token.headerPadding) !== null && _b !== void 0 ? _b : token.paddingLG
- };
- };
- // ============================== Export ==============================
- exports.prepareComponentToken = prepareComponentToken;
- var _default = exports.default = (0, _internal.genStyleHooks)('Card', token => {
- const cardToken = (0, _internal.mergeToken)(token, {
- cardShadow: token.boxShadowCard,
- cardHeadPadding: token.padding,
- cardPaddingBase: token.paddingLG,
- cardActionsIconSize: token.fontSize
- });
- return [
- // Style
- genCardStyle(cardToken),
- // Size
- genCardSizeStyle(cardToken)];
- }, prepareComponentToken);
|