react-responsive-tools 1.1.5 → 2.0.1
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/README.MD +507 -149
- package/bin/react-responsive-tools.js +20 -0
- package/package.json +6 -4
- package/src/breakpoints.config.d.ts +4 -0
- package/src/breakpoints.config.js +25 -0
- package/src/components/horizontal.tsx +2 -2
- package/src/default.config.js +25 -0
- package/src/functions/getBreakpoint.ts +11 -0
- package/src/hooks/useBreakpoint.ts +2 -3
- package/src/hooks/useVBreakpoint.ts +2 -2
- package/src/index.ts +0 -2
- package/src/interfaces/TBreakpoint.ts +1 -2
- package/src/scripts/createConfig.js +49 -0
- package/src/scripts/generateCustomBreakpointsSCSS.js +30 -0
- package/src/scripts/generateSCSS.js +51 -0
- package/src/scripts/generateTBreakpoint.js +30 -0
- package/src/scss/_custom-breakpoints.scss +21 -0
- package/src/scss/_horizontal-breakpoints.scss +104 -0
- package/src/scss/_horizontal.scss +3 -104
- package/src/scss/_vertical-breakpoints.scss +64 -0
- package/src/scss/_vertical.scss +4 -64
- package/src/scss/index.scss +2 -1
- package/default.scss +0 -1
- package/src/hooks/getCSSVariable.ts +0 -16
- package/src/scss/_breakpoints.scss +0 -19
package/README.MD
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
# react-responsive-tools
|
2
2
|
|
3
|
-
This project provides tools and configurations to simplify writing
|
3
|
+
This project provides tools and configurations to simplify writing adaptive code for both vertical and horizontal layouts.
|
4
4
|
|
5
|
-
The package is based on
|
6
|
-
|
7
|
-
In the future, the dependency on scss will be removed.
|
5
|
+
The package is based on [react-responsive](https://www.npmjs.com/package/react-responsive) for use in React. It assumes the use of SCSS for compilation.
|
8
6
|
|
9
7
|
## Installation
|
10
8
|
|
@@ -18,249 +16,609 @@ yarn add react-responsive-tools
|
|
18
16
|
npm install react-responsive-tools
|
19
17
|
```
|
20
18
|
|
21
|
-
|
19
|
+
### Import SCSS
|
20
|
+
|
21
|
+
To use the generated SCSS files, import the main SCSS file from the library:
|
22
22
|
|
23
23
|
```scss
|
24
|
-
@import
|
24
|
+
@import 'react-responsive-tools';
|
25
25
|
```
|
26
26
|
|
27
|
-
|
27
|
+
### Import JavaScript
|
28
28
|
|
29
|
-
|
29
|
+
To use the components and hooks, import them from the library:
|
30
30
|
|
31
|
-
```
|
32
|
-
|
31
|
+
```javascript
|
32
|
+
import { For, Before, useBreakpoint, useBreakpointDF, useBreakpointMF, useVBreakpoint, useVBreakpointDF, useVBreakpointMF } from 'react-responsive-tools';
|
33
33
|
```
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
--vbp - vertical breakpoints
|
35
|
+
## Initialization and Configuration
|
38
36
|
|
39
|
-
|
37
|
+
To initialize the tools, use the following commands:
|
40
38
|
|
41
|
-
|
42
|
-
:root {
|
43
|
-
--bp-xs: 320px;
|
44
|
-
--bp-sm: 576px;
|
45
|
-
--bp-md: 768px;
|
46
|
-
--bp-lg: 992px;
|
47
|
-
--bp-lt: 1024px;
|
48
|
-
--bp-ltm: 1120px;
|
49
|
-
--bp-ltl: 1440px;
|
50
|
-
--bp-xl: 1920px;
|
51
|
-
--bp-xxl: 2560px;
|
52
|
-
--bp-qxl: 3840px;
|
53
|
-
|
54
|
-
--vbp-xs: 600px;
|
55
|
-
--vbp-sm: 800px;
|
56
|
-
--vbp-md: 1000px;
|
57
|
-
--vbp-lg: 1200px;
|
58
|
-
--vbp-xl: 1600px;
|
59
|
-
--vbp-xxl: 1920px;
|
60
|
-
}
|
61
|
-
```
|
39
|
+
### Re-initializing Configuration
|
62
40
|
|
63
|
-
|
41
|
+
If you have changed the configuration or added new settings, you need to reinitialize the configuration files. To do this, run the following command:
|
64
42
|
|
65
|
-
```
|
66
|
-
|
67
|
-
|
68
|
-
:root {
|
69
|
-
//--bp-xxl: 2560px;
|
70
|
-
--bp-xxl: 2222px; // new point
|
71
|
-
}
|
43
|
+
```sh
|
44
|
+
react-responsive-tools run reinit
|
72
45
|
```
|
73
46
|
|
74
|
-
|
47
|
+
This command will run the `reinit.sh` script, which will recreate the necessary configuration files.
|
75
48
|
|
76
|
-
|
49
|
+
### Default Values
|
77
50
|
|
78
|
-
|
51
|
+
The following horizontal and vertical breakpoints are provided by default:
|
79
52
|
|
80
|
-
|
81
|
-
@import "react-responsive-tools";
|
53
|
+
#### Horizontal Breakpoints
|
82
54
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
55
|
+
```typescript
|
56
|
+
export const HORIZONTAL_BREAKPOINTS = {
|
57
|
+
xs: '320px',
|
58
|
+
sm: '576px',
|
59
|
+
md: '768px',
|
60
|
+
lg: '992px',
|
61
|
+
lt: '1024px',
|
62
|
+
ltm: '1200px',
|
63
|
+
ltl: '1440px',
|
64
|
+
xl: '1920px',
|
65
|
+
xxl: '2560px',
|
66
|
+
qxl: '3840px',
|
67
|
+
};
|
68
|
+
```
|
95
69
|
|
96
|
-
|
97
|
-
@include d-xxl { // for desktop to first xxl breakpoint
|
98
|
-
color: white;
|
99
|
-
// vertical points in horizontal
|
100
|
-
@include vd-xs {
|
101
|
-
font-size: 10px;
|
102
|
-
}
|
103
|
-
@include vd-md {
|
104
|
-
font-size: 12px;
|
105
|
-
}
|
106
|
-
}
|
107
|
-
}
|
70
|
+
#### Vertical Breakpoints
|
108
71
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
72
|
+
```typescript
|
73
|
+
export const VERTICAL_BREAKPOINTS = {
|
74
|
+
xs: '600px',
|
75
|
+
sm: '800px',
|
76
|
+
md: '1000px',
|
77
|
+
lg: '1200px',
|
78
|
+
xl: '1600px',
|
79
|
+
xxl: '1920px',
|
80
|
+
};
|
81
|
+
```
|
118
82
|
|
119
|
-
|
120
|
-
@include v-desk-first(md) {
|
83
|
+
### Using Hooks
|
121
84
|
|
122
|
-
|
123
|
-
// mob first
|
124
|
-
@include v-mob-first(md) {
|
85
|
+
#### Hook `useBreakpoint`
|
125
86
|
|
126
|
-
|
127
|
-
}
|
128
|
-
```
|
87
|
+
```typescript
|
88
|
+
import { useBreakpoint } from 'react-responsive-tools';
|
129
89
|
|
130
|
-
|
90
|
+
// Usage Example
|
91
|
+
const MyComponent = () => {
|
92
|
+
const isMedium = useBreakpoint('md');
|
131
93
|
|
132
|
-
|
94
|
+
return (
|
95
|
+
<div>
|
96
|
+
{isMedium && <p>Current breakpoint: Medium (md)</p>}
|
97
|
+
</div>
|
98
|
+
);
|
99
|
+
};
|
100
|
+
```
|
133
101
|
|
134
|
-
#### Hook `
|
102
|
+
#### Hook `useBreakpointMF`
|
135
103
|
|
136
104
|
```typescript
|
137
|
-
import {
|
138
|
-
import breakpoints from '../../scss/_horizontal.export.scss';
|
139
|
-
import { TBreakpoint } from '../../interfaces/TBreakpoint';
|
140
|
-
import { TAdaptiveVariant } from '../../interfaces/TAdaptiveVariant';
|
141
|
-
import useVariant from '../useVariant';
|
105
|
+
import { useBreakpointMF } from 'react-responsive-tools';
|
142
106
|
|
143
|
-
|
144
|
-
|
145
|
-
const
|
146
|
-
return useMediaQuery({ query: `(${v}-width: ${p}px)` });
|
147
|
-
}
|
148
|
-
|
149
|
-
export function useBreakpointMF(b: TBreakpoint) {
|
150
|
-
return useBreakpoint(b, 'MtF');
|
151
|
-
}
|
107
|
+
// Usage Example
|
108
|
+
const MyComponent = () => {
|
109
|
+
const isMedium = useBreakpointMF('md');
|
152
110
|
|
153
|
-
|
154
|
-
|
155
|
-
}
|
111
|
+
return (
|
112
|
+
<div>
|
113
|
+
{isMedium && <p>Current breakpoint: Medium (md) for Mobile First</p>}
|
114
|
+
</div>
|
115
|
+
);
|
116
|
+
};
|
156
117
|
```
|
157
118
|
|
158
|
-
|
159
|
-
|
160
|
-
#### Hook `useBreakpoint`:
|
119
|
+
#### Hook `useBreakpointDF`
|
161
120
|
|
162
121
|
```typescript
|
163
|
-
import
|
122
|
+
import { useBreakpointDF } from 'react-responsive-tools';
|
164
123
|
|
124
|
+
// Usage Example
|
165
125
|
const MyComponent = () => {
|
166
|
-
const
|
126
|
+
const isLarge = useBreakpointDF('lg');
|
167
127
|
|
168
128
|
return (
|
169
129
|
<div>
|
170
|
-
{
|
130
|
+
{isLarge && <p>Current breakpoint: Large (lg) for Desktop First</p>}
|
171
131
|
</div>
|
172
132
|
);
|
173
133
|
};
|
174
134
|
```
|
175
135
|
|
176
|
-
#### Hook `
|
136
|
+
#### Hook `useVBreakpoint`
|
177
137
|
|
178
138
|
```typescript
|
179
|
-
import {
|
139
|
+
import { useVBreakpoint } from 'react-responsive-tools';
|
180
140
|
|
141
|
+
// Usage Example
|
181
142
|
const MyComponent = () => {
|
182
|
-
const isMedium =
|
143
|
+
const isMedium = useVBreakpoint('md');
|
183
144
|
|
184
145
|
return (
|
185
146
|
<div>
|
186
|
-
{isMedium && <p>Current breakpoint: Medium (md)
|
147
|
+
{isMedium && <p>Current vertical breakpoint: Medium (md)</p>}
|
187
148
|
</div>
|
188
149
|
);
|
189
150
|
};
|
190
151
|
```
|
191
152
|
|
192
|
-
#### Hook `
|
153
|
+
#### Hook `useVBreakpointMF`
|
193
154
|
|
194
155
|
```typescript
|
195
|
-
import {
|
156
|
+
import { useVBreakpointMF } from 'react-responsive-tools';
|
196
157
|
|
158
|
+
// Usage Example
|
197
159
|
const MyComponent = () => {
|
198
|
-
const
|
160
|
+
const isMedium = useVBreakpointMF('md');
|
199
161
|
|
200
162
|
return (
|
201
163
|
<div>
|
202
|
-
{
|
164
|
+
{isMedium && <p>Current vertical breakpoint: Medium (md) for Mobile First</p>}
|
203
165
|
</div>
|
204
166
|
);
|
205
167
|
};
|
206
168
|
```
|
207
169
|
|
208
|
-
|
170
|
+
#### Hook `useVBreakpointDF`
|
209
171
|
|
210
|
-
|
172
|
+
```typescript
|
173
|
+
import { useVBreakpointDF } from 'react-responsive-tools';
|
211
174
|
|
212
|
-
|
175
|
+
// Usage Example
|
176
|
+
const MyComponent = () => {
|
177
|
+
const isLarge = useVBreakpointDF('lg');
|
213
178
|
|
214
|
-
|
179
|
+
return (
|
180
|
+
<div>
|
181
|
+
{isLarge && <p>Current vertical breakpoint: Large (lg) for Desktop First</p>}
|
182
|
+
</div>
|
183
|
+
);
|
184
|
+
};
|
185
|
+
```
|
186
|
+
|
187
|
+
### Using Components
|
188
|
+
|
189
|
+
#### Component `For`
|
215
190
|
|
216
191
|
```typescript
|
217
|
-
import {
|
192
|
+
import { For } from 'react-responsive-tools';
|
218
193
|
|
194
|
+
// Usage Example
|
219
195
|
const MyComponent = () => (
|
220
|
-
<
|
196
|
+
<For p='md'>
|
221
197
|
<p>This content is visible only at the Medium (md) breakpoint</p>
|
222
|
-
</
|
198
|
+
</For>
|
223
199
|
);
|
224
200
|
|
225
201
|
const CustomSizeComponent = () => (
|
226
|
-
<
|
202
|
+
<For p={850}>
|
227
203
|
<p>This content is visible only at the Custom (850px) breakpoint</p>
|
228
|
-
</
|
204
|
+
</For>
|
229
205
|
);
|
230
206
|
```
|
231
207
|
|
232
|
-
#### Component `
|
208
|
+
#### Component `Before`
|
233
209
|
|
234
210
|
```typescript
|
235
|
-
import {
|
211
|
+
import { Before } from 'react-responsive-tools';
|
236
212
|
|
213
|
+
// Usage Example
|
237
214
|
const MyComponent = () => (
|
238
|
-
<
|
215
|
+
<Before p='lg'>
|
239
216
|
<p>This content is visible only at the Large (lg) breakpoint</p>
|
240
|
-
</
|
217
|
+
</Before>
|
241
218
|
);
|
242
219
|
|
243
220
|
const CustomSizeComponent = () => (
|
244
|
-
<
|
221
|
+
<Before p={1200}>
|
245
222
|
<p>This content is visible only at the Custom (1200px) breakpoint</p>
|
246
|
-
</
|
223
|
+
</Before>
|
247
224
|
);
|
248
225
|
```
|
249
226
|
|
250
|
-
|
227
|
+
### Breakpoint Types
|
228
|
+
|
229
|
+
```typescript
|
230
|
+
export type TBreakpoint =
|
231
|
+
| 'xs'
|
232
|
+
| 'sm'
|
233
|
+
| 'md'
|
234
|
+
| 'lg'
|
235
|
+
| 'lt'
|
236
|
+
| 'ltm'
|
237
|
+
| 'ltl'
|
238
|
+
| 'xl'
|
239
|
+
| 'xxl'
|
240
|
+
| 'qxl'
|
241
|
+
|
242
|
+
export type TVerticalBreakpoint =
|
243
|
+
| 'xs'
|
244
|
+
| 'sm'
|
245
|
+
| 'md'
|
246
|
+
| 'lg'
|
247
|
+
| 'xl'
|
248
|
+
| 'xxl'
|
249
|
+
```
|
250
|
+
|
251
|
+
### Project Structure
|
252
|
+
|
253
|
+
The project includes the following directories and files:
|
254
|
+
|
255
|
+
- `scss`: directory for SCSS files.
|
256
|
+
- `_custom-breakpoints.scss`: contains custom breakpoints.
|
257
|
+
- `_horizontal.scss`: provides mixins for horizontal layouts.
|
258
|
+
- `_horizontal-breakpoints.scss`: defines horizontal breakpoints.
|
259
|
+
- `_vertical.scss`: provides mixins for vertical layouts.
|
260
|
+
- `_vertical-breakpoints.scss`: defines vertical breakpoints.
|
261
|
+
- `index.scss`: main SCSS file.
|
262
|
+
|
263
|
+
- `hooks`: directory for hooks.
|
264
|
+
- `useBreakpoint.ts`: implements the `useBreakpoint` hook.
|
265
|
+
- `useVBreakpoint.ts`: implements the `useVBreakpoint` hook.
|
266
|
+
- `useVariant.ts`: utility hook to determine the variant.
|
267
|
+
|
268
|
+
- `components`: directory for components.
|
269
|
+
- `horizontal.tsx`: utility components for horizontal layouts.
|
270
|
+
- `For.tsx`: utility component for displaying content at a specific breakpoint.
|
271
|
+
- `Before.tsx`: utility component similar to `For`, but for different breakpoints.
|
272
|
+
|
273
|
+
- `scripts`: directory for scripts.
|
274
|
+
- `createConfig.js`: script to create configuration files.
|
275
|
+
- `generateCustomBreakpointsSCSS.js`: script to generate custom SCSS breakpoints.
|
276
|
+
- `generateSCSS.js`: script to generate SCSS files.
|
277
|
+
- `generateTBreakpoint.js`: script to generate TypeScript breakpoint types.
|
278
|
+
|
279
|
+
- `interfaces`: directory for TypeScript interfaces.
|
280
|
+
- `TAdaptiveVariant.ts`: interface for adaptive variant types.
|
281
|
+
- `TBreakpoint.ts`: interface for breakpoint types.
|
282
|
+
- `TBreakpoints.ts`: interface for breakpoints.
|
283
|
+
|
284
|
+
## Command Line Interface (CLI)
|
285
|
+
|
286
|
+
To recreate the necessary files, run the provided script using the following command:
|
287
|
+
|
288
|
+
```sh
|
289
|
+
react-responsive-tools run reinit
|
290
|
+
```
|
291
|
+
|
292
|
+
This command will run the `reinit.sh` script, which will create the configuration files for the project.
|
293
|
+
|
294
|
+
### Examples of SCSS Mixins after Re-initialization
|
295
|
+
|
296
|
+
After re-generating the files, the following SCSS mixins will be available:
|
297
|
+
|
298
|
+
#### Horizontal Breakpoints
|
299
|
+
|
300
|
+
```scss
|
301
|
+
@import "_custom-breakpoints";
|
302
|
+
|
303
|
+
@mixin mob-first($breakpoint) {
|
304
|
+
@media (min-width: map-get($horizontal-breakpoints, $breakpoint)) {
|
305
|
+
@content;
|
306
|
+
}
|
307
|
+
}
|
308
|
+
|
309
|
+
@mixin desk-first($breakpoint) {
|
310
|
+
@media (max-width: map-get($horizontal-breakpoints, $breakpoint)) {
|
311
|
+
@content;
|
312
|
+
}
|
313
|
+
}
|
314
|
+
|
315
|
+
// Example mixins
|
316
|
+
@mixin for-xs() {
|
317
|
+
@include mob-first(xs) {
|
318
|
+
@content;
|
319
|
+
}
|
320
|
+
}
|
321
|
+
|
322
|
+
@mixin for-sm() {
|
323
|
+
@include mob-first(sm) {
|
324
|
+
@content;
|
325
|
+
}
|
326
|
+
}
|
327
|
+
|
328
|
+
@mixin for-md() {
|
329
|
+
@include mob-first(md) {
|
330
|
+
@content;
|
331
|
+
}
|
332
|
+
}
|
333
|
+
|
334
|
+
@mixin for-lg() {
|
335
|
+
@include mob-first(lg) {
|
336
|
+
@content;
|
337
|
+
}
|
338
|
+
}
|
339
|
+
|
340
|
+
@mixin for-lt() {
|
341
|
+
@include mob-first(lt) {
|
342
|
+
@content;
|
343
|
+
}
|
344
|
+
}
|
345
|
+
|
346
|
+
@mixin for-ltm() {
|
347
|
+
@include mob-first(ltm) {
|
348
|
+
@content;
|
349
|
+
}
|
350
|
+
}
|
351
|
+
|
352
|
+
@mixin for-ltl() {
|
353
|
+
@include mob-first(ltl) {
|
354
|
+
@content;
|
355
|
+
}
|
356
|
+
}
|
357
|
+
|
358
|
+
@mixin for-xl() {
|
359
|
+
@include mob-first(xl) {
|
360
|
+
@content;
|
361
|
+
}
|
362
|
+
}
|
363
|
+
|
364
|
+
@mixin for-xxl() {
|
365
|
+
@include mob-first(xxl) {
|
366
|
+
@content;
|
367
|
+
}
|
368
|
+
}
|
369
|
+
|
370
|
+
@mixin for-qxl() {
|
371
|
+
@include mob-first(qxl) {
|
372
|
+
@content;
|
373
|
+
}
|
374
|
+
}
|
375
|
+
|
376
|
+
@mixin before-xs() {
|
377
|
+
@include desk-first(xs) {
|
378
|
+
@content;
|
379
|
+
}
|
380
|
+
}
|
381
|
+
|
382
|
+
@mixin before-sm() {
|
383
|
+
@include desk-first(sm) {
|
384
|
+
@content;
|
385
|
+
}
|
386
|
+
}
|
387
|
+
|
388
|
+
@mixin before-md() {
|
389
|
+
@include desk-first(md) {
|
390
|
+
@content;
|
391
|
+
}
|
392
|
+
}
|
393
|
+
|
394
|
+
@mixin before-lg() {
|
395
|
+
@include desk-first(lg) {
|
396
|
+
@content;
|
397
|
+
}
|
398
|
+
}
|
399
|
+
|
400
|
+
@mixin before-lt() {
|
401
|
+
@include desk-first(lt) {
|
402
|
+
@content;
|
403
|
+
}
|
404
|
+
}
|
405
|
+
|
406
|
+
@mixin before-ltm() {
|
407
|
+
@include desk-first(ltm) {
|
408
|
+
@content;
|
409
|
+
}
|
410
|
+
}
|
411
|
+
|
412
|
+
@mixin before-ltl() {
|
413
|
+
@include desk-first(ltl) {
|
414
|
+
@content;
|
415
|
+
}
|
416
|
+
}
|
417
|
+
|
418
|
+
@mixin before-xl() {
|
419
|
+
@include desk-first(xl) {
|
420
|
+
@content;
|
421
|
+
}
|
422
|
+
}
|
423
|
+
|
424
|
+
@mixin before-xxl() {
|
425
|
+
@include desk-first(xxl) {
|
426
|
+
@content;
|
427
|
+
}
|
428
|
+
}
|
429
|
+
|
430
|
+
@mixin before-qxl() {
|
431
|
+
@include desk-first(qxl) {
|
432
|
+
@content;
|
433
|
+
}
|
434
|
+
}
|
435
|
+
```
|
436
|
+
|
437
|
+
#### Vertical Breakpoints
|
438
|
+
|
439
|
+
```scss
|
440
|
+
@import "_custom-breakpoints";
|
441
|
+
|
442
|
+
@mixin v-mob-first($breakpoint) {
|
443
|
+
@media (min-height: map-get($vertical-breakpoints, $breakpoint)) {
|
444
|
+
@content;
|
445
|
+
}
|
446
|
+
}
|
447
|
+
|
448
|
+
@mixin v-desk-first($breakpoint) {
|
449
|
+
@media (max-height: map-get($vertical-breakpoints, $breakpoint)) {
|
450
|
+
@content;
|
451
|
+
}
|
452
|
+
}
|
453
|
+
|
454
|
+
// Example mixins
|
455
|
+
@mixin v-for-xs() {
|
456
|
+
@include v-mob-first(xs) {
|
457
|
+
@content;
|
458
|
+
}
|
459
|
+
}
|
460
|
+
|
461
|
+
@mixin v-for-sm() {
|
462
|
+
@include v-mob-first(sm) {
|
463
|
+
@content;
|
464
|
+
}
|
465
|
+
}
|
466
|
+
|
467
|
+
@mixin v-for-md() {
|
468
|
+
@include v-mob-first(md) {
|
469
|
+
@content;
|
470
|
+
}
|
471
|
+
}
|
472
|
+
|
473
|
+
@mixin v-for-lg() {
|
474
|
+
@include v-mob-first(lg) {
|
475
|
+
@content;
|
476
|
+
}
|
477
|
+
}
|
478
|
+
|
479
|
+
@mixin v-for-xl() {
|
480
|
+
@include v-mob-first(xl) {
|
481
|
+
@content;
|
482
|
+
}
|
483
|
+
}
|
484
|
+
|
485
|
+
@mixin v-for-xxl() {
|
486
|
+
@include v-mob-first(xxl) {
|
487
|
+
@content;
|
488
|
+
}
|
489
|
+
}
|
490
|
+
|
491
|
+
@mixin v-before-xs() {
|
492
|
+
@include v-desk-first(xs) {
|
493
|
+
@content;
|
494
|
+
}
|
495
|
+
}
|
496
|
+
|
497
|
+
@mixin v-before-sm() {
|
498
|
+
@include v-desk-first(sm) {
|
499
|
+
@content;
|
500
|
+
}
|
501
|
+
}
|
502
|
+
|
503
|
+
@mixin v-before-md() {
|
504
|
+
@include v-desk-first(md) {
|
505
|
+
@content;
|
506
|
+
}
|
507
|
+
}
|
508
|
+
|
509
|
+
@mixin v-before-lg() {
|
510
|
+
@include v-desk-first(lg) {
|
511
|
+
@content;
|
512
|
+
}
|
513
|
+
}
|
514
|
+
|
515
|
+
@mixin v-before-xl() {
|
516
|
+
@include v-desk-first(xl) {
|
517
|
+
@content;
|
518
|
+
}
|
519
|
+
}
|
520
|
+
|
521
|
+
@mixin v-before-xxl() {
|
522
|
+
@include v-desk-first(xxl) {
|
523
|
+
@content;
|
524
|
+
}
|
525
|
+
}
|
526
|
+
```
|
527
|
+
|
528
|
+
### Practical Example of Using These Mixins
|
529
|
+
|
530
|
+
Here is an example of how to use these mixins in your SCSS code:
|
531
|
+
|
532
|
+
#### Horizontal Layout
|
533
|
+
|
534
|
+
```scss
|
535
|
+
.container {
|
536
|
+
// Base styles
|
537
|
+
width: 100%;
|
538
|
+
padding: 20px;
|
539
|
+
|
540
|
+
// Styles for `sm` breakpoint
|
541
|
+
@include for-sm {
|
542
|
+
width: 90%;
|
543
|
+
padding: 15px;
|
544
|
+
}
|
545
|
+
|
546
|
+
// Styles for `md` breakpoint
|
547
|
+
@include for-md {
|
548
|
+
width: 80%;
|
549
|
+
padding: 10px;
|
550
|
+
}
|
551
|
+
|
552
|
+
// Styles for `lg` breakpoint
|
553
|
+
@include for-lg {
|
554
|
+
width: 70%;
|
555
|
+
padding: 5px;
|
556
|
+
}
|
557
|
+
}
|
558
|
+
|
559
|
+
.header {
|
560
|
+
// Base styles
|
561
|
+
font-size: 16px;
|
562
|
+
background-color: white;
|
563
|
+
|
564
|
+
// Styles for `sm` breakpoint
|
565
|
+
@include before-sm {
|
566
|
+
font-size: 18px;
|
567
|
+
background-color: lightgray;
|
568
|
+
}
|
569
|
+
|
570
|
+
// Styles for `md` breakpoint
|
571
|
+
@include before-md {
|
572
|
+
font-size: 20px;
|
573
|
+
background-color: gray;
|
574
|
+
}
|
575
|
+
}
|
576
|
+
```
|
577
|
+
|
578
|
+
#### Vertical Layout
|
251
579
|
|
252
|
-
|
580
|
+
```scss
|
581
|
+
.panel {
|
582
|
+
// Base styles
|
583
|
+
height: 100%;
|
584
|
+
padding: 20px;
|
585
|
+
|
586
|
+
// Styles for `sm` vertical breakpoint
|
587
|
+
@include v-for-sm {
|
588
|
+
height: 90%;
|
589
|
+
padding: 15px;
|
590
|
+
}
|
253
591
|
|
254
|
-
|
255
|
-
-
|
256
|
-
|
592
|
+
// Styles for `md` vertical breakpoint
|
593
|
+
@include v-for-md {
|
594
|
+
height: 80%;
|
595
|
+
padding: 10px;
|
596
|
+
}
|
257
597
|
|
258
|
-
|
598
|
+
// Styles for `lg` vertical breakpoint
|
599
|
+
@include v-for-lg {
|
600
|
+
height: 70%;
|
601
|
+
padding: 5px;
|
602
|
+
}
|
603
|
+
}
|
259
604
|
|
260
|
-
|
261
|
-
|
605
|
+
.footer {
|
606
|
+
// Base styles
|
607
|
+
font-size: 16px;
|
608
|
+
background-color: white;
|
609
|
+
|
610
|
+
// Styles for `sm` vertical breakpoint
|
611
|
+
@include v-before-sm {
|
612
|
+
font-size: 18px;
|
613
|
+
background-color: lightgray;
|
614
|
+
}
|
262
615
|
|
263
|
-
|
616
|
+
// Styles for `md` vertical breakpoint
|
617
|
+
@include v-before-md {
|
618
|
+
font-size: 20px;
|
619
|
+
background-color: gray;
|
620
|
+
}
|
621
|
+
}
|
622
|
+
```
|
264
623
|
|
265
|
-
|
266
|
-
- `ForDF.ts`: Similar to `ForMF`, but uses the `useBreakpointDF` hook.
|
624
|
+
Now, the documentation is complete with examples of using the `for` and `before` mixins for both horizontal and vertical breakpoints, as well as the native mobile-first and desktop-first mixins.
|