-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcreateCardStyle.ts
More file actions
53 lines (47 loc) · 1.38 KB
/
createCardStyle.ts
File metadata and controls
53 lines (47 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { css } from '@emotion/react';
import { hexToRgba, getColorByToken } from '@jdesignlab/theme';
import type { ColorToken } from '@jdesignlab/theme';
import type { Size, Variant } from '../types';
const createCardStyle = (size: Size, variant: Variant, backgroundColor: ColorToken, borderColor: ColorToken) => {
const hexBorderColor = getColorByToken(borderColor);
const baseStyle = css({
boxSizing: 'border-box',
padding: '12px 24px'
});
const variantStyle = () => {
switch (variant) {
case 'filled':
return css({
boxSizing: 'border-box',
boxShadow: 'none',
backgroundColor: `${getColorByToken(backgroundColor)}`
});
case 'outlined':
return css({ boxSizing: 'border-box', border: `1px solid ${hexBorderColor}` });
default:
return css({
boxSizing: 'border-box',
boxShadow: `0 3px 6px ${hexToRgba(hexBorderColor, 0.16)}, 0 3px 6px ${hexToRgba(hexBorderColor, 0.2)}`
});
}
};
const sizeStyle = () => {
switch (size) {
case 'lg':
return css({
maxWidth: '720px'
});
case 'sm':
return css({
maxWidth: '200px'
});
//medium
default:
return css({
maxWidth: '440px'
});
}
};
return [baseStyle, variantStyle(), sizeStyle()];
};
export default createCardStyle;