@formixru/b2b-ui 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/CONTRIBUTING.md +61 -0
- package/README.md +30 -0
- package/package.json +110 -0
- package/src/base.scss +89 -0
- package/src/components/action-list/index.scss +38 -0
- package/src/components/banner/index.scss +30 -0
- package/src/components/breadcrumbs/index.js +8 -0
- package/src/components/breadcrumbs/index.scss +55 -0
- package/src/components/button/index.scss +223 -0
- package/src/components/checkbox/index.scss +94 -0
- package/src/components/color-input/index.scss +88 -0
- package/src/components/color-input/index.vue +156 -0
- package/src/components/date-input/index.scss +126 -0
- package/src/components/date-input/index.vue +240 -0
- package/src/components/delete-all/index.scss +44 -0
- package/src/components/dialog/index.js +221 -0
- package/src/components/dialog/index.scss +198 -0
- package/src/components/empty-list/index.scss +97 -0
- package/src/components/file-input/index.scss +119 -0
- package/src/components/file-input/index.vue +333 -0
- package/src/components/font-input/index.scss +47 -0
- package/src/components/font-input/index.vue +154 -0
- package/src/components/form/index.js +228 -0
- package/src/components/form/index.scss +398 -0
- package/src/components/header-announcement/index.scss +48 -0
- package/src/components/input/index.js +85 -0
- package/src/components/input/index.scss +87 -0
- package/src/components/link/index.scss +266 -0
- package/src/components/loader/index.js +65 -0
- package/src/components/loader/index.scss +99 -0
- package/src/components/nobr/index.scss +5 -0
- package/src/components/overlay/index.js +82 -0
- package/src/components/overlay/index.scss +29 -0
- package/src/components/pagination/index.scss +59 -0
- package/src/components/pagination-group/index.js +5 -0
- package/src/components/pagination-group/index.scss +86 -0
- package/src/components/quantity-input/index.scss +179 -0
- package/src/components/quantity-input/index.vue +141 -0
- package/src/components/radio/index.scss +80 -0
- package/src/components/radio-list/index.scss +79 -0
- package/src/components/range-input/index.scss +109 -0
- package/src/components/range-input/index.vue +185 -0
- package/src/components/rating-input/index.js +32 -0
- package/src/components/rating-input/index.scss +36 -0
- package/src/components/select/index.js +6 -0
- package/src/components/select/index.scss +84 -0
- package/src/components/sidebar/index.js +174 -0
- package/src/components/sidebar/index.scss +398 -0
- package/src/components/simple-page/index.scss +32 -0
- package/src/components/slider-nav/index.scss +82 -0
- package/src/components/slider-pagination/index.scss +130 -0
- package/src/components/spinner/index.scss +35 -0
- package/src/components/sr-only/index.scss +25 -0
- package/src/components/steps/index.scss +155 -0
- package/src/components/suggest-input/index.scss +141 -0
- package/src/components/suggest-input/index.vue +324 -0
- package/src/components/tabs/index.js +192 -0
- package/src/components/tabs/index.scss +137 -0
- package/src/components/time-select/index.scss +27 -0
- package/src/components/toggle/index.scss +76 -0
- package/src/components/tooltip/index.js +69 -0
- package/src/components/tooltip/index.scss +112 -0
- package/src/components/total/index.scss +162 -0
- package/src/components/warning-message/index.scss +170 -0
- package/src/components/warning-message/index.vue +94 -0
- package/src/components/wysiwyg/index.scss +344 -0
- package/src/helpers/css-var.js +8 -0
- package/src/helpers/error-handler.js +61 -0
- package/src/helpers/get-smart-captcha.js +7 -0
- package/src/helpers/is-in-viewport.js +10 -0
- package/src/helpers/mm.js +52 -0
- package/src/helpers/scroll-to.js +21 -0
- package/src/variables.scss +1295 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
@use '../../variables' as *;
|
|
2
|
+
|
|
3
|
+
$b: '.wysiwyg';
|
|
4
|
+
$block: true !default;
|
|
5
|
+
|
|
6
|
+
@mixin wysiwyg() {
|
|
7
|
+
color: $wysiwyg-color;
|
|
8
|
+
|
|
9
|
+
@include font($wysiwyg-font);
|
|
10
|
+
|
|
11
|
+
a:not(.link, .button) {
|
|
12
|
+
color: $wysiwyg-link-color;
|
|
13
|
+
text-decoration: none;
|
|
14
|
+
transition-duration: var(--duration-micro-s);
|
|
15
|
+
transition-property: color;
|
|
16
|
+
transition-timing-function: var(--easing-standard);
|
|
17
|
+
|
|
18
|
+
@include ul-solid($wysiwyg-link-color);
|
|
19
|
+
|
|
20
|
+
&:hover,
|
|
21
|
+
&:focus-visible {
|
|
22
|
+
color: $wysiwyg-link-active-color;
|
|
23
|
+
|
|
24
|
+
@include ul-solid($wysiwyg-link-active-color);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
h1,
|
|
29
|
+
#{$b}__h1 {
|
|
30
|
+
color: $wysiwyg-h1-color;
|
|
31
|
+
|
|
32
|
+
@include font($wysiwyg-h1-mobile-font);
|
|
33
|
+
|
|
34
|
+
@media (--tablet-landscape-up) {
|
|
35
|
+
@include font($wysiwyg-h1-desktop-font);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&:not(:last-child) {
|
|
39
|
+
margin-bottom: 4px * 8;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
h2,
|
|
44
|
+
#{$b}__h2 {
|
|
45
|
+
color: $wysiwyg-h2-color;
|
|
46
|
+
|
|
47
|
+
@include font($wysiwyg-h2-mobile-font);
|
|
48
|
+
|
|
49
|
+
@media (--tablet-landscape-up) {
|
|
50
|
+
@include font($wysiwyg-h2-desktop-font);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&:not(:first-child) {
|
|
54
|
+
margin-top: 4px * 8;
|
|
55
|
+
|
|
56
|
+
@media (--tablet-landscape-up) {
|
|
57
|
+
margin-top: 4px * 12;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&:not(:last-child) {
|
|
62
|
+
margin-bottom: 4px * 4;
|
|
63
|
+
|
|
64
|
+
@media (--tablet-landscape-up) {
|
|
65
|
+
margin-bottom: 4px * 8;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
h3,
|
|
71
|
+
#{$b}__h3 {
|
|
72
|
+
color: $wysiwyg-h3-color;
|
|
73
|
+
|
|
74
|
+
@include font($wysiwyg-h3-mobile-font);
|
|
75
|
+
|
|
76
|
+
@media (--tablet-landscape-up) {
|
|
77
|
+
@include font($wysiwyg-h3-desktop-font);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&:not(:first-child) {
|
|
81
|
+
margin-top: 4px * 8;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&:not(:last-child) {
|
|
85
|
+
margin-bottom: 4px * 4;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
h4,
|
|
90
|
+
#{$b}__h4 {
|
|
91
|
+
color: $wysiwyg-h4-color;
|
|
92
|
+
|
|
93
|
+
@include font($wysiwyg-h4-mobile-font);
|
|
94
|
+
|
|
95
|
+
@media (--tablet-landscape-up) {
|
|
96
|
+
@include font($wysiwyg-h4-desktop-font);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&:not(:first-child) {
|
|
100
|
+
margin-top: 4px * 8;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&:not(:last-child) {
|
|
104
|
+
margin-bottom: 4px * 4;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
p {
|
|
109
|
+
&:not(:last-child) {
|
|
110
|
+
margin-bottom: 4px * 4;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
ul {
|
|
115
|
+
list-style-type: disc;
|
|
116
|
+
margin-left: 1em;
|
|
117
|
+
|
|
118
|
+
ul,
|
|
119
|
+
ol {
|
|
120
|
+
padding-left: 1em;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
ul {
|
|
124
|
+
list-style-type: circle;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&:not(:last-child) {
|
|
128
|
+
margin-bottom: 4px * 4;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
li {
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
ol {
|
|
136
|
+
counter-reset: list;
|
|
137
|
+
|
|
138
|
+
ul,
|
|
139
|
+
ol {
|
|
140
|
+
padding-left: 1em;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
&:not(:last-child) {
|
|
144
|
+
margin-bottom: 4px * 4;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
li,
|
|
148
|
+
li > ol > li {
|
|
149
|
+
&::before {
|
|
150
|
+
content: counters(list, '.') '. ';
|
|
151
|
+
counter-increment: list;
|
|
152
|
+
font-weight: bold;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
img,
|
|
158
|
+
svg {
|
|
159
|
+
border-radius: $wysiwyg-image-radius;
|
|
160
|
+
display: block;
|
|
161
|
+
max-width: 100%;
|
|
162
|
+
|
|
163
|
+
&:not(:first-child) {
|
|
164
|
+
margin-top: 4px * 8;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
&:not(:last-child) {
|
|
168
|
+
margin-bottom: 4px * 8;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
&#{$b}__float {
|
|
172
|
+
&_right {
|
|
173
|
+
@media (--tablet-landscape-up) {
|
|
174
|
+
float: right;
|
|
175
|
+
margin-bottom: 0;
|
|
176
|
+
margin-left: 4px * 6;
|
|
177
|
+
margin-top: 0;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
&_left {
|
|
182
|
+
@media (--tablet-landscape-up) {
|
|
183
|
+
float: left;
|
|
184
|
+
margin-bottom: 0;
|
|
185
|
+
margin-right: 4px * 6;
|
|
186
|
+
margin-top: 0;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
&#{$b}__fluid-image {
|
|
192
|
+
width: 100%;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
#{$b}__table {
|
|
197
|
+
overflow: auto;
|
|
198
|
+
-webkit-overflow-scrolling: touch;
|
|
199
|
+
|
|
200
|
+
&:not(:first-child) {
|
|
201
|
+
margin-top: 4px * 8;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
&:not(:last-child) {
|
|
205
|
+
margin-bottom: 4px * 8;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
table {
|
|
209
|
+
width: 100%;
|
|
210
|
+
|
|
211
|
+
@include font($wysiwyg-table-font);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
th,
|
|
215
|
+
td {
|
|
216
|
+
padding: 4px * 4 4px * 3;
|
|
217
|
+
|
|
218
|
+
&:first-child {
|
|
219
|
+
padding-left: 4px * 6;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
&:last-child {
|
|
223
|
+
padding-right: 4px * 6;
|
|
224
|
+
text-align: right;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
thead {
|
|
229
|
+
th {
|
|
230
|
+
background-color: $wysiwyg-table-header-bg;
|
|
231
|
+
color: $wysiwyg-table-header-color;
|
|
232
|
+
text-align: left;
|
|
233
|
+
|
|
234
|
+
@include font($wysiwyg-table-header-font);
|
|
235
|
+
|
|
236
|
+
&:first-child {
|
|
237
|
+
border-bottom-left-radius: $wysiwyg-table-radius;
|
|
238
|
+
border-top-left-radius: $wysiwyg-table-radius;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
&:last-child {
|
|
242
|
+
border-bottom-right-radius: $wysiwyg-table-radius;
|
|
243
|
+
border-top-right-radius: $wysiwyg-table-radius;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
tbody {
|
|
249
|
+
td {
|
|
250
|
+
border-bottom: $wysiwyg-table-separator-width solid $wysiwyg-table-separator-color;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
&_zebra {
|
|
255
|
+
background-color: $wysiwyg-table-zebra-bg;
|
|
256
|
+
border-radius: $wysiwyg-table-radius;
|
|
257
|
+
box-shadow: $wysiwyg-table-zebra-shadow;
|
|
258
|
+
|
|
259
|
+
thead {
|
|
260
|
+
th {
|
|
261
|
+
&:first-child {
|
|
262
|
+
border-bottom-left-radius: 0;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
&:last-child {
|
|
266
|
+
border-bottom-right-radius: 0;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
tbody {
|
|
272
|
+
tr {
|
|
273
|
+
&:nth-child(even) {
|
|
274
|
+
td {
|
|
275
|
+
background-color: $wysiwyg-table-zebra-td-bg;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
&:last-child {
|
|
280
|
+
td {
|
|
281
|
+
&:first-child {
|
|
282
|
+
border-bottom-left-radius: $wysiwyg-table-radius;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
&:last-child {
|
|
286
|
+
border-bottom-right-radius: $wysiwyg-table-radius;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
td {
|
|
293
|
+
border-bottom-style: none;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
#{$b}__alert {
|
|
300
|
+
background-color: $wysiwyg-alert-bg;
|
|
301
|
+
border-radius: $wysiwyg-alert-radius;
|
|
302
|
+
color: $wysiwyg-alert-color;
|
|
303
|
+
padding-top: 4px * 4;
|
|
304
|
+
|
|
305
|
+
@media (--tablet-landscape-up) {
|
|
306
|
+
padding: 4px * 6 4px * 8;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
&:not(:first-child) {
|
|
310
|
+
margin-top: 4px * 8;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
&:not(:last-child) {
|
|
314
|
+
margin-bottom: 4px * 8;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
&_warning {
|
|
318
|
+
background-color: $wysiwyg-alert-warning-bg;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
> * {
|
|
322
|
+
color: $wysiwyg-alert-color;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
a:not(.link, .button) {
|
|
326
|
+
color: $wysiwyg-alert-link-color;
|
|
327
|
+
|
|
328
|
+
@include ul-solid($wysiwyg-alert-link-color);
|
|
329
|
+
|
|
330
|
+
&:hover,
|
|
331
|
+
&:focus-visible {
|
|
332
|
+
color: $wysiwyg-alert-active-link-color;
|
|
333
|
+
|
|
334
|
+
@include ul-solid($wysiwyg-alert-active-link-color);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
@if $block == true {
|
|
341
|
+
#{$b} {
|
|
342
|
+
@include wysiwyg;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const cssVar = (name, element = document.documentElement) => {
|
|
2
|
+
const value = window.getComputedStyle(element).getPropertyValue(name);
|
|
3
|
+
const durationRegExp = new RegExp(/(^[\d.]+)s$/);
|
|
4
|
+
if (durationRegExp.test(value)) {
|
|
5
|
+
return durationRegExp.exec(value)[1] * 1000;
|
|
6
|
+
}
|
|
7
|
+
return value;
|
|
8
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { is } from '@advdominion/is';
|
|
2
|
+
|
|
3
|
+
import { show as showDialog } from '../components/dialog/index.js';
|
|
4
|
+
|
|
5
|
+
export const errorHandler = async (error) => {
|
|
6
|
+
if (!document.querySelector('#error-handler')) {
|
|
7
|
+
document.body.insertAdjacentHTML(
|
|
8
|
+
'beforeend',
|
|
9
|
+
`
|
|
10
|
+
<div id="error-handler" class="dialog dialog_s" hidden>
|
|
11
|
+
<div class="dialog__wrapper">
|
|
12
|
+
<button class="dialog__close" type="button" data-dialog-close>
|
|
13
|
+
<svg class="dialog__close-icon"><use href="${window.ICONS_PATH}#close" /></svg>
|
|
14
|
+
</button>
|
|
15
|
+
<div class="dialog__container">
|
|
16
|
+
<div class="dialog__title">Произошла ошибка</div>
|
|
17
|
+
<div class="dialog__descr wysiwyg"></div>
|
|
18
|
+
<div class="dialog__action-list">
|
|
19
|
+
<button class="dialog__action-item button" type="button" data-dialog-close>Закрыть</button>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
`,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const $dialog = document.querySelector('#error-handler');
|
|
28
|
+
let content = '<p>Не удаётся выполнить действие. Перезагрузите страницу или попробуйте позже</p>';
|
|
29
|
+
if (is(error, 'Error')) {
|
|
30
|
+
content += `<pre>${error.toString()}</pre>`;
|
|
31
|
+
} else if (is(error, 'Response')) {
|
|
32
|
+
content = `<pre>${JSON.stringify(
|
|
33
|
+
{
|
|
34
|
+
url: error.url,
|
|
35
|
+
status: error.status,
|
|
36
|
+
statusText: error.statusText,
|
|
37
|
+
body: (await error.json()) || (await error.text()) || '',
|
|
38
|
+
},
|
|
39
|
+
undefined,
|
|
40
|
+
4,
|
|
41
|
+
)}</pre>`;
|
|
42
|
+
}
|
|
43
|
+
const $descr = $dialog.querySelector('.dialog__descr');
|
|
44
|
+
$descr.innerHTML = content;
|
|
45
|
+
$descr.style = `
|
|
46
|
+
overflow: auto;
|
|
47
|
+
`;
|
|
48
|
+
$dialog.addEventListener(
|
|
49
|
+
'dialog-hidden',
|
|
50
|
+
() => {
|
|
51
|
+
$descr.style = `
|
|
52
|
+
overflow: '';
|
|
53
|
+
`;
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
once: true,
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
showDialog($dialog);
|
|
60
|
+
console.error(error);
|
|
61
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const getSmartCaptcha = () => {
|
|
2
|
+
window.smartCaptcha = {};
|
|
3
|
+
const script = document.createElement('script');
|
|
4
|
+
script.src = 'https://smartcaptcha.yandexcloud.net/captcha.js?render=onload&onload=initSmartCaptcha';
|
|
5
|
+
script.async = true;
|
|
6
|
+
document.body.append(script);
|
|
7
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const isInViewport = ($el, offset = {}) => {
|
|
2
|
+
const rect = $el.getBoundingClientRect();
|
|
3
|
+
offset = Object.assign({ top: 0, left: 0, bottom: 0, right: 0 }, offset);
|
|
4
|
+
return (
|
|
5
|
+
rect.top >= offset.top &&
|
|
6
|
+
rect.left >= offset.left &&
|
|
7
|
+
rect.bottom <= window.innerHeight - offset.bottom &&
|
|
8
|
+
rect.right <= window.innerWidth - offset.right
|
|
9
|
+
);
|
|
10
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { cssVar } from './css-var.js';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
|
|
5
|
+
Использование:
|
|
6
|
+
|
|
7
|
+
mm('tablet-landscape-up')
|
|
8
|
+
mm('tablet-landscape-only')
|
|
9
|
+
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const devices = ['phone', 'tablet-portrait', 'tablet-landscape', 'desktop', 'big-desktop'];
|
|
13
|
+
|
|
14
|
+
export const deviceBreakpoint = (device, returnDeviceIndex = false) => {
|
|
15
|
+
const deviceIndex = devices.indexOf(device);
|
|
16
|
+
if (deviceIndex === -1) {
|
|
17
|
+
throw new Error(`Адаптивной точки ${device} не существует`);
|
|
18
|
+
}
|
|
19
|
+
const breakpoint = Number.parseInt(cssVar(`--breakpoint-${device}`));
|
|
20
|
+
if (returnDeviceIndex) {
|
|
21
|
+
return {
|
|
22
|
+
deviceIndex,
|
|
23
|
+
breakpoint,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return breakpoint;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const mm = (query) => {
|
|
30
|
+
query = query.split('-');
|
|
31
|
+
const device = query.length > 2 ? `${query[0]}-${query[1]}` : query[0];
|
|
32
|
+
const condition = query.length > 2 ? query[2] : query[1];
|
|
33
|
+
const { breakpoint, deviceIndex } = deviceBreakpoint(device, true);
|
|
34
|
+
let width;
|
|
35
|
+
switch (condition) {
|
|
36
|
+
case 'only': {
|
|
37
|
+
if (deviceIndex === devices.length - 1) {
|
|
38
|
+
width = `(min-width: ${breakpoint}px)`;
|
|
39
|
+
} else {
|
|
40
|
+
const nextDevice = devices[deviceIndex + 1];
|
|
41
|
+
const nextBreakpoint = Number.parseInt(cssVar(`--breakpoint-${nextDevice}`));
|
|
42
|
+
width = `(min-width: ${breakpoint}px) and (max-width: ${nextBreakpoint - 1}px)`;
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case 'up': {
|
|
47
|
+
width = `(min-width: ${breakpoint}px)`;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return window.matchMedia(width).matches;
|
|
52
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const scrollTo = ($el, offset = 0) => {
|
|
2
|
+
return new Promise((resolve) => {
|
|
3
|
+
const observer = new IntersectionObserver((entries) => {
|
|
4
|
+
if (entries[0].isIntersecting) {
|
|
5
|
+
observer.disconnect();
|
|
6
|
+
setTimeout(() => {
|
|
7
|
+
resolve();
|
|
8
|
+
}, 500);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
observer.observe($el);
|
|
12
|
+
|
|
13
|
+
const elementTop = $el.getBoundingClientRect().top + window.pageYOffset;
|
|
14
|
+
const offsetValue = (window.innerHeight * offset) / 100;
|
|
15
|
+
|
|
16
|
+
window.scrollTo({
|
|
17
|
+
top: elementTop - offsetValue,
|
|
18
|
+
behavior: 'smooth',
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
};
|