UNPKG

5.24 kBJavaScriptView Raw
1import { keys } from 'ramda';
2import camelcase from 'camelcase';
3import styledMQ from '../mq';
4
5// -----------------------------------------------------------------------------
6// Values
7// -----------------------------------------------------------------------------
8
9export const junkValuesNotNull = [undefined, NaN, '', [], {}];
10export const junkValuesNotUndefined = [null, NaN, '', [], {}];
11export const junkValues = [null, ...junkValuesNotNull];
12export const booleanValues = [true, false];
13export const invalidValues = [...junkValues, ...booleanValues];
14export const invalidValuesNotNull = [...junkValuesNotNull, ...booleanValues];
15export const invalidValuesNotUndefined = [
16 ...junkValuesNotUndefined,
17 ...booleanValues,
18];
19export const genericStrings = ['xxxx'];
20export const genericPositiveIntegers = [78, 4999];
21export const genericPositiveIntegersIncludingZero = [
22 0,
23 ...genericPositiveIntegers,
24];
25export const genericNegativeIntegers = [-90, -6];
26export const genericNegativeIntegersIncludingZero = [
27 0,
28 ...genericNegativeIntegers,
29];
30export const genericPositiveDecimals = [0.6, 44.7];
31export const genericPositiveDecimalsIncludingZero = [
32 0,
33 ...genericPositiveDecimals,
34];
35export const genericNegativeDecimals = [-99.8, -0.4];
36export const genericNegativeDecimalsIncludingZero = [
37 0,
38 ...genericNegativeDecimals,
39];
40export const genericDecimals = [-99.8, -0.4, 0.6, 44.7];
41export const genericNegativeNumbers = [
42 ...genericNegativeDecimals,
43 ...genericNegativeIntegers,
44];
45export const genericPositiveNumbers = [
46 ...genericPositiveDecimals,
47 ...genericPositiveIntegers,
48];
49
50export const genericNegativeNumbersIncludingZero = [
51 0,
52 ...genericNegativeDecimals,
53 ...genericNegativeIntegers,
54];
55
56export const genericPositiveNumbersIncludingZero = [
57 0,
58 ...genericPositiveDecimalsIncludingZero,
59 ...genericPositiveIntegersIncludingZero,
60];
61export const positiveRemValues = ['163rem', '555rem'];
62export const positiveEmValues = ['163em', '555em'];
63export const positivePixelValues = ['163px', '555px'];
64export const positiveDimensionValues = [
65 ...positiveEmValues,
66 ...positiveRemValues,
67 ...positivePixelValues,
68];
69export const negativeRemValuesOrZero = ['0rem', '-163rem', '-555rem'];
70export const negativeEmValuesOrZero = ['0em', '-163em', '-555em'];
71export const negativePixelValuesOrZero = ['0px', '-163px', '-555px'];
72export const negativeDimensionValuesOrZero = [
73 ...negativeEmValuesOrZero,
74 ...negativeRemValuesOrZero,
75 ...negativePixelValuesOrZero,
76];
77export const positiveResolutionValues = ['111dpi', '56dpi'];
78export const negativeResolutionValuesIncludingZero = [
79 '0dpi',
80 '-163dpi',
81 '-555dpi',
82];
83export const genericAspectRatioValues = [
84 '16/9',
85 '1/1',
86 '6/4',
87 '16 / 9',
88 '1 / 1',
89 '6 / 4',
90];
91export const invalidAspectRatioValues = [
92 '0/9',
93 '1/0',
94 '0/0',
95 '-16/9',
96 '1/-1',
97 '-6/-',
98];
99
100export const genericResolutionValues = [
101 ...positiveResolutionValues,
102 ...negativeResolutionValuesIncludingZero,
103];
104
105export const genericNumbers = [
106 ...genericDecimals,
107 ...genericNegativeIntegers,
108 ...genericPositiveIntegersIncludingZero,
109];
110
111export const genericValues = [
112 ...invalidValues,
113 ...genericStrings,
114 ...genericNumbers,
115];
116
117export const genericValuesNotNull = [
118 ...invalidValuesNotNull,
119 ...genericStrings,
120 ...genericNumbers,
121];
122
123// -----------------------------------------------------------------------------
124// Breakpoint Sets
125// -----------------------------------------------------------------------------
126
127export const validDimensionBreakpoints = {
128 small: 400,
129 medium: '900px',
130 large: '68.75rem',
131 xLarge: '81.25em',
132};
133
134export const validResolutionBreakpoints = {
135 small: 72,
136 medium: '150dpi',
137 large: 300,
138 xLarge: '600dpi',
139};
140
141export const validAspectRatioBreakpoints = {
142 small: '2/3',
143 medium: '1/1',
144 large: '3/2',
145 xLarge: '16/9',
146};
147
148export const validColorBreakpoints = {
149 small: 1,
150 medium: 4,
151 large: 5,
152 xLarge: 6,
153};
154
155export const validMonochromeBreakpoints = {
156 small: 0,
157 medium: 4,
158 large: 8,
159 xLarge: 16,
160};
161
162export const validBreakpointSets = {
163 width: validDimensionBreakpoints,
164 height: validDimensionBreakpoints,
165 resolution: validResolutionBreakpoints,
166 aspectRatio: validAspectRatioBreakpoints,
167 color: validColorBreakpoints,
168 colorIndex: validColorBreakpoints,
169 monochrome: validMonochromeBreakpoints,
170};
171
172// -----------------------------------------------------------------------------
173// Breakpoint Sets
174// -----------------------------------------------------------------------------
175
176export const validBreakpointsForRange = name => {
177 const camelisedName = camelcase(name);
178 const o = {};
179 o[camelisedName] = validBreakpointSets[camelisedName];
180 return o;
181};
182
183export const mqWithValidBreakpointsForRange = (name, config = {}) =>
184 styledMQ.configure(validBreakpointsForRange(name), config);
185
186export const validBreakpointKeysForRange = name => {
187 const camelisedName = camelcase(name);
188 return keys(validBreakpointsForRange(name)[camelisedName]);
189};
190
191export const mqWithTweakedBreakpointsForRange = name =>
192 styledMQ
193 .configure(validBreakpointsForRange(name))
194 .tweak({ width: { alpha: 300 } });
195
196export const mqWithNoBreakpoints = () => styledMQ.configure();