This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 221
/
Copy pathselect-control-styles.js
97 lines (79 loc) · 1.6 KB
/
select-control-styles.js
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
/**
* External dependencies
*/
import { css } from '@emotion/react';
import styled from '@emotion/styled';
/**
* Internal dependencies
*/
import { COLORS, rtl } from '../../utils';
const disabledStyles = ( { disabled } ) => {
if ( ! disabled ) return '';
return css( {
color: COLORS.ui.textDisabled,
} );
};
const fontSizeStyles = ( { size } ) => {
const sizes = {
default: '13px',
small: '11px',
};
const fontSize = sizes[ size ];
const fontSizeMobile = '16px';
if ( ! fontSize ) return '';
return css`
font-size: ${ fontSizeMobile };
@media ( min-width: 600px ) {
font-size: ${ fontSize };
}
`;
};
const sizeStyles = ( { size } ) => {
const sizes = {
default: {
height: 30,
lineHeight: 1,
minHeight: 30,
},
small: {
height: 24,
lineHeight: 1,
minHeight: 24,
},
};
const style = sizes[ size ] || sizes.default;
return css( style );
};
// TODO: Resolve need to use &&& to increase specificity
// https://github.com/WordPress/gutenberg/issues/18483
export const Select = styled.select`
&&& {
appearance: none;
background: transparent;
box-sizing: border-box;
border: none;
box-shadow: none !important;
color: ${ COLORS.black };
display: block;
margin: 0;
width: 100%;
${ disabledStyles };
${ fontSizeStyles };
${ sizeStyles };
${ rtl( { paddingLeft: 8, paddingRight: 24 } )() }
}
`;
export const DownArrowWrapper = styled.div`
align-items: center;
bottom: 0;
box-sizing: border-box;
display: flex;
padding: 0 4px;
pointer-events: none;
position: absolute;
top: 0;
${ rtl( { right: 0 } )() }
svg {
display: block;
}
`;