react-responsive-tools 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +13 -0
- package/README.MD +498 -0
- package/declarations.d.ts +5 -0
- package/index.ts +1 -0
- package/package.json +74 -0
- package/src/breakpoints.configs.js +25 -0
- package/src/components/horizontal.tsx +28 -0
- package/src/hooks/horizontal/useBreakpoint.test.ts +56 -0
- package/src/hooks/horizontal/useBreakpoint.ts +20 -0
- package/src/hooks/horizontal/useBreakpoints.ts +30 -0
- package/src/hooks/useVariant.ts +5 -0
- package/src/hooks/vertical/useVBreakpoint.ts +20 -0
- package/src/hooks/vertical/useVBreakpoints.ts +26 -0
- package/src/index.scss +4 -0
- package/src/index.ts +19 -0
- package/src/interfaces/TAdaptiveVariant.ts +1 -0
- package/src/interfaces/TBreakpoint.ts +21 -0
- package/src/interfaces/TBreakpoints.ts +9 -0
- package/src/reset.scss +99 -0
- package/src/scss/_data.scss +24 -0
- package/src/scss/_horizontal.export.scss +14 -0
- package/src/scss/_horizontal.scss +118 -0
- package/src/scss/_vertical.export.scss +10 -0
- package/src/scss/_vertical.scss +76 -0
- package/src/scss/index.scss +4 -0
package/LICENSE.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2023, NIKOLAY CHERNEY <westprophet@gmail.com>
|
2
|
+
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.MD
ADDED
@@ -0,0 +1,498 @@
|
|
1
|
+
# react-adaptable-scss: Adaptive SCSS Tools
|
2
|
+
|
3
|
+
This project provides tools and configurations to simplify writing adaptive code for both vertical and horizontal layouts.
|
4
|
+
|
5
|
+
## Project Structure
|
6
|
+
|
7
|
+
The project includes the `scss` directory with the following files:
|
8
|
+
- `_data.scss`: Contains breakpoints.
|
9
|
+
- `_horizontal.scss` and `_vertical.scss`: Provide mixins for horizontal and vertical layouts, respectively.
|
10
|
+
- `_screen.scss`: An intermediate file for JS export.
|
11
|
+
- `_export.module.scss`: A file meant for explicit JS export.
|
12
|
+
|
13
|
+
The `hooks` directory includes:
|
14
|
+
- `useBreakpoint.ts`: Implements the `useBreakpoint` hook for identifying the current breakpoint.
|
15
|
+
- `useBreakpoints.ts`: Implements the `useBreakpoints` hook for retrieving the list of currently active breakpoints.
|
16
|
+
- `useVBreakpoint.ts`: Implements the `useVBreakpoint` hook for identifying the current vertical breakpoint.
|
17
|
+
- `useVBreakpoints.ts`: Implements the `useVBreakpoints` hook for retrieving the list of currently active vertical breakpoints.
|
18
|
+
|
19
|
+
The `components` directory includes:
|
20
|
+
- `ForMF.ts`: A utility component that takes breakpoint size and children as props. It uses the `useBreakpointMF` hook to determine if the display size matches the given breakpoint. If so, it renders the children; otherwise, it renders `null`.
|
21
|
+
- `ForDF.ts`: Similar to `ForMF`, but uses the `useBreakpointDF` hook.
|
22
|
+
|
23
|
+
## Breakpoints
|
24
|
+
|
25
|
+
We use a set of fixed variables for different screen sizes: `xs`, `sm`, `md`, `lg`, `xl`, `xxl`, and `xxxl`.
|
26
|
+
|
27
|
+
## Mixins Application
|
28
|
+
|
29
|
+
Mixins are bundled with the `include` decorator, providing descriptive statements for breakpoints based on them.
|
30
|
+
|
31
|
+
## Hooks
|
32
|
+
|
33
|
+
The project incorporates the following hooks based on `react-responsive` for use in React.js:# react-adaptable-scss: Adaptive SCSS Tools
|
34
|
+
|
35
|
+
This project provides tools and configurations to simplify writing adaptive code for both vertical and horizontal layouts.
|
36
|
+
|
37
|
+
## Project Structure
|
38
|
+
|
39
|
+
The project includes the `scss` directory with the following files:
|
40
|
+
- `_data.scss`: Contains breakpoints.
|
41
|
+
- `_horizontal.scss` and `_vertical.scss`: Provide mixins for horizontal and vertical layouts, respectively.
|
42
|
+
- `_screen.scss`: An intermediate file for JS export.
|
43
|
+
- `_export.module.scss`: A file meant for explicit JS export.
|
44
|
+
|
45
|
+
The `hooks` directory includes:
|
46
|
+
- `useBreakpoint.ts`: Implements the `useBreakpoint` hook for identifying the current breakpoint.
|
47
|
+
- `useBreakpoints.ts`: Implements the `useBreakpoints` hook for retrieving the list of currently active breakpoints.
|
48
|
+
- `useVBreakpoint.ts`: Implements the `useVBreakpoint` hook for identifying the current vertical breakpoint.
|
49
|
+
- `useVBreakpoints.ts`: Implements the `useVBreakpoints` hook for retrieving the list of currently active vertical breakpoints.
|
50
|
+
|
51
|
+
The `components` directory includes:
|
52
|
+
- `ForMF.ts`: A utility component that takes breakpoint size and children as props. It uses the `useBreakpointMF` hook to determine if the display size matches the given breakpoint. If so, it renders the children; otherwise, it renders `null`.
|
53
|
+
- `ForDF.ts`: Similar to `ForMF`, but uses the `useBreakpointDF` hook.
|
54
|
+
|
55
|
+
## Breakpoints
|
56
|
+
|
57
|
+
We use a set of fixed variables for different screen sizes.
|
58
|
+
|
59
|
+
### Horizontal Breakpoints (default):
|
60
|
+
|
61
|
+
```ecmascript 6
|
62
|
+
const horizontalBreakpoints = {
|
63
|
+
xs: '320px',
|
64
|
+
sm: '576px',
|
65
|
+
md: '768px',
|
66
|
+
lg: '992px',
|
67
|
+
lt: '1024px',
|
68
|
+
ltm: '1200px',
|
69
|
+
ltl: '1440px',
|
70
|
+
xl: '1920px',
|
71
|
+
xxl: '2560px',
|
72
|
+
qxl: '3840px',
|
73
|
+
};
|
74
|
+
```
|
75
|
+
|
76
|
+
### Vertical Breakpoints (default):
|
77
|
+
|
78
|
+
```ecmascript 6
|
79
|
+
const verticalBreakpoints = {
|
80
|
+
xs: '600px',
|
81
|
+
sm: '800px',
|
82
|
+
md: '1000px',
|
83
|
+
lg: '1200px',
|
84
|
+
xl: '1600px',
|
85
|
+
xxl: '1601px',
|
86
|
+
};
|
87
|
+
```
|
88
|
+
|
89
|
+
## Mixins Application
|
90
|
+
|
91
|
+
Mixins are bundled with the `include` decorator, providing descriptive statements for breakpoints based on them.
|
92
|
+
|
93
|
+
## Hooks
|
94
|
+
|
95
|
+
The project incorporates the following hooks based on `react-responsive` for use in React.js:
|
96
|
+
- `useBreakpoints`: Retrieve current screen breakpoints.
|
97
|
+
- `useBreakpoint`: Retrieve the current breakpoint.
|
98
|
+
|
99
|
+
## Components
|
100
|
+
|
101
|
+
The project includes utility components to display content only at certain breakpoints.
|
102
|
+
|
103
|
+
## Future Growth Perspectives
|
104
|
+
|
105
|
+
We aim to add the following functionalities:
|
106
|
+
- Redefining SCSS variables.
|
107
|
+
- Configuring breakpoint names.
|
108
|
+
- Separate breakpoint configurations for vertical layout.
|
109
|
+
- Integration with the external library `react-responsive# react-adaptable-scss: Adaptive SCSS Tools
|
110
|
+
|
111
|
+
This project provides tools and configurations to simplify writing adaptive code for both vertical and horizontal layouts.
|
112
|
+
|
113
|
+
## Project Structure
|
114
|
+
|
115
|
+
The project includes the `scss` directory with the following files:
|
116
|
+
- `_data.scss`: Contains breakpoints.
|
117
|
+
- `_horizontal.scss` and `_vertical.scss`: Provide mixins for horizontal and vertical layouts, respectively.
|
118
|
+
- `_screen.scss`: An intermediate file for JS export.
|
119
|
+
- `_export.module.scss`: A file meant for explicit JS export.
|
120
|
+
|
121
|
+
The `hooks` directory includes:
|
122
|
+
- `useBreakpoint.ts`: Implements the `useBreakpoint` hook for identifying the current breakpoint.
|
123
|
+
- `useBreakpoints.ts`: Implements the `useBreakpoints` hook for retrieving the list of currently active breakpoints.
|
124
|
+
- `useVBreakpoint.ts`: Implements the `useVBreakpoint` hook for identifying the current vertical breakpoint.
|
125
|
+
- `useVBreakpoints.ts`: Implements the `useVBreakpoints` hook for retrieving the list of currently active vertical breakpoints.
|
126
|
+
|
127
|
+
The `components` directory includes:
|
128
|
+
- `ForMF.ts`: A utility component that takes breakpoint size and children as props. It uses the `useBreakpointMF` hook to determine if the display size matches the given breakpoint. If so, it renders the children; otherwise, it renders `null`.
|
129
|
+
- `ForDF.ts`: Similar to `ForMF`, but uses the `useBreakpointDF` hook.
|
130
|
+
|
131
|
+
## Breakpoints
|
132
|
+
|
133
|
+
We use a set of fixed variables for different screen sizes.
|
134
|
+
|
135
|
+
### Horizontal Breakpoints (default):
|
136
|
+
|
137
|
+
```typescript
|
138
|
+
const horizontalBreakpoints = {
|
139
|
+
xs: '320px',
|
140
|
+
sm: '576px',
|
141
|
+
md: '768px',
|
142
|
+
lg: '992px',
|
143
|
+
lt: '1024px',
|
144
|
+
ltm: '1200px',
|
145
|
+
ltl: '1440px',
|
146
|
+
xl: '1920px',
|
147
|
+
xxl: '2560px',
|
148
|
+
qxl: '3840px',
|
149
|
+
};
|
150
|
+
```
|
151
|
+
|
152
|
+
### Vertical Breakpoints (default):
|
153
|
+
|
154
|
+
```typescript
|
155
|
+
const verticalBreakpoints = {
|
156
|
+
xs: '600px',
|
157
|
+
sm: '800px',
|
158
|
+
md: '1000px',
|
159
|
+
lg: '1200px',
|
160
|
+
xl: '1600px',
|
161
|
+
xxl: '1601px',
|
162
|
+
};
|
163
|
+
```
|
164
|
+
|
165
|
+
## Mixins Application
|
166
|
+
|
167
|
+
Mixins are bundled with the `include` decorator, providing descriptive statements for breakpoints based on them.
|
168
|
+
|
169
|
+
## Hooks
|
170
|
+
|
171
|
+
The project incorporates the following hooks based on `react-responsive` for use in React.js:
|
172
|
+
- `useBreakpoints`: Retrieve current screen breakpoints.
|
173
|
+
- `useBreakpoint`: Retrieve the current breakpoint.
|
174
|
+
- `useBreakpointMF`: Retrieve the current breakpoint for "MtF" variant.
|
175
|
+
- `useBreakpointDF`: Retrieve the current breakpoint for "MtF" variant.
|
176
|
+
|
177
|
+
### Hook Implementations
|
178
|
+
|
179
|
+
#### useBreakpoint Hook:
|
180
|
+
|
181
|
+
```typescript
|
182
|
+
import { useMediaQuery } from 'react-responsive';
|
183
|
+
import breakpoints from '../../scss/_horizontal.export.scss';
|
184
|
+
import { TBreakpoint } from '../../interfaces/TBreakpoint';
|
185
|
+
import { TAdaptiveVariant } from '../../interfaces/TAdaptiveVariant';
|
186
|
+
import useVariant from '../useVariant';
|
187
|
+
|
188
|
+
export default function useBreakpoint(b: TBreakpoint, variant: TAdaptiveVariant = 'MtF') {
|
189
|
+
const p = breakpoints[b];
|
190
|
+
const v = useVariant(variant);
|
191
|
+
return useMediaQuery({ query: `(${v}-width: ${p}px)` });
|
192
|
+
}
|
193
|
+
|
194
|
+
export function useBreakpointMF(b: TBreakpoint) {
|
195
|
+
return useBreakpoint(b, 'MtF');
|
196
|
+
}
|
197
|
+
|
198
|
+
export function useBreakpointDF(b: TBreakpoint) {
|
199
|
+
return useBreakpoint(b, 'DtF');
|
200
|
+
}
|
201
|
+
```
|
202
|
+
|
203
|
+
### Usage Examples:
|
204
|
+
|
205
|
+
#### useBreakpoint Hook:
|
206
|
+
|
207
|
+
```typescript
|
208
|
+
import useBreakpoint from './hooks/useBreakpoint';
|
209
|
+
|
210
|
+
const MyComponent = () => {
|
211
|
+
const isMedium = useBreakpoint('md');
|
212
|
+
|
213
|
+
return (
|
214
|
+
<div>
|
215
|
+
{isMedium && <p>The current breakpoint is Medium (md)</p>}
|
216
|
+
</div>
|
217
|
+
);
|
218
|
+
};
|
219
|
+
```
|
220
|
+
|
221
|
+
#### useBreakpoints Hook:
|
222
|
+
|
223
|
+
```typescript
|
224
|
+
import { useBreakpoints } from './hooks/useBreakpoints';
|
225
|
+
|
226
|
+
const MyComponent = () => {
|
227
|
+
const breakpoints = useBreakpoints();
|
228
|
+
|
229
|
+
return (
|
230
|
+
<div>
|
231
|
+
{breakpoints.includes('lg') && <p>The Large (lg) breakpoint is active</p>}
|
232
|
+
</div>
|
233
|
+
);
|
234
|
+
};
|
235
|
+
```
|
236
|
+
|
237
|
+
#### useBreakpointMF Hook:
|
238
|
+
|
239
|
+
```typescript
|
240
|
+
import { useBreakpointMF } from './hooks/useBreakpoint';
|
241
|
+
|
242
|
+
const MyComponent = () => {
|
243
|
+
const isMedium = useBreakpointMF('md');
|
244
|
+
|
245
|
+
return (
|
246
|
+
<div>
|
247
|
+
{isMedium && <p>The current breakpoint is Medium (md) for Mobile First</p>}
|
248
|
+
</div>
|
249
|
+
);
|
250
|
+
};
|
251
|
+
```
|
252
|
+
|
253
|
+
#### useBreakpointDF Hook:
|
254
|
+
|
255
|
+
```typescript
|
256
|
+
import { useBreakpointDF } from './hooks/useBreakpoint';
|
257
|
+
|
258
|
+
const MyComponent = () => {
|
259
|
+
const isLarge = useBreakpointDF('lg');
|
260
|
+
|
261
|
+
return (
|
262
|
+
<div>
|
263
|
+
{isLarge && <p>The current breakpoint is Large (lg) for Desktop First</p>}
|
264
|
+
</div>
|
265
|
+
);
|
266
|
+
};
|
267
|
+
```
|
268
|
+
|
269
|
+
## Components
|
270
|
+
|
271
|
+
The project includes utility components to display content only at certain breakpoints.
|
272
|
+
|
273
|
+
### Usage Examples:
|
274
|
+
|
275
|
+
#### ForMF Component:
|
276
|
+
|
277
|
+
```typescript
|
278
|
+
import { ForMF } from './components/ForMF';
|
279
|
+
|
280
|
+
const MyComponent = () => (
|
281
|
+
<ForMF bp='md'>
|
282
|
+
<p>This content is only visible at the Medium (md) breakpoint</p>
|
283
|
+
</ForMF>
|
284
|
+
);
|
285
|
+
```
|
286
|
+
# react-adaptable-scss: Adaptive SCSS Tools
|
287
|
+
|
288
|
+
This project provides tools and configurations to simplify writing adaptive code for both vertical and horizontal layouts.
|
289
|
+
|
290
|
+
## Project Structure
|
291
|
+
|
292
|
+
The project includes the `scss` directory with the following files:
|
293
|
+
- `_data.scss`: Contains breakpoints.
|
294
|
+
- `_horizontal.scss` and `_vertical.scss`: Provide mixins for horizontal and vertical layouts, respectively.
|
295
|
+
- `_screen.scss`: An intermediate file for JS export.
|
296
|
+
- `_export.module.scss`: A file meant for explicit JS export.
|
297
|
+
|
298
|
+
The `hooks` directory includes:
|
299
|
+
- `useBreakpoint.ts`: Implements the `useBreakpoint` hook for identifying the current breakpoint.
|
300
|
+
- `useBreakpoints.ts`: Implements the `useBreakpoints` hook for retrieving the list of currently active breakpoints.
|
301
|
+
- `useVBreakpoint.ts`: Implements the `useVBreakpoint` hook for identifying the current vertical breakpoint.
|
302
|
+
- `useVBreakpoints.ts`: Implements the `useVBreakpoints` hook for retrieving the list of currently active vertical breakpoints.
|
303
|
+
|
304
|
+
The `components` directory includes:
|
305
|
+
- `ForMF.ts`: A utility component that takes breakpoint size and children as props. It uses the `useBreakpointMF` hook to determine if the display size matches the given breakpoint. If so, it renders the children; otherwise, it renders `null`.
|
306
|
+
- `ForDF.ts`: Similar to `ForMF`, but uses the `useBreakpointDF` hook.
|
307
|
+
|
308
|
+
## Breakpoints
|
309
|
+
|
310
|
+
We use a set of fixed variables for different screen sizes.
|
311
|
+
|
312
|
+
### Horizontal Breakpoints (default):
|
313
|
+
|
314
|
+
```typescript
|
315
|
+
const horizontalBreakpoints = {
|
316
|
+
xs: '320px',
|
317
|
+
sm: '576px',
|
318
|
+
md: '768px',
|
319
|
+
lg: '992px',
|
320
|
+
lt: '1024px',
|
321
|
+
ltm: '1200px',
|
322
|
+
ltl: '1440px',
|
323
|
+
xl: '1920px',
|
324
|
+
xxl: '2560px',
|
325
|
+
qxl: '3840px',
|
326
|
+
};
|
327
|
+
```
|
328
|
+
|
329
|
+
### Vertical Breakpoints (default):
|
330
|
+
|
331
|
+
```typescript
|
332
|
+
const verticalBreakpoints = {
|
333
|
+
xs: '600px',
|
334
|
+
sm: '800px',
|
335
|
+
md: '1000px',
|
336
|
+
lg: '1200px',
|
337
|
+
xl: '1600px',
|
338
|
+
xxl: '1601px',
|
339
|
+
};
|
340
|
+
```
|
341
|
+
|
342
|
+
## Mixins Application
|
343
|
+
|
344
|
+
Mixins are bundled with the `include` decorator, providing descriptive statements for breakpoints based on them.
|
345
|
+
|
346
|
+
## Hooks
|
347
|
+
|
348
|
+
The project incorporates the following hooks based on `react-responsive` for use in React.js:
|
349
|
+
- `useBreakpoints`: Retrieve current screen breakpoints.
|
350
|
+
- `useBreakpoint`: Retrieve the current breakpoint.
|
351
|
+
- `useBreakpointMF`: Retrieve the current breakpoint for "Mobile to First" variant.
|
352
|
+
- `useBreakpointDF`: Retrieve the current breakpoint for "Desktop to First" variant.
|
353
|
+
|
354
|
+
### Hook Implementations
|
355
|
+
|
356
|
+
### Usage Examples:
|
357
|
+
|
358
|
+
#### useBreakpoint Hook with Predefined Breakpoints:
|
359
|
+
|
360
|
+
```typescript
|
361
|
+
import useBreakpoint from './hooks/useBreakpoint';
|
362
|
+
|
363
|
+
const MyComponent = () => {
|
364
|
+
const isMedium = useBreakpoint('md');
|
365
|
+
|
366
|
+
return (
|
367
|
+
<div>
|
368
|
+
{isMedium && <p>The current breakpoint is Medium (md)</p>}
|
369
|
+
</div>
|
370
|
+
);
|
371
|
+
};
|
372
|
+
```
|
373
|
+
|
374
|
+
#### useBreakpoint Hook with Custom Size:
|
375
|
+
|
376
|
+
```typescript
|
377
|
+
import useBreakpoint from './hooks/useBreakpoint';
|
378
|
+
|
379
|
+
const MyComponent = () => {
|
380
|
+
const isCustomSize = useBreakpoint(850);
|
381
|
+
|
382
|
+
return (
|
383
|
+
<div>
|
384
|
+
{isCustomSize && <p>The current breakpoint is Custom (850px)</p>}
|
385
|
+
</div>
|
386
|
+
);
|
387
|
+
};
|
388
|
+
```
|
389
|
+
|
390
|
+
#### useBreakpoints Hook:
|
391
|
+
|
392
|
+
```typescript
|
393
|
+
import { useBreakpoints } from './hooks/useBreakpoints';
|
394
|
+
|
395
|
+
const MyComponent = () => {
|
396
|
+
const breakpoints = useBreakpoints();
|
397
|
+
|
398
|
+
return (
|
399
|
+
<div>
|
400
|
+
{breakpoints.includes('lg') && <p>The Large (lg) breakpoint is active</p>}
|
401
|
+
</div>
|
402
|
+
);
|
403
|
+
};
|
404
|
+
```
|
405
|
+
|
406
|
+
#### useBreakpointMF Hook:
|
407
|
+
|
408
|
+
```typescript
|
409
|
+
import { useBreakpointMF } from './hooks/useBreakpoint';
|
410
|
+
|
411
|
+
const MyComponent = () => {
|
412
|
+
const isMedium = useBreakpointMF('md');
|
413
|
+
|
414
|
+
return (
|
415
|
+
<div>
|
416
|
+
{isMedium && <p>The current breakpoint is Medium (md) for Mobile First</p>}
|
417
|
+
</div>
|
418
|
+
);
|
419
|
+
};
|
420
|
+
```
|
421
|
+
|
422
|
+
#### useBreakpointDF Hook:
|
423
|
+
|
424
|
+
```typescript
|
425
|
+
import { useBreakpointDF } from './hooks/useBreakpoint';
|
426
|
+
|
427
|
+
const MyComponent = () => {
|
428
|
+
const isLarge = useBreakpointDF('lg');
|
429
|
+
|
430
|
+
return (
|
431
|
+
<div>
|
432
|
+
{isLarge && <p>The current breakpoint is Large (lg) for Desktop First</p>}
|
433
|
+
</div>
|
434
|
+
);
|
435
|
+
};
|
436
|
+
```
|
437
|
+
|
438
|
+
## Components
|
439
|
+
|
440
|
+
The project includes utility components to display content only at certain breakpoints.
|
441
|
+
|
442
|
+
### Usage Examples:
|
443
|
+
|
444
|
+
#### ForMF Component:
|
445
|
+
|
446
|
+
```typescript
|
447
|
+
import { ForMF } from './components/ForMF';
|
448
|
+
|
449
|
+
const MyComponent = () => (
|
450
|
+
<ForMF bp='md'>
|
451
|
+
<p>This content is only visible at the Medium (md) breakpoint</p>
|
452
|
+
</ForMF>
|
453
|
+
);
|
454
|
+
|
455
|
+
const CustomSizeComponent = () => (
|
456
|
+
<ForMF bp={850}>
|
457
|
+
<p>This content is only visible at the Custom size (850px) breakpoint</p>
|
458
|
+
</ForMF>
|
459
|
+
);
|
460
|
+
```
|
461
|
+
|
462
|
+
#### ForDF Component:
|
463
|
+
|
464
|
+
```typescript
|
465
|
+
import { ForDF } from './components/ForDF';
|
466
|
+
|
467
|
+
const MyComponent = () => (
|
468
|
+
<ForDF bp='lg'>
|
469
|
+
<p>This content is only visible at the Large (lg) breakpoint</p>
|
470
|
+
</ForDF>
|
471
|
+
);
|
472
|
+
|
473
|
+
const CustomSizeComponent = () => (
|
474
|
+
<ForDF bp={1200}>
|
475
|
+
<p>This content is only visible at the Custom size (1200px) breakpoint</p>
|
476
|
+
</ForDF>
|
477
|
+
);
|
478
|
+
```
|
479
|
+
|
480
|
+
## Future Growth Perspectives
|
481
|
+
|
482
|
+
We aim to add the following functionalities:
|
483
|
+
- Redefining SCSS variables.
|
484
|
+
- Configuring breakpoint names.
|
485
|
+
- Separate breakpoint configurations for vertical layout.
|
486
|
+
- Integration with the external library `react-responsive`.
|
487
|
+
- Addition of WebStorm live templates for quick layout designs.
|
488
|
+
#### ForDF Component:
|
489
|
+
|
490
|
+
```typescript
|
491
|
+
import { ForDF } from './components/ForDF';
|
492
|
+
|
493
|
+
const MyComponent = () => (
|
494
|
+
<ForDF bp='lg'>
|
495
|
+
<p>This content is only visible at the Large (lg) breakpoint</p>
|
496
|
+
</ForDF>
|
497
|
+
);
|
498
|
+
```
|
package/index.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './src'
|
package/package.json
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
{
|
2
|
+
"name": "react-responsive-tools",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "",
|
5
|
+
"main": "index.js",
|
6
|
+
"module": "index.js",
|
7
|
+
"types": "index.d.ts",
|
8
|
+
"scripts": {
|
9
|
+
"dev": "webpack --mode development --watch",
|
10
|
+
"build": "npm run generate-breakpoints && tsc && webpack --mode production",
|
11
|
+
"tsc": "tsc",
|
12
|
+
"test": "jest",
|
13
|
+
"lint": "eslint \"{**/*,*}.{js,ts,jsx,tsx}\"",
|
14
|
+
"lint-fix": "eslint \"{**/*,*}.{js,ts,jsx,tsx}\" --fix",
|
15
|
+
"generate-breakpoints": "node loadBreakpoints.js",
|
16
|
+
"postinstall": "npm run generate-breakpoints"
|
17
|
+
},
|
18
|
+
"files": [
|
19
|
+
"src",
|
20
|
+
"*.ts",
|
21
|
+
"*.scss",
|
22
|
+
"index.js",
|
23
|
+
"index.d.ts"
|
24
|
+
],
|
25
|
+
"keywords": [
|
26
|
+
"react",
|
27
|
+
"typescript",
|
28
|
+
"scss-tools",
|
29
|
+
"react-responsive"
|
30
|
+
],
|
31
|
+
"author": "westprophet",
|
32
|
+
"license": "ISC",
|
33
|
+
"dependencies": {
|
34
|
+
"classnames": "^2.5.1",
|
35
|
+
"react-responsive": "^10.0.0"
|
36
|
+
},
|
37
|
+
"devDependencies": {
|
38
|
+
"@babel/core": "^7.25.2",
|
39
|
+
"@babel/preset-env": "^7.25.4",
|
40
|
+
"@babel/preset-typescript": "^7.24.7",
|
41
|
+
"@testing-library/jest-dom": "^6.5.0",
|
42
|
+
"@testing-library/react": "^16.0.1",
|
43
|
+
"@testing-library/react-hooks": "^8.0.1",
|
44
|
+
"@types/jest": "^29.5.12",
|
45
|
+
"@types/node": "^22.5.4",
|
46
|
+
"@types/react-dom": "^18.3.0",
|
47
|
+
"@typescript-eslint/eslint-plugin": "^8.4.0",
|
48
|
+
"@typescript-eslint/parser": "^8.4.0",
|
49
|
+
"babel-loader": "^9.1.3",
|
50
|
+
"copy-webpack-plugin": "^12.0.2",
|
51
|
+
"css-loader": "^7.1.2",
|
52
|
+
"eslint": "^9.10.0",
|
53
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
54
|
+
"eslint-config-airbnb-typescript": "^18.0.0",
|
55
|
+
"eslint-import-resolver-typescript": "^3.6.3",
|
56
|
+
"eslint-plugin-import": "^2.30.0",
|
57
|
+
"eslint-plugin-jsx-a11y": "^6.10.0",
|
58
|
+
"eslint-webpack-plugin": "^4.2.0",
|
59
|
+
"file-loader": "^6.2.0",
|
60
|
+
"husky": "^9.1.5",
|
61
|
+
"jest": "^29.7.0",
|
62
|
+
"react-dom": "^18.3.1",
|
63
|
+
"react-test-renderer": "^18.3.1",
|
64
|
+
"sass": "^1.78.0",
|
65
|
+
"sass-loader": "^16.0.1",
|
66
|
+
"style-loader": "^4.0.0",
|
67
|
+
"ts-jest": "^29.2.5",
|
68
|
+
"ts-loader": "^9.5.1",
|
69
|
+
"tsconfig-paths": "^4.2.0",
|
70
|
+
"typescript": "^5.5.4",
|
71
|
+
"webpack": "^5.94.0",
|
72
|
+
"webpack-cli": "^5.1.4"
|
73
|
+
}
|
74
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
// breakpointConfig.js
|
2
|
+
|
3
|
+
const HORIZONTAL_BREAKPOINTS = {
|
4
|
+
xs: '320px',
|
5
|
+
sm: '576px',
|
6
|
+
md: '768px',
|
7
|
+
lg: '992px',
|
8
|
+
lt: '1024px',
|
9
|
+
ltm: '1200px',
|
10
|
+
ltl: '1440px',
|
11
|
+
xl: '1920px',
|
12
|
+
xxl: '2560px',
|
13
|
+
qxl: '3840px',
|
14
|
+
};
|
15
|
+
|
16
|
+
const VERTICAL_BREAKPOINTS = {
|
17
|
+
xs: '600px',
|
18
|
+
sm: '800px',
|
19
|
+
md: '1000px',
|
20
|
+
lg: '1200px',
|
21
|
+
xl: '1600px',
|
22
|
+
xxl: '1601px',
|
23
|
+
};
|
24
|
+
|
25
|
+
export { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS };
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/**
|
2
|
+
* Created by westp on 15.05.2023
|
3
|
+
*/
|
4
|
+
|
5
|
+
import { TBreakpoint } from '../interfaces/TBreakpoint';
|
6
|
+
import { useBreakpointDF, useBreakpointMF } from '../hooks/horizontal/useBreakpoint';
|
7
|
+
|
8
|
+
interface Props {
|
9
|
+
children: any;
|
10
|
+
}
|
11
|
+
|
12
|
+
interface ForComponentProps extends Props {
|
13
|
+
p: TBreakpoint | number;
|
14
|
+
}
|
15
|
+
|
16
|
+
export function ForMF({children, p}: ForComponentProps) {
|
17
|
+
const is = useBreakpointMF(p);
|
18
|
+
if (is) return children;
|
19
|
+
return null;
|
20
|
+
}
|
21
|
+
|
22
|
+
|
23
|
+
export function ForDF({children ,p}: ForComponentProps) {
|
24
|
+
const is = useBreakpointDF(p);
|
25
|
+
if (is) return children;
|
26
|
+
return null;
|
27
|
+
}
|
28
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
// src/hooks/__tests__/useBreakpoint.test.tsx
|
2
|
+
import { renderHook } from '@testing-library/react';
|
3
|
+
import useBreakpoint, { useBreakpointMF, useBreakpointDF } from './useBreakpoint';
|
4
|
+
import breakpoints from '../../scss/_horizontal.export.scss';
|
5
|
+
|
6
|
+
jest.mock('react-responsive', () => ({
|
7
|
+
useMediaQuery: jest.fn(),
|
8
|
+
}));
|
9
|
+
|
10
|
+
jest.mock('../useVariant', () => jest.fn(() => 'min'));
|
11
|
+
|
12
|
+
describe('useBreakpoint', () => {
|
13
|
+
it('should return true for the media query that matches the breakpoint', () => {
|
14
|
+
const mockedUseMediaQuery = require('react-responsive').useMediaQuery as jest.Mock;
|
15
|
+
mockedUseMediaQuery.mockReturnValue(true);
|
16
|
+
|
17
|
+
const { result } = renderHook(() => useBreakpoint('sm'));
|
18
|
+
|
19
|
+
expect(result.current).toBe(true);
|
20
|
+
expect(mockedUseMediaQuery).toHaveBeenCalledWith({ query: `(min-width: ${breakpoints.sm}px)` });
|
21
|
+
});
|
22
|
+
|
23
|
+
it('should return false for the media query that does not match the breakpoint', () => {
|
24
|
+
const mockedUseMediaQuery = require('react-responsive').useMediaQuery as jest.Mock;
|
25
|
+
mockedUseMediaQuery.mockReturnValue(false);
|
26
|
+
|
27
|
+
const { result } = renderHook(() => useBreakpoint('sm'));
|
28
|
+
|
29
|
+
expect(result.current).toBe(false);
|
30
|
+
expect(mockedUseMediaQuery).toHaveBeenCalledWith({ query: `(min-width: ${breakpoints.sm}px)` });
|
31
|
+
});
|
32
|
+
});
|
33
|
+
|
34
|
+
describe('useBreakpointMF', () => {
|
35
|
+
it('should return true for the `MtF` variant', () => {
|
36
|
+
const mockedUseMediaQuery = require('react-responsive').useMediaQuery as jest.Mock;
|
37
|
+
mockedUseMediaQuery.mockReturnValue(true);
|
38
|
+
|
39
|
+
const { result } = renderHook(() => useBreakpointMF('md'));
|
40
|
+
|
41
|
+
expect(result.current).toBe(true);
|
42
|
+
expect(mockedUseMediaQuery).toHaveBeenCalledWith({ query: `(min-width: ${breakpoints.md}px)` });
|
43
|
+
});
|
44
|
+
});
|
45
|
+
|
46
|
+
describe('useBreakpointDF', () => {
|
47
|
+
it('should return true for the `DtF` variant', () => {
|
48
|
+
const mockedUseMediaQuery = require('react-responsive').useMediaQuery as jest.Mock;
|
49
|
+
mockedUseMediaQuery.mockReturnValue(true);
|
50
|
+
|
51
|
+
const { result } = renderHook(() => useBreakpointDF('lg'));
|
52
|
+
|
53
|
+
expect(result.current).toBe(true);
|
54
|
+
expect(mockedUseMediaQuery).toHaveBeenCalledWith({ query: `(min-width: ${breakpoints.lg}px)` });
|
55
|
+
});
|
56
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { useMediaQuery } from 'react-responsive';
|
2
|
+
|
3
|
+
import breakpoints from '../../scss/_horizontal.export.scss';
|
4
|
+
import { TBreakpoint } from '../../interfaces/TBreakpoint';
|
5
|
+
import { TAdaptiveVariant } from '../../interfaces/TAdaptiveVariant';
|
6
|
+
import useVariant from '../useVariant';
|
7
|
+
|
8
|
+
export default function useBreakpoint(b: TBreakpoint | number, variant: TAdaptiveVariant = 'MtF') {
|
9
|
+
const p = typeof b === 'number' ? b : breakpoints[b];
|
10
|
+
const v = useVariant(variant);
|
11
|
+
return useMediaQuery({ query: `(${v}-width: ${p}px)` });
|
12
|
+
}
|
13
|
+
|
14
|
+
export function useBreakpointMF(b: TBreakpoint | number) {
|
15
|
+
return useBreakpoint(b, 'MtF');
|
16
|
+
}
|
17
|
+
|
18
|
+
export function useBreakpointDF(b: TBreakpoint | number) {
|
19
|
+
return useBreakpoint(b, 'MtF');
|
20
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { useMediaQuery } from 'react-responsive';
|
2
|
+
|
3
|
+
import breakpoints from '../../scss/_horizontal.export.scss';
|
4
|
+
import { TBreakpoints } from '../../interfaces/TBreakpoints';
|
5
|
+
import { TAdaptiveVariant } from '../../interfaces/TAdaptiveVariant';
|
6
|
+
import useVariant from '../useVariant';
|
7
|
+
|
8
|
+
export default function useBreakpoints(variant: TAdaptiveVariant = 'MtF'): TBreakpoints<boolean> {
|
9
|
+
const v = useVariant(variant);
|
10
|
+
return {
|
11
|
+
xs: useMediaQuery({ query: `(${v}-width: ${breakpoints.xs}px)` }),
|
12
|
+
sm: useMediaQuery({ query: `(${v}-width: ${breakpoints.sm}px)` }),
|
13
|
+
md: useMediaQuery({ query: `(${v}-width: ${breakpoints.md}px)` }),
|
14
|
+
lg: useMediaQuery({ query: `(${v}-width: ${breakpoints.lg}px)` }),
|
15
|
+
lt: useMediaQuery({ query: `(${v}-width: ${breakpoints.lt})px` }),
|
16
|
+
ltm: useMediaQuery({ query: `(${v}-width: ${breakpoints.ltm})px` }),
|
17
|
+
ltl: useMediaQuery({ query: `(${v}-width: ${breakpoints.ltl})px` }),
|
18
|
+
xl: useMediaQuery({ query: `(${v}-width: ${breakpoints.xl})px` }),
|
19
|
+
xxl: useMediaQuery({ query: `(${v}-width: ${breakpoints.xxl})px` }),
|
20
|
+
qxl: useMediaQuery({ query: `(${v}-width: ${breakpoints.qxl})px` }),
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
export function useBreakpointsMF(): TBreakpoints<boolean> {
|
25
|
+
return useBreakpoints('MtF');
|
26
|
+
}
|
27
|
+
|
28
|
+
export function useBreakpointsDF(): TBreakpoints<boolean> {
|
29
|
+
return useBreakpoints('DtF');
|
30
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { useMediaQuery } from 'react-responsive';
|
2
|
+
|
3
|
+
import breakpoints from '../../scss/_vertical.export.scss';
|
4
|
+
import { TVerticalBreakpoint } from '../../interfaces/TBreakpoint';
|
5
|
+
import { TAdaptiveVariant } from '../../interfaces/TAdaptiveVariant';
|
6
|
+
import useVariant from '../useVariant';
|
7
|
+
|
8
|
+
export default function useVBreakpoint(b: TVerticalBreakpoint | number, variant: TAdaptiveVariant = 'MtF') {
|
9
|
+
const p = typeof b === 'number' ? b : breakpoints[b];
|
10
|
+
const v = useVariant(variant);
|
11
|
+
return useMediaQuery({ query: `(${v}-height: ${p}px)` });
|
12
|
+
}
|
13
|
+
|
14
|
+
export function useVBreakpointMF(b: TVerticalBreakpoint | number) {
|
15
|
+
return useVBreakpoint(b, 'MtF');
|
16
|
+
}
|
17
|
+
|
18
|
+
export function useVBreakpointDF(b: TVerticalBreakpoint | number) {
|
19
|
+
return useVBreakpoint(b, 'MtF');
|
20
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { useMediaQuery } from 'react-responsive';
|
2
|
+
|
3
|
+
import breakpoints from '../../scss/_vertical.export.scss';
|
4
|
+
import { TVerticalBreakpoints } from '../../interfaces/TBreakpoints';
|
5
|
+
import { TAdaptiveVariant } from '../../interfaces/TAdaptiveVariant';
|
6
|
+
import useVariant from '../useVariant';
|
7
|
+
|
8
|
+
export default function useVBreakpoints(variant: TAdaptiveVariant = 'MtF'): TVerticalBreakpoints<boolean> {
|
9
|
+
const v = useVariant(variant);
|
10
|
+
return {
|
11
|
+
xs: useMediaQuery({ query: `(${v}-height: ${breakpoints.xs}px)` }),
|
12
|
+
sm: useMediaQuery({ query: `(${v}-height: ${breakpoints.sm}px)` }),
|
13
|
+
md: useMediaQuery({ query: `(${v}-height: ${breakpoints.md}px)` }),
|
14
|
+
lg: useMediaQuery({ query: `(${v}-height: ${breakpoints.lg}px)` }),
|
15
|
+
xl: useMediaQuery({ query: `(${v}-height: ${breakpoints.xl})px` }),
|
16
|
+
xxl: useMediaQuery({ query: `(${v}-height: ${breakpoints.xxl})px` }),
|
17
|
+
};
|
18
|
+
}
|
19
|
+
|
20
|
+
export function useVBreakpointsMF(): TVerticalBreakpoints<boolean> {
|
21
|
+
return useVBreakpoints('MtF');
|
22
|
+
}
|
23
|
+
|
24
|
+
export function useVBreakpointsDF(): TVerticalBreakpoints<boolean> {
|
25
|
+
return useVBreakpoints('DtF');
|
26
|
+
}
|
package/src/index.scss
ADDED
package/src/index.ts
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
import { TBreakpoints, TVerticalBreakpoints } from './interfaces/TBreakpoints';
|
2
|
+
import { TBreakpoint, TVerticalBreakpoint } from './interfaces/TBreakpoint';
|
3
|
+
|
4
|
+
export * from 'react-responsive';
|
5
|
+
|
6
|
+
export * from './hooks/horizontal/useBreakpoints';
|
7
|
+
export * from './hooks/horizontal/useBreakpoint';
|
8
|
+
|
9
|
+
export * from './hooks/vertical/useVBreakpoint';
|
10
|
+
export * from './hooks/vertical/useVBreakpoints';
|
11
|
+
|
12
|
+
export type {
|
13
|
+
TBreakpoints,
|
14
|
+
TBreakpoint,
|
15
|
+
TVerticalBreakpoint,
|
16
|
+
TVerticalBreakpoints,
|
17
|
+
};
|
18
|
+
|
19
|
+
export * from './components/horizontal';
|
@@ -0,0 +1 @@
|
|
1
|
+
export type TAdaptiveVariant = 'MtF' | 'DtF';
|
package/src/reset.scss
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
/***
|
2
|
+
The new CSS reset - version 1.8.4 (last updated 14.2.2023)
|
3
|
+
GitHub page: https://github.com/elad2412/the-new-css-reset
|
4
|
+
***/
|
5
|
+
|
6
|
+
/*
|
7
|
+
Remove all the styles of the "User-Agent-Stylesheet", except for the 'display' property
|
8
|
+
- The "symbol *" part is to solve Firefox SVG sprite bug
|
9
|
+
*/
|
10
|
+
*:where(:not(html, iframe, canvas, img, svg, video, audio):not(svg *, symbol *)) {
|
11
|
+
all: unset;
|
12
|
+
display: revert;
|
13
|
+
}
|
14
|
+
|
15
|
+
/* Preferred box-sizing value */
|
16
|
+
*,
|
17
|
+
*::before,
|
18
|
+
*::after {
|
19
|
+
box-sizing: border-box;
|
20
|
+
}
|
21
|
+
|
22
|
+
/* Reapply the pointer cursor for anchor tags */
|
23
|
+
a, button {
|
24
|
+
cursor: revert;
|
25
|
+
}
|
26
|
+
|
27
|
+
/* Remove list styles (bullets/numbers) */
|
28
|
+
ol, ul, menu {
|
29
|
+
list-style: none;
|
30
|
+
}
|
31
|
+
|
32
|
+
/* For images to not be able to exceed their container */
|
33
|
+
img {
|
34
|
+
max-inline-size: 100%;
|
35
|
+
max-block-size: 100%;
|
36
|
+
}
|
37
|
+
|
38
|
+
/* removes spacing between cells in tables */
|
39
|
+
table {
|
40
|
+
border-collapse: collapse;
|
41
|
+
}
|
42
|
+
|
43
|
+
/* Safari - solving issue when using user-select:none on the <body> text input doesn't working */
|
44
|
+
input, textarea {
|
45
|
+
-webkit-user-select: auto;
|
46
|
+
}
|
47
|
+
|
48
|
+
/* revert the 'white-space' property for textarea elements on Safari */
|
49
|
+
textarea {
|
50
|
+
white-space: revert;
|
51
|
+
}
|
52
|
+
|
53
|
+
/* minimum style to allow to style meter element */
|
54
|
+
meter {
|
55
|
+
-webkit-appearance: revert;
|
56
|
+
appearance: revert;
|
57
|
+
}
|
58
|
+
|
59
|
+
/* preformatted text - use only for this feature */
|
60
|
+
:where(pre) {
|
61
|
+
all: revert;
|
62
|
+
}
|
63
|
+
|
64
|
+
/* reset default text opacity of input placeholder */
|
65
|
+
::placeholder {
|
66
|
+
color: unset;
|
67
|
+
}
|
68
|
+
|
69
|
+
/* remove default dot (•) sign */
|
70
|
+
::marker {
|
71
|
+
content: initial;
|
72
|
+
}
|
73
|
+
|
74
|
+
/* fix the feature of 'hidden' attribute.
|
75
|
+
display:revert; revert to element instead of attribute */
|
76
|
+
:where([hidden]) {
|
77
|
+
display: none;
|
78
|
+
}
|
79
|
+
|
80
|
+
/* revert for bug in Chromium browsers
|
81
|
+
- fix for the content editable attribute will work properly.
|
82
|
+
- webkit-user-select: auto; added for Safari in case of using user-select:none on wrapper element*/
|
83
|
+
:where([contenteditable]:not([contenteditable="false"])) {
|
84
|
+
-moz-user-modify: read-write;
|
85
|
+
-webkit-user-modify: read-write;
|
86
|
+
overflow-wrap: break-word;
|
87
|
+
-webkit-line-break: after-white-space;
|
88
|
+
-webkit-user-select: auto;
|
89
|
+
}
|
90
|
+
|
91
|
+
/* apply back the draggable feature - exist only in Chromium and Safari */
|
92
|
+
:where([draggable="true"]) {
|
93
|
+
-webkit-user-drag: element;
|
94
|
+
}
|
95
|
+
|
96
|
+
/* Revert Modal native behavior */
|
97
|
+
:where(dialog:modal) {
|
98
|
+
all: revert;
|
99
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
// _data.scss
|
2
|
+
@import './custom-breakpoints';
|
3
|
+
|
4
|
+
:export {
|
5
|
+
// Экспорт горизонтальных брейкпоинтов
|
6
|
+
xs: map-get($horizontal-breakpoints, xs);
|
7
|
+
sm: map-get($horizontal-breakpoints, sm);
|
8
|
+
md: map-get($horizontal-breakpoints, md);
|
9
|
+
lg: map-get($horizontal-breakpoints, lg);
|
10
|
+
lt: map-get($horizontal-breakpoints, lt);
|
11
|
+
ltm: map-get($horizontal-breakpoints, ltm);
|
12
|
+
ltl: map-get($horizontal-breakpoints, ltl);
|
13
|
+
xl: map-get($horizontal-breakpoints, xl);
|
14
|
+
xxl: map-get($horizontal-breakpoints, xxl);
|
15
|
+
qxl: map-get($horizontal-breakpoints, qxl);
|
16
|
+
|
17
|
+
// Экспорт вертикальных брейкпоинтов
|
18
|
+
vxs: map-get($vertical-breakpoints, xs);
|
19
|
+
vsm: map-get($vertical-breakpoints, sm);
|
20
|
+
vmd: map-get($vertical-breakpoints, md);
|
21
|
+
vlg: map-get($vertical-breakpoints, lg);
|
22
|
+
vxl: map-get($vertical-breakpoints, xl);
|
23
|
+
vxxl: map-get($vertical-breakpoints, xxl);
|
24
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
@import "data";
|
2
|
+
|
3
|
+
:export{
|
4
|
+
xs:map-get($horizontal-breakpoints,xs);
|
5
|
+
sm:map-get($horizontal-breakpoints,sm);
|
6
|
+
md:map-get($horizontal-breakpoints,md);
|
7
|
+
lg:map-get($horizontal-breakpoints,lg);
|
8
|
+
lt:map-get($horizontal-breakpoints,lt);
|
9
|
+
ltm:map-get($horizontal-breakpoints,ltm);
|
10
|
+
ltl:map-get($horizontal-breakpoints,ltl);
|
11
|
+
xl:map-get($horizontal-breakpoints,xl);
|
12
|
+
xxl:map-get($horizontal-breakpoints,xxl);
|
13
|
+
qxl:map-get($horizontal-breakpoints,qxl);
|
14
|
+
}
|
@@ -0,0 +1,118 @@
|
|
1
|
+
|
2
|
+
@mixin mobile-first($breakpoint){
|
3
|
+
$breakpoint-value: map-get($horizontal-breakpoints, $breakpoint);
|
4
|
+
@media (min-width: #{$breakpoint-value}px) {
|
5
|
+
@content;
|
6
|
+
}
|
7
|
+
}
|
8
|
+
|
9
|
+
@mixin desktop-first($breakpoint){
|
10
|
+
$breakpoint-value: map-get($horizontal-breakpoints, $breakpoint);
|
11
|
+
@media (max-width: #{$breakpoint-value}px) {
|
12
|
+
@content;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
|
17
|
+
@mixin m-xs(){
|
18
|
+
@include mobile-first(xs){
|
19
|
+
@content;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
@mixin m-sm(){
|
23
|
+
@include mobile-first(sm){
|
24
|
+
@content;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
@mixin m-md(){
|
28
|
+
@include mobile-first(md){
|
29
|
+
@content;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
@mixin m-lg(){
|
33
|
+
@include mobile-first(lg){
|
34
|
+
@content;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
@mixin m-lt(){
|
38
|
+
@include mobile-first(lt){
|
39
|
+
@content;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
@mixin m-ltm(){
|
43
|
+
@include mobile-first(ltm){
|
44
|
+
@content;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
@mixin m-ltl(){
|
48
|
+
@include mobile-first(ltl){
|
49
|
+
@content;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
@mixin m-xl(){
|
53
|
+
@include mobile-first(xl){
|
54
|
+
@content;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
@mixin m-xxl(){
|
58
|
+
@include mobile-first(xxl){
|
59
|
+
@content;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
@mixin m-qxl(){
|
63
|
+
@include mobile-first(qxl){
|
64
|
+
@content;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
@mixin d-xs(){
|
70
|
+
@include desktop-first(xs){
|
71
|
+
@content;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
@mixin d-sm(){
|
75
|
+
@include desktop-first(sm){
|
76
|
+
@content;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
@mixin d-md(){
|
80
|
+
@include desktop-first(md){
|
81
|
+
@content;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
@mixin d-lg(){
|
85
|
+
@include desktop-first(lg){
|
86
|
+
@content;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
@mixin d-lt(){
|
90
|
+
@include desktop-first(lt){
|
91
|
+
@content;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
@mixin d-ltm(){
|
95
|
+
@include desktop-first(ltm){
|
96
|
+
@content;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
@mixin d-ltl(){
|
100
|
+
@include desktop-first(ltl){
|
101
|
+
@content;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
@mixin d-xl(){
|
105
|
+
@include desktop-first(xl){
|
106
|
+
@content;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
@mixin d-xxl(){
|
110
|
+
@include desktop-first(xxl){
|
111
|
+
@content;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
@mixin d-qxl(){
|
115
|
+
@include desktop-first(qxl){
|
116
|
+
@content;
|
117
|
+
}
|
118
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
@import "data";
|
2
|
+
|
3
|
+
:export{
|
4
|
+
xs: map-get($vertical-breakpoints, xs);
|
5
|
+
sm: map-get($vertical-breakpoints, sm);
|
6
|
+
md: map-get($vertical-breakpoints, md);
|
7
|
+
lg: map-get($vertical-breakpoints, lg);
|
8
|
+
xl: map-get($vertical-breakpoints, xl);
|
9
|
+
xxl: map-get($vertical-breakpoints, xxl);
|
10
|
+
}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
|
2
|
+
@mixin v-mobile-first($breakpoint){
|
3
|
+
$breakpoint-value: map-get($vertical-breakpoints, $breakpoint);
|
4
|
+
@media (min-height: #{$breakpoint-value}px) {
|
5
|
+
@content;
|
6
|
+
}
|
7
|
+
}
|
8
|
+
|
9
|
+
@mixin v-desktop-first($breakpoint){
|
10
|
+
$breakpoint-value: map-get($vertical-breakpoints, $breakpoint);
|
11
|
+
@media (max-height: #{$breakpoint-value}px) {
|
12
|
+
@content;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
@mixin vm-xs(){
|
17
|
+
@include v-mobile-first(xs){
|
18
|
+
@content;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
@mixin vm-sm(){
|
22
|
+
@include v-mobile-first(sm){
|
23
|
+
@content;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
@mixin vm-md(){
|
27
|
+
@include v-mobile-first(md){
|
28
|
+
@content;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
@mixin vm-lg(){
|
32
|
+
@include v-mobile-first(lg){
|
33
|
+
@content;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
@mixin vm-xl(){
|
37
|
+
@include v-mobile-first(xl){
|
38
|
+
@content;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
@mixin vm-xxl(){
|
42
|
+
@include v-mobile-first(xxl){
|
43
|
+
@content;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
@mixin vd-xs(){
|
48
|
+
@include v-desktop-first(xs){
|
49
|
+
@content;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
@mixin vd-sm(){
|
53
|
+
@include v-desktop-first(sm){
|
54
|
+
@content;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
@mixin vd-md(){
|
58
|
+
@include v-desktop-first(md){
|
59
|
+
@content;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
@mixin vd-lg(){
|
63
|
+
@include v-desktop-first(lg){
|
64
|
+
@content;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
@mixin vd-xl(){
|
68
|
+
@include v-desktop-first(xl){
|
69
|
+
@content;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
@mixin vd-xxl(){
|
73
|
+
@include v-desktop-first(xxl){
|
74
|
+
@content;
|
75
|
+
}
|
76
|
+
}
|