-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
styles.ts
116 lines (97 loc) · 2.54 KB
/
styles.ts
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
* External dependencies
*/
import { css } from '@emotion/react';
/**
* Internal dependencies
*/
import { CONFIG, COLORS, font } from '../utils';
export const unstyledButton = ( as: 'a' | 'button' ) => {
return css`
font-size: ${ font( 'default.fontSize' ) };
font-family: inherit;
appearance: none;
border: 1px solid transparent;
cursor: pointer;
background: none;
text-align: start;
text-decoration: ${ as === 'a' ? 'none' : undefined };
svg,
path {
fill: currentColor;
}
&:hover {
color: ${ COLORS.theme.accent };
}
&:focus {
box-shadow: none;
outline: none;
}
&:focus-visible {
box-shadow: 0 0 0 var( --wp-admin-border-width-focus )
${ COLORS.theme.accent };
// Windows high contrast mode.
outline: 2px solid transparent;
outline-offset: 0;
}
`;
};
export const itemWrapper = css`
width: 100%;
display: block;
`;
export const item = css`
box-sizing: border-box;
width: 100%;
display: block;
margin: 0;
color: inherit;
`;
export const bordered = css`
border: 1px solid ${ CONFIG.surfaceBorderColor };
`;
export const separated = css`
> *:not( marquee ) > * {
border-bottom: 1px solid ${ CONFIG.surfaceBorderColor };
}
> *:last-of-type > *:not( :focus ) {
border-bottom-color: transparent;
}
`;
const borderRadius = CONFIG.radiusSmall;
export const spacedAround = css`
border-radius: ${ borderRadius };
`;
export const rounded = css`
border-radius: ${ borderRadius };
> *:first-of-type > * {
border-top-left-radius: ${ borderRadius };
border-top-right-radius: ${ borderRadius };
}
> *:last-of-type > * {
border-bottom-left-radius: ${ borderRadius };
border-bottom-right-radius: ${ borderRadius };
}
`;
const baseFontHeight = `calc(${ CONFIG.fontSize } * ${ CONFIG.fontLineHeightBase })`;
/*
* Math:
* - Use the desired height as the base value
* - Subtract the computed height of (default) text
* - Subtract the effects of border
* - Divide the calculated number by 2, in order to get an individual top/bottom padding
*/
const paddingY = `calc((${ CONFIG.controlHeight } - ${ baseFontHeight } - 2px) / 2)`;
const paddingYSmall = `calc((${ CONFIG.controlHeightSmall } - ${ baseFontHeight } - 2px) / 2)`;
const paddingYLarge = `calc((${ CONFIG.controlHeightLarge } - ${ baseFontHeight } - 2px) / 2)`;
export const itemSizes = {
small: css`
padding: ${ paddingYSmall } ${ CONFIG.controlPaddingXSmall }px;
`,
medium: css`
padding: ${ paddingY } ${ CONFIG.controlPaddingX }px;
`,
large: css`
padding: ${ paddingYLarge } ${ CONFIG.controlPaddingXLarge }px;
`,
};