|
1 | 1 | /* eslint-disable react/destructuring-assignment */ |
2 | 2 | import PropTypes from 'prop-types' |
3 | 3 |
|
4 | | -export const propTypes = { |
5 | | - absolute: PropTypes.bool, |
6 | | - align: PropTypes.string, |
7 | | - appearance: PropTypes.oneOf(['none']), |
| 4 | +const display = { |
8 | 5 | block: PropTypes.bool, |
9 | | - bg: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), |
10 | | - border: PropTypes.oneOfType([ |
11 | | - PropTypes.string, |
| 6 | + hidden: PropTypes.bool, |
| 7 | + inlineBlock: PropTypes.bool, |
| 8 | + table: PropTypes.bool, |
| 9 | + tableCell: PropTypes.bool, |
| 10 | + tableRow: PropTypes.bool, |
| 11 | +} |
| 12 | + |
| 13 | +const floats = { |
| 14 | + clearfix: PropTypes.bool, |
| 15 | + float: PropTypes.oneOf(['none', 'right', 'left']), |
| 16 | +} |
| 17 | + |
| 18 | +const overflow = { |
| 19 | + overflow: PropTypes.oneOf(['hidden', 'auto', 'scroll']), |
| 20 | + overflowX: PropTypes.oneOf(['hidden', 'auto', 'scroll']), |
| 21 | + overflowY: PropTypes.oneOf(['hidden', 'auto', 'scroll']), |
| 22 | +} |
| 23 | + |
| 24 | +const position = { |
| 25 | + absolute: PropTypes.bool, |
| 26 | + fixed: PropTypes.bool, |
| 27 | + pin: PropTypes.oneOfType([ |
12 | 28 | PropTypes.bool, |
| 29 | + PropTypes.oneOf(['t', 'r', 'b', 'l', 'y', 'x', 'none']), |
13 | 30 | PropTypes.array, |
14 | 31 | ]), |
| 32 | + relative: PropTypes.bool, |
| 33 | + static: PropTypes.bool, |
| 34 | +} |
| 35 | + |
| 36 | +const zIndex = { |
| 37 | + z: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), |
| 38 | +} |
| 39 | + |
| 40 | +const typography = { |
| 41 | + align: PropTypes.string, |
15 | 42 | break: PropTypes.oneOf(['words', 'normal']), |
16 | 43 | capitalize: PropTypes.bool, |
17 | | - content: PropTypes.string, |
18 | | - flex: PropTypes.oneOfType([ |
19 | | - PropTypes.string, |
20 | | - PropTypes.bool, |
21 | | - PropTypes.number, |
22 | | - PropTypes.array, |
23 | | - ]), |
24 | 44 | font: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), |
25 | | - h: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
26 | | - hidden: PropTypes.bool, |
27 | | - inlineBlock: PropTypes.bool, |
28 | | - inlineFlex: PropTypes.bool, |
29 | 45 | italic: PropTypes.bool, |
30 | | - items: PropTypes.string, |
31 | | - justify: PropTypes.string, |
| 46 | + text: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), |
| 47 | + tracking: PropTypes.string, |
32 | 48 | leading: PropTypes.string, |
33 | 49 | lineThrough: PropTypes.bool, |
34 | 50 | lowercase: PropTypes.bool, |
| 51 | + normalCase: PropTypes.bool, |
| 52 | + noUnderline: PropTypes.bool, |
| 53 | + roman: PropTypes.bool, |
| 54 | + truncate: PropTypes.bool, |
| 55 | + underline: PropTypes.bool, |
| 56 | + uppercase: PropTypes.bool, |
| 57 | + whitespace: PropTypes.oneOf([ |
| 58 | + 'normal', |
| 59 | + 'no-wrap', |
| 60 | + 'pre', |
| 61 | + 'pre-line', |
| 62 | + 'pre-wrap', |
| 63 | + ]), |
| 64 | +} |
| 65 | + |
| 66 | +const backgrounds = { |
| 67 | + bg: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), |
| 68 | +} |
| 69 | + |
| 70 | +const borders = { |
| 71 | + border: PropTypes.oneOfType([ |
| 72 | + PropTypes.string, |
| 73 | + PropTypes.bool, |
| 74 | + PropTypes.array, |
| 75 | + ]), |
| 76 | + borderB: PropTypes.number, |
| 77 | + borderL: PropTypes.number, |
| 78 | + borderR: PropTypes.number, |
| 79 | + borderT: PropTypes.number, |
| 80 | + rounded: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), |
| 81 | + roundedB: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), |
| 82 | + roundedBl: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), |
| 83 | + roundedBr: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), |
| 84 | + roundedL: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), |
| 85 | + roundedR: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), |
| 86 | + roundedT: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), |
| 87 | + roundedTl: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), |
| 88 | + roundedTr: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), |
| 89 | +} |
| 90 | + |
| 91 | +const flexValues = [ |
| 92 | + true, |
| 93 | + 'row', |
| 94 | + 'row-reverse', |
| 95 | + 'col', |
| 96 | + 'col-reverse', |
| 97 | + 'no-wrap', |
| 98 | + 'wrap', |
| 99 | + 'wrap-reverse', |
| 100 | + 'initial', |
| 101 | + 1, |
| 102 | + 'auto', |
| 103 | + 'none', |
| 104 | + 'grow', |
| 105 | + 'shrink', |
| 106 | + 'no-grow', |
| 107 | + 'no-shrink', |
| 108 | +] |
| 109 | + |
| 110 | +const flexAlignment = ['start', 'center', 'end'] |
| 111 | + |
| 112 | +const flex = { |
| 113 | + content: PropTypes.oneOf([...flexAlignment, 'between', 'around']), |
| 114 | + flex: PropTypes.oneOfType([ |
| 115 | + PropTypes.oneOf(flexValues), |
| 116 | + PropTypes.arrayOf(PropTypes.oneOf(flexValues)), |
| 117 | + ]), |
| 118 | + inlineFlex: PropTypes.bool, |
| 119 | + items: PropTypes.oneOf([...flexAlignment, 'stretch', 'baseline']), |
| 120 | + self: PropTypes.oneOf([...flexAlignment, 'auto', 'stretch']), |
| 121 | + justify: PropTypes.oneOf([...flexAlignment, 'between', 'around']), |
| 122 | +} |
| 123 | + |
| 124 | +const spacingShape = { |
| 125 | + t: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
| 126 | + r: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
| 127 | + b: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
| 128 | + l: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
| 129 | + x: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
| 130 | + y: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
| 131 | +} |
| 132 | + |
| 133 | +const spacing = { |
35 | 134 | m: PropTypes.oneOfType([ |
36 | 135 | PropTypes.string, |
37 | 136 | PropTypes.number, |
38 | | - PropTypes.object, |
| 137 | + PropTypes.shape(spacingShape), |
39 | 138 | ]), |
40 | | - maxH: PropTypes.string, |
41 | | - maxW: PropTypes.string, |
42 | 139 | nm: PropTypes.oneOfType([ |
43 | 140 | PropTypes.string, |
44 | 141 | PropTypes.number, |
45 | | - PropTypes.object, |
| 142 | + PropTypes.shape(spacingShape), |
46 | 143 | ]), |
47 | | - normalCase: PropTypes.bool, |
48 | | - noUnderline: PropTypes.bool, |
49 | | - opacity: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
50 | | - outline: PropTypes.oneOf(['none']), |
51 | | - overflow: PropTypes.string, |
52 | 144 | p: PropTypes.oneOfType([ |
53 | 145 | PropTypes.string, |
54 | 146 | PropTypes.number, |
55 | | - PropTypes.object, |
56 | | - ]), |
57 | | - pin: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), |
58 | | - resize: PropTypes.oneOfType([ |
59 | | - PropTypes.oneOf(['none', 'y', 'x']), |
60 | | - PropTypes.bool, |
61 | | - ]), |
62 | | - roman: PropTypes.bool, |
63 | | - rounded: PropTypes.oneOfType([ |
64 | | - PropTypes.string, |
65 | | - PropTypes.bool, |
66 | | - PropTypes.array, |
67 | | - ]), |
68 | | - select: PropTypes.oneOf(['none', 'text']), |
69 | | - self: PropTypes.oneOfType([PropTypes.string]), |
70 | | - shadow: PropTypes.oneOfType([ |
71 | | - PropTypes.string, |
72 | | - PropTypes.bool, |
73 | | - PropTypes.array, |
| 147 | + PropTypes.shape(spacingShape), |
74 | 148 | ]), |
75 | | - text: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), |
76 | | - tracking: PropTypes.string, |
77 | | - truncate: PropTypes.bool, |
78 | | - underline: PropTypes.bool, |
79 | | - uppercase: PropTypes.bool, |
| 149 | +} |
| 150 | + |
| 151 | +const sizing = { |
| 152 | + h: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
| 153 | + maxH: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
| 154 | + minH: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
| 155 | + maxW: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
| 156 | + minW: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
| 157 | + w: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
| 158 | +} |
| 159 | + |
| 160 | +const misc = { |
| 161 | + opacity: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
| 162 | + shadow: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), |
| 163 | +} |
| 164 | + |
| 165 | +const plugins = { |
80 | 166 | visuallyHidden: PropTypes.bool, |
81 | 167 | visuallyHiddenFocusable: PropTypes.bool, |
82 | | - w: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
83 | | - whitespace: PropTypes.string, |
| 168 | +} |
| 169 | + |
| 170 | +export const propTypes = { |
| 171 | + ...display, |
| 172 | + ...floats, |
| 173 | + ...overflow, |
| 174 | + ...position, |
| 175 | + ...zIndex, |
| 176 | + ...typography, |
| 177 | + ...backgrounds, |
| 178 | + ...borders, |
| 179 | + ...flex, |
| 180 | + ...spacing, |
| 181 | + ...sizing, |
| 182 | + ...misc, |
| 183 | + ...plugins, |
84 | 184 | } |
85 | 185 |
|
86 | 186 | export const variants = ['hover', 'focus', 'hocus', 'sm', 'md', 'lg', 'xl'] |
|
0 commit comments