Skip to content

Commit f5d8c47

Browse files
committed
move padding style in get-padding-by-size file
1 parent 832e1b1 commit f5d8c47

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

packages/components/src/card/get-padding-by-size.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,35 @@ import { css, type SerializedStyles } from '@emotion/react';
77
* Internal dependencies
88
*/
99
import type { Props, SizeToken } from './types';
10-
import { cardPaddings } from './styles';
1110
import { space } from '../utils/space';
1211

12+
const CONFIG = {
13+
cardPaddingXSmall: `${ space( 2 ) }`,
14+
cardPaddingSmall: `${ space( 4 ) }`,
15+
cardPaddingMedium: `${ space( 4 ) } ${ space( 6 ) }`,
16+
cardPaddingLarge: `${ space( 6 ) } ${ space( 8 ) }`,
17+
};
18+
19+
const xSmallCardPadding = css`
20+
padding: ${ CONFIG.cardPaddingXSmall };
21+
`;
22+
23+
export const cardPaddings = {
24+
large: css`
25+
padding: ${ CONFIG.cardPaddingLarge };
26+
`,
27+
medium: css`
28+
padding: ${ CONFIG.cardPaddingMedium };
29+
`,
30+
small: css`
31+
padding: ${ CONFIG.cardPaddingSmall };
32+
`,
33+
xSmall: xSmallCardPadding,
34+
// The `extraSmall` size is not officially documented, but the following styles
35+
// are kept for legacy reasons to support older values of the `size` prop.
36+
extraSmall: xSmallCardPadding,
37+
};
38+
1339
const getSinglePaddingValue = ( size?: SizeToken ): string | undefined => {
1440
switch ( size ) {
1541
case 'xSmall':

packages/components/src/card/styles.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,6 @@ export const rounded = css`
9494
border-radius: ${ adjustedBorderRadius };
9595
`;
9696

97-
const xSmallCardPadding = css`
98-
padding: ${ CONFIG.cardPaddingXSmall };
99-
`;
100-
101-
export const cardPaddings = {
102-
large: css`
103-
padding: ${ CONFIG.cardPaddingLarge };
104-
`,
105-
medium: css`
106-
padding: ${ CONFIG.cardPaddingMedium };
107-
`,
108-
small: css`
109-
padding: ${ CONFIG.cardPaddingSmall };
110-
`,
111-
xSmall: xSmallCardPadding,
112-
// The `extraSmall` size is not officially documented, but the following styles
113-
// are kept for legacy reasons to support older values of the `size` prop.
114-
extraSmall: xSmallCardPadding,
115-
};
116-
11797
export const shady = css`
11898
background-color: ${ COLORS.ui.backgroundDisabled };
11999
`;

packages/components/src/utils/config-values.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* Internal dependencies
33
*/
4-
import { space } from './space';
54
import { COLORS } from './colors-values';
65

76
const CONTROL_HEIGHT = '36px';
@@ -54,10 +53,6 @@ export default Object.assign( {}, CONTROL_PROPS, {
5453
fontWeightMedium: '499', // ensures fallback to 400 (instead of 600)
5554
fontWeightHeading: '600',
5655
gridBase: '4px',
57-
cardPaddingXSmall: `${ space( 2 ) }`,
58-
cardPaddingSmall: `${ space( 4 ) }`,
59-
cardPaddingMedium: `${ space( 4 ) } ${ space( 6 ) }`,
60-
cardPaddingLarge: `${ space( 6 ) } ${ space( 8 ) }`,
6156
elevationXSmall: `0 1px 1px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.02), 0 3px 3px rgba(0, 0, 0, 0.02), 0 4px 4px rgba(0, 0, 0, 0.01)`,
6257
elevationSmall: `0 1px 2px rgba(0, 0, 0, 0.05), 0 2px 3px rgba(0, 0, 0, 0.04), 0 6px 6px rgba(0, 0, 0, 0.03), 0 8px 8px rgba(0, 0, 0, 0.02)`,
6358
elevationMedium: `0 2px 3px rgba(0, 0, 0, 0.05), 0 4px 5px rgba(0, 0, 0, 0.04), 0 12px 12px rgba(0, 0, 0, 0.03), 0 16px 16px rgba(0, 0, 0, 0.02)`,

0 commit comments

Comments
 (0)