| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- import _extends from "@babel/runtime/helpers/esm/extends";
- import { genComponentStyleHook, mergeToken } from '../../theme/internal';
- import { resetComponent, textEllipsis } from '../../style';
- const genBorderedStyle = token => {
- const {
- componentCls,
- descriptionsSmallPadding,
- descriptionsDefaultPadding,
- descriptionsMiddlePadding,
- descriptionsBg
- } = token;
- return {
- [`&${componentCls}-bordered`]: {
- [`${componentCls}-view`]: {
- border: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`,
- '> table': {
- tableLayout: 'auto',
- borderCollapse: 'collapse'
- }
- },
- [`${componentCls}-item-label, ${componentCls}-item-content`]: {
- padding: descriptionsDefaultPadding,
- borderInlineEnd: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`,
- '&:last-child': {
- borderInlineEnd: 'none'
- }
- },
- [`${componentCls}-item-label`]: {
- backgroundColor: descriptionsBg,
- '&::after': {
- display: 'none'
- }
- },
- [`${componentCls}-row`]: {
- borderBottom: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`,
- '&:last-child': {
- borderBottom: 'none'
- }
- },
- [`&${componentCls}-middle`]: {
- [`${componentCls}-item-label, ${componentCls}-item-content`]: {
- padding: descriptionsMiddlePadding
- }
- },
- [`&${componentCls}-small`]: {
- [`${componentCls}-item-label, ${componentCls}-item-content`]: {
- padding: descriptionsSmallPadding
- }
- }
- }
- };
- };
- const genDescriptionStyles = token => {
- const {
- componentCls,
- descriptionsExtraColor,
- descriptionItemPaddingBottom,
- descriptionsItemLabelColonMarginRight,
- descriptionsItemLabelColonMarginLeft,
- descriptionsTitleMarginBottom
- } = token;
- return {
- [componentCls]: _extends(_extends(_extends({}, resetComponent(token)), genBorderedStyle(token)), {
- [`&-rtl`]: {
- direction: 'rtl'
- },
- [`${componentCls}-header`]: {
- display: 'flex',
- alignItems: 'center',
- marginBottom: descriptionsTitleMarginBottom
- },
- [`${componentCls}-title`]: _extends(_extends({}, textEllipsis), {
- flex: 'auto',
- color: token.colorText,
- fontWeight: token.fontWeightStrong,
- fontSize: token.fontSizeLG,
- lineHeight: token.lineHeightLG
- }),
- [`${componentCls}-extra`]: {
- marginInlineStart: 'auto',
- color: descriptionsExtraColor,
- fontSize: token.fontSize
- },
- [`${componentCls}-view`]: {
- width: '100%',
- borderRadius: token.borderRadiusLG,
- table: {
- width: '100%',
- tableLayout: 'fixed'
- }
- },
- [`${componentCls}-row`]: {
- '> th, > td': {
- paddingBottom: descriptionItemPaddingBottom
- },
- '&:last-child': {
- borderBottom: 'none'
- }
- },
- [`${componentCls}-item-label`]: {
- color: token.colorText,
- fontWeight: 'normal',
- fontSize: token.fontSize,
- lineHeight: token.lineHeight,
- textAlign: `start`,
- '&::after': {
- content: '":"',
- position: 'relative',
- top: -0.5,
- marginInline: `${descriptionsItemLabelColonMarginLeft}px ${descriptionsItemLabelColonMarginRight}px`
- },
- [`&${componentCls}-item-no-colon::after`]: {
- content: '""'
- }
- },
- [`${componentCls}-item-no-label`]: {
- '&::after': {
- margin: 0,
- content: '""'
- }
- },
- [`${componentCls}-item-content`]: {
- display: 'table-cell',
- flex: 1,
- color: token.colorText,
- fontSize: token.fontSize,
- lineHeight: token.lineHeight,
- wordBreak: 'break-word',
- overflowWrap: 'break-word'
- },
- [`${componentCls}-item`]: {
- paddingBottom: 0,
- verticalAlign: 'top',
- '&-container': {
- display: 'flex',
- [`${componentCls}-item-label`]: {
- display: 'inline-flex',
- alignItems: 'baseline'
- },
- [`${componentCls}-item-content`]: {
- display: 'inline-flex',
- alignItems: 'baseline'
- }
- }
- },
- '&-middle': {
- [`${componentCls}-row`]: {
- '> th, > td': {
- paddingBottom: token.paddingSM
- }
- }
- },
- '&-small': {
- [`${componentCls}-row`]: {
- '> th, > td': {
- paddingBottom: token.paddingXS
- }
- }
- }
- })
- };
- };
- // ============================== Export ==============================
- export default genComponentStyleHook('Descriptions', token => {
- const descriptionsBg = token.colorFillAlter;
- const descriptionsTitleMarginBottom = token.fontSizeSM * token.lineHeightSM;
- const descriptionsExtraColor = token.colorText;
- const descriptionsSmallPadding = `${token.paddingXS}px ${token.padding}px`;
- const descriptionsDefaultPadding = `${token.padding}px ${token.paddingLG}px`;
- const descriptionsMiddlePadding = `${token.paddingSM}px ${token.paddingLG}px`;
- const descriptionItemPaddingBottom = token.padding;
- const descriptionsItemLabelColonMarginRight = token.marginXS;
- const descriptionsItemLabelColonMarginLeft = token.marginXXS / 2;
- const descriptionToken = mergeToken(token, {
- descriptionsBg,
- descriptionsTitleMarginBottom,
- descriptionsExtraColor,
- descriptionItemPaddingBottom,
- descriptionsSmallPadding,
- descriptionsDefaultPadding,
- descriptionsMiddlePadding,
- descriptionsItemLabelColonMarginRight,
- descriptionsItemLabelColonMarginLeft
- });
- return [genDescriptionStyles(descriptionToken)];
- });
|