-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
styles.ts
165 lines (141 loc) · 3.79 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/**
* External dependencies
*/
import { css } from '@emotion/react';
/**
* Internal dependencies
*/
import { COLORS, CONFIG, boxSizingReset, rtl } from '../utils';
import { space } from '../utils/space';
import { StyledLabel } from '../base-control/styles/base-control-styles';
import {
ValueInput as UnitControlWrapper,
UnitSelect,
} from '../unit-control/styles/unit-control-styles';
import type { Border } from './types';
const focusBoxShadow = css`
box-shadow: inset ${ CONFIG.controlBoxShadowFocus };
`;
export const borderControl = css`
border: 0;
padding: 0;
margin: 0;
${ boxSizingReset }
`;
export const innerWrapper = () => css`
${ UnitControlWrapper } {
flex: 1 1 40%;
}
&& ${ UnitSelect } {
/* Prevent unit select forcing min height larger than its UnitControl */
min-height: 0;
}
`;
/*
* This style is only applied to the UnitControl wrapper when the border width
* field should be a set width. Omitting this allows the UnitControl &
* RangeControl to share the available width in a 40/60 split respectively.
*/
export const wrapperWidth = css`
${ UnitControlWrapper } {
/* Force the UnitControl's set width. */
flex: 0 0 auto;
}
`;
export const wrapperHeight = ( size?: 'default' | '__unstable-large' ) => {
return css`
height: ${ size === '__unstable-large' ? '40px' : '30px' };
`;
};
export const borderControlDropdown = css`
background: #fff;
&& > button {
aspect-ratio: 1;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
${ rtl(
{ borderRadius: `2px 0 0 2px` },
{ borderRadius: `0 2px 2px 0` }
)() }
border: ${ CONFIG.borderWidth } solid ${ COLORS.ui.border };
&:focus,
&:hover:not( :disabled ) {
${ focusBoxShadow }
border-color: ${ COLORS.ui.borderFocus };
z-index: 1;
position: relative;
}
}
`;
export const colorIndicatorBorder = ( border?: Border ) => {
const { color, style } = border || {};
const fallbackColor =
!! style && style !== 'none' ? COLORS.gray[ 300 ] : undefined;
return css`
border-style: ${ style === 'none' ? 'solid' : style };
border-color: ${ color || fallbackColor };
`;
};
export const colorIndicatorWrapper = (
border?: Border,
size?: 'default' | '__unstable-large'
) => {
const { style } = border || {};
return css`
border-radius: ${ CONFIG.radiusFull };
border: 2px solid transparent;
${ style ? colorIndicatorBorder( border ) : undefined }
width: ${ size === '__unstable-large' ? '24px' : '22px' };
height: ${ size === '__unstable-large' ? '24px' : '22px' };
padding: ${ size === '__unstable-large' ? '2px' : '1px' };
/*
* ColorIndicator
*
* The transparent colors used here ensure visibility of the indicator
* over the active state of the border control dropdown's toggle button.
*/
& > span {
height: ${ space( 4 ) };
width: ${ space( 4 ) };
background: linear-gradient(
-45deg,
transparent 48%,
rgb( 0 0 0 / 20% ) 48%,
rgb( 0 0 0 / 20% ) 52%,
transparent 52%
);
}
`;
};
// Must equal $color-palette-circle-size from:
// @wordpress/components/src/circular-option-picker/style.scss
const swatchSize = 28;
const swatchGap = 12;
export const borderControlPopoverControls = css`
width: ${ swatchSize * 6 + swatchGap * 5 }px;
> div:first-of-type > ${ StyledLabel } {
margin-bottom: 0;
}
&& ${ StyledLabel } + button:not( .has-text ) {
min-width: 24px;
padding: 0;
}
`;
export const borderControlPopoverContent = css``;
export const borderColorIndicator = css``;
export const resetButton = css`
justify-content: center;
width: 100%;
/* Override button component styling */
&& {
border-top: ${ CONFIG.borderWidth } solid ${ COLORS.gray[ 400 ] };
border-top-left-radius: 0;
border-top-right-radius: 0;
}
`;
export const borderSlider = () => css`
flex: 1 1 60%;
${ rtl( { marginRight: space( 3 ) } )() }
`;