@andreyshpigunov/x 0.4.3 → 0.5.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.
@@ -12,6 +12,8 @@ All right reserved.
12
12
  .color-warning
13
13
  .color-danger
14
14
  .color-error
15
+ .color-black
16
+ .color-white
15
17
  .color-grey
16
18
 
17
19
  .bg-primary
@@ -19,6 +21,8 @@ All right reserved.
19
21
  .bg-warning
20
22
  .bg-danger
21
23
  .bg-error
24
+ .bg-black
25
+ .bg-white
22
26
  .bg-grey
23
27
  */
24
28
 
@@ -28,6 +32,8 @@ All right reserved.
28
32
  --color-warning: #ff8800;
29
33
  --color-danger: #ee3333;
30
34
  --color-error: #ee3333;
35
+ --color-black: #fff;
36
+ --color-white: #000;
31
37
  --color-grey: #f4f5f6;
32
38
  }
33
39
 
@@ -46,6 +52,12 @@ All right reserved.
46
52
  .color-error {
47
53
  color: var(--color-error);
48
54
  }
55
+ .color-black {
56
+ color: var(--color-black);
57
+ }
58
+ .color-white {
59
+ color: var(--color-white);
60
+ }
49
61
  .color-grey {
50
62
  color: var(--color-grey);
51
63
  }
@@ -65,6 +77,12 @@ All right reserved.
65
77
  .bg-error {
66
78
  background-color: var(--color-error);
67
79
  }
80
+ .bg-black {
81
+ background-color: var(--color-black);
82
+ }
83
+ .bg-white {
84
+ background-color: var(--color-white);
85
+ }
68
86
  .bg-grey {
69
87
  background-color: var(--color-grey);
70
88
  }
@@ -87,24 +87,24 @@ All right reserved.
87
87
  .dropdown {
88
88
  position: relative;
89
89
 
90
- &.dropdown--right > [x-dropdown] {
90
+ &.dropdown_right > [x-dropdown] {
91
91
  right: 0;
92
92
  left: auto;
93
93
  }
94
- &.dropdown--bottom > [x-dropdown] {
94
+ &.dropdown_bottom > [x-dropdown] {
95
95
  bottom: 100%;
96
96
  top: auto;
97
97
  transform-origin: bottom;
98
98
  }
99
- &.dropdown--ready > [x-dropdown] {
99
+ &.dropdown_ready > [x-dropdown] {
100
100
  display: block;
101
101
  pointer-events: auto;
102
102
  }
103
- &.dropdown--open > [x-dropdown] {
103
+ &.dropdown_open > [x-dropdown] {
104
104
  opacity: 1;
105
105
  transform: scale(1);
106
106
  }
107
- &.dropdown--wrap > [x-dropdown] li {
107
+ &.dropdown_wrap > [x-dropdown] li {
108
108
  & > a,
109
109
  & > span {
110
110
  white-space: wrap;
@@ -46,7 +46,7 @@
46
46
  * Preventing auto-close on click:
47
47
  * ```html
48
48
  * <ul x-dropdown>
49
- * <li class="dropdown--stay">
49
+ * <li class="dropdown_stay">
50
50
  * <button>This area won't close dropdown</button>
51
51
  * </li>
52
52
  * </ul>
@@ -80,10 +80,10 @@
80
80
  * CSS classes:
81
81
  *
82
82
  * - `.dropdown` – Added to parent container
83
- * - `.dropdown--open` – Added when dropdown is open
84
- * - `.dropdown--right` – Added when menu needs to align right (overflow prevention)
85
- * - `.dropdown--bottom` – Added when menu needs to align bottom (overflow prevention)
86
- * - `.dropdown--ready` – Temporarily added during position calculation
83
+ * - `.dropdown_open` – Added when dropdown is open
84
+ * - `.dropdown_right` – Added when menu needs to align right (overflow prevention)
85
+ * - `.dropdown_bottom` – Added when menu needs to align bottom (overflow prevention)
86
+ * - `.dropdown_ready` – Temporarily added during position calculation
87
87
  * - `.active` – Added to trigger when dropdown is open
88
88
  * - `.hover` – Added on focus for better visual feedback
89
89
  *
@@ -123,7 +123,7 @@ import { lib } from './lib';
123
123
  * Features:
124
124
  * - Supports multiple dropdowns on the page.
125
125
  * - Keyboard navigation (Enter, Space, ArrowDown, ArrowUp, Home, End, Escape).
126
- * - Automatic positioning with overflow handling (adds `.dropdown--right`, `.dropdown--bottom`).
126
+ * - Automatic positioning with overflow handling (adds `.dropdown_right`, `.dropdown_bottom`).
127
127
  * - Adds `.hover` class on focus for triggers and menu items.
128
128
  * - Safe `init()` with cleanup and reinitialization support.
129
129
  *
@@ -412,7 +412,7 @@ class Dropdown {
412
412
  * @private
413
413
  */
414
414
  _toggleDropdown(parent, trigger) {
415
- const isOpen = parent.classList.contains('dropdown--open');
415
+ const isOpen = parent.classList.contains('dropdown_open');
416
416
  this.closeAllDropdowns();
417
417
  if (!isOpen) this._open(parent, trigger);
418
418
  }
@@ -432,7 +432,7 @@ class Dropdown {
432
432
  this._adjustPosition(parent, menu);
433
433
 
434
434
  lib.addClass(trigger, 'active');
435
- lib.addClass(parent, 'dropdown--open', 20);
435
+ lib.addClass(parent, 'dropdown_open', 20);
436
436
  trigger.setAttribute('aria-expanded', 'true');
437
437
 
438
438
  this._fireEvent(parent, 'aftershow');
@@ -446,22 +446,22 @@ class Dropdown {
446
446
  * @private
447
447
  */
448
448
  _adjustPosition(parent, menu) {
449
- parent.classList.add('dropdown--ready');
449
+ parent.classList.add('dropdown_ready');
450
450
  const rect = menu.getBoundingClientRect();
451
- parent.classList.remove('dropdown--ready');
451
+ parent.classList.remove('dropdown_ready');
452
452
 
453
453
  const vw = window.innerWidth;
454
454
  const docHeight = document.documentElement.scrollHeight;
455
455
 
456
- parent.classList.remove('dropdown--right', 'dropdown--bottom');
456
+ parent.classList.remove('dropdown_right', 'dropdown_bottom');
457
457
 
458
458
  if (rect.right > vw) {
459
- parent.classList.add('dropdown--right');
459
+ parent.classList.add('dropdown_right');
460
460
  }
461
461
 
462
462
  const menuBottomInDoc = window.scrollY + rect.bottom;
463
463
  if (menuBottomInDoc > docHeight) {
464
- parent.classList.add('dropdown--bottom');
464
+ parent.classList.add('dropdown_bottom');
465
465
  }
466
466
  }
467
467
 
@@ -498,8 +498,8 @@ class Dropdown {
498
498
  * dropdown.closeAllDropdowns();
499
499
  */
500
500
  closeAllDropdowns() {
501
- if (!document.querySelector('.dropdown--open')) return;
502
- const openDropdowns = lib.qsa('.dropdown--open');
501
+ if (!document.querySelector('.dropdown_open')) return;
502
+ const openDropdowns = lib.qsa('.dropdown_open');
503
503
  for (const parent of openDropdowns) {
504
504
  this._close(parent);
505
505
  }
@@ -523,8 +523,8 @@ class Dropdown {
523
523
  trigger.setAttribute('aria-expanded', 'false');
524
524
  }
525
525
 
526
- await lib.removeClass(parent, 'dropdown--open', 200);
527
- parent.classList.remove('dropdown--right', 'dropdown--bottom');
526
+ await lib.removeClass(parent, 'dropdown_open', 200);
527
+ parent.classList.remove('dropdown_right', 'dropdown_bottom');
528
528
 
529
529
  this._fireEvent(parent, 'afterhide');
530
530
 
@@ -551,8 +551,8 @@ class Dropdown {
551
551
  if (Dropdown._globalListenersAttached) return;
552
552
 
553
553
  this._globalClickHandler = e => {
554
- if (e.target.closest('[x-dropdown-open]') || e.target.closest('[x-dropdown] .dropdown--stay')) return;
555
- if (!document.querySelector('.dropdown--open')) return;
554
+ if (e.target.closest('[x-dropdown-open]') || e.target.closest('[x-dropdown] .dropdown_stay')) return;
555
+ if (!document.querySelector('.dropdown_open')) return;
556
556
  this.closeAllDropdowns();
557
557
  };
558
558
  document.addEventListener('click', this._globalClickHandler);
@@ -30,10 +30,6 @@ All right reserved.
30
30
  */
31
31
 
32
32
  .flex { display: flex }
33
- @media (min-width: 640px) { .s\:flex { display: flex } }
34
- @media (min-width: 768px) { .m\:flex { display: flex } }
35
- @media (min-width: 1024px) { .l\:flex { display: flex } }
36
- @media (min-width: 1280px) { .xl\:flex { display: flex } }
37
33
 
38
34
  [class*=flex] {
39
35
  /* Columns */
@@ -14,10 +14,6 @@ All right reserved.
14
14
  */
15
15
 
16
16
  .grid { display: grid }
17
- @media (min-width: 640px) { .s\:grid { display: grid } }
18
- @media (min-width: 768px) { .m\:grid { display: grid } }
19
- @media (min-width: 1024px) { .l\:grid { display: grid } }
20
- @media (min-width: 1280px) { .xl\:grid { display: grid } }
21
17
 
22
18
  [class*=grid] {
23
19
  width: 100%;
@@ -49,15 +49,15 @@ All right reserved.
49
49
  .ratio2x3 (s,m,l,xl)
50
50
  .ratio3x4 (s,m,l,xl)
51
51
  .ratio9x16 (s,m,l,xl)
52
- .break-word
53
- .visually-hidden
52
+ .breakWord
53
+ .visuallyHidden
54
54
  .invisible
55
55
  .scroll-responsive
56
56
  .hidden (s,m,l,xl)
57
57
  .hidden-next (s,m,l,xl)
58
58
  .block (s,m,l,xl)
59
59
  .inline (s,m,l,xl)
60
- .inline-block (s,m,l,xl)
60
+ .inlineBlock (s,m,l,xl)
61
61
  .fullscreen
62
62
  .max (s,m,l,xl)
63
63
  .w[10-190] step 10 (s,m,l,xl)
@@ -455,11 +455,11 @@ html.touch .touch-hide { display: none }
455
455
 
456
456
 
457
457
  /* !- Break word, invisible, scroll */
458
- .break-word {
458
+ .breakWord {
459
459
  overflow-wrap: anywhere;
460
460
  word-break: break-word;
461
461
  }
462
- .visually-hidden {
462
+ .visuallyHidden {
463
463
  position: absolute;
464
464
  top: 0;
465
465
  left: 0;
@@ -479,6 +479,13 @@ html.touch .touch-hide { display: none }
479
479
  }
480
480
 
481
481
 
482
+ /* !- Display */
483
+ .block { display: block }
484
+ .inline { display: inline }
485
+ .inlineBlock { display: inline-block }
486
+ .table { display: table }
487
+
488
+
482
489
  /* !- Hidden */
483
490
  .hidden,
484
491
  .hidden-next + * { display: none }
@@ -502,34 +509,37 @@ html.touch .touch-hide { display: none }
502
509
 
503
510
 
504
511
  /* !- Display */
505
- .block { display: block }
506
- .inline { display: inline }
507
- .inline-block { display: inline-block }
508
- .table { display: table }
509
-
510
512
  @media (min-width: 640px) {
511
513
  .s\:block { display: block }
512
514
  .s\:inline { display: inline }
513
- .s\:inline-block { display: inline-block }
515
+ .s\:inlineBlock { display: inline-block }
514
516
  .s\:table { display: table }
517
+ .s\:flex { display: flex }
518
+ .s\:grid { display: grid }
515
519
  }
516
520
  @media (min-width: 768px) {
517
521
  .m\:block { display: block }
518
522
  .m\:inline { display: inline }
519
- .m\:inline-block { display: inline-block }
523
+ .m\:inlineBlock { display: inline-block }
520
524
  .m\:table { display: table }
525
+ .m\:flex { display: flex }
526
+ .m\:grid { display: grid }
521
527
  }
522
528
  @media (min-width: 1024px) {
523
529
  .l\:block { display: block }
524
530
  .l\:inline { display: inline }
525
- .l\:inline-block { display: inline-block }
531
+ .l\:inlineBlock { display: inline-block }
526
532
  .l\:table { display: table }
533
+ .l\:flex { display: flex }
534
+ .l\:grid { display: grid }
527
535
  }
528
536
  @media (min-width: 1280px) {
529
537
  .xl\:block { display: block }
530
538
  .xl\:inline { display: inline }
531
- .xl\:inline-block { display: inline-block }
539
+ .xl\:inlineBlock { display: inline-block }
532
540
  .xl\:table { display: table }
541
+ .xl\:flex { display: flex }
542
+ .xl\:grid { display: grid }
533
543
  }
534
544
 
535
545
 
@@ -9,7 +9,7 @@ All right reserved.
9
9
 
10
10
  /*
11
11
  .icon - base icon style
12
- .icon.s[10-60] step 2 (m,l) - icon size in px
12
+ .icon[10-60] step 2 (m,l) - icon size in px
13
13
  */
14
14
 
15
15
  .icon,
@@ -27,9 +27,9 @@ All right reserved.
27
27
  }
28
28
 
29
29
  @for $i from 10 to 60 by 2 {
30
- .icon.s$(i),
31
- .icon.s$(i) > svg,
32
- .icon.s$(i) > img {
30
+ .icon$(i),
31
+ .icon$(i) > svg,
32
+ .icon$(i) > img {
33
33
  width: calc($(i)rem / 10);
34
34
  height: calc($(i)rem / 10);
35
35
  }
@@ -37,9 +37,9 @@ All right reserved.
37
37
 
38
38
  @media (min-width: 768px) {
39
39
  @for $i from 10 to 60 by 2 {
40
- .m\:icon.s$(i),
41
- .m\:icon.s$(i) > svg,
42
- .m\:icon.s$(i) > img {
40
+ .m\:icon$(i),
41
+ .m\:icon$(i) > svg,
42
+ .m\:icon$(i) > img {
43
43
  width: calc($(i)rem / 10);
44
44
  height: calc($(i)rem / 10);
45
45
  }
@@ -48,9 +48,9 @@ All right reserved.
48
48
 
49
49
  @media (min-width: 1024px) {
50
50
  @for $i from 10 to 60 by 2 {
51
- .l\:icon.s$(i),
52
- .l\:icon.s$(i) > svg,
53
- .l\:icon.s$(i) > img {
51
+ .l\:icon$(i),
52
+ .l\:icon$(i) > svg,
53
+ .l\:icon$(i) > img {
54
54
  width: calc($(i)rem / 10);
55
55
  height: calc($(i)rem / 10);
56
56
  }
@@ -90,8 +90,8 @@
90
90
  * const items = lib.qsa('li', container);
91
91
  *
92
92
  * Classes with delay (for transitions):
93
- * await lib.addClass('.element', 'active', 100); // Adds --ready class, waits 100ms, then adds active
94
- * await lib.removeClass('.element', 'active', 200); // Removes active, waits 200ms, removes --ready
93
+ * await lib.addClass('.element', 'active', 100); // Adds _ready class, waits 100ms, then adds active
94
+ * await lib.removeClass('.element', 'active', 200); // Removes active, waits 200ms, removes _ready
95
95
  *
96
96
  * Formatting:
97
97
  * lib.price(1234.56); // "1 234.56"
@@ -333,7 +333,7 @@ class Lib {
333
333
  if (!len) return;
334
334
 
335
335
  if (delay > 0) {
336
- const readyClass = className.replace(/--.*/, '') + '--ready';
336
+ const readyClass = className.replace(/_.*/, '') + '_ready';
337
337
  for (let i = 0; i < len; i++) items[i].classList.add(readyClass);
338
338
  await new Promise(res => setTimeout(res, delay));
339
339
  }
@@ -357,7 +357,7 @@ class Lib {
357
357
 
358
358
  if (delay > 0) {
359
359
  await new Promise(res => setTimeout(res, delay));
360
- const readyClass = className.replace(/--.*/, '') + '--ready';
360
+ const readyClass = className.replace(/_.*/, '') + '_ready';
361
361
  for (let i = 0; i < len; i++) items[i].classList.remove(readyClass);
362
362
  }
363
363
  }
@@ -14,11 +14,11 @@ All right reserved.
14
14
  a.link
15
15
  a.hover
16
16
  a.active
17
- a.link--noline
18
- a.link--underline
19
- a.link--dashed
20
- a.link--dotted
21
- a.link--wavy
17
+ a.link_noline
18
+ a.link_underline
19
+ a.link_dashed
20
+ a.link_dotted
21
+ a.link_wavy
22
22
  */
23
23
 
24
24
  :root {
@@ -82,19 +82,19 @@ a {
82
82
 
83
83
  /* Link predefined styles */
84
84
 
85
- &.link--noline {
85
+ &.link_noline {
86
86
  --link-decoration-line: none;
87
87
  }
88
- &.link--underline {
88
+ &.link_underline {
89
89
  --link-decoration-line: underline;
90
90
  }
91
- &.link--dashed {
91
+ &.link_dashed {
92
92
  --link-decoration-style: dashed;
93
93
  }
94
- &.link--dotted {
94
+ &.link_dotted {
95
95
  --link-decoration-style: dotted;
96
96
  }
97
- &.link--wavy {
97
+ &.link_wavy {
98
98
  --link-decoration-style: wavy;
99
99
  }
100
100
  }
@@ -49,21 +49,21 @@ html.modal--active body {
49
49
  pointer-events: none;
50
50
  display: none;
51
51
  }
52
- .modal--ready {
52
+ .modal_ready {
53
53
  z-index: 10000;
54
54
  pointer-events: all;
55
55
  display: block;
56
56
  }
57
- .modal--z1 { z-index: 10001 }
58
- .modal--z2 { z-index: 10002 }
59
- .modal--z3 { z-index: 10003 }
60
- .modal--z4 { z-index: 10004 }
61
- .modal--z5 { z-index: 10005 }
62
- .modal--z6 { z-index: 10006 }
63
- .modal--z7 { z-index: 10007 }
64
- .modal--z8 { z-index: 10008 }
65
- .modal--z9 { z-index: 10009 }
66
- .modal--z10 { z-index: 10010 }
57
+ .modal_z1 { z-index: 10001 }
58
+ .modal_z2 { z-index: 10002 }
59
+ .modal_z3 { z-index: 10003 }
60
+ .modal_z4 { z-index: 10004 }
61
+ .modal_z5 { z-index: 10005 }
62
+ .modal_z6 { z-index: 10006 }
63
+ .modal_z7 { z-index: 10007 }
64
+ .modal_z8 { z-index: 10008 }
65
+ .modal_z9 { z-index: 10009 }
66
+ .modal_z10 { z-index: 10010 }
67
67
 
68
68
  /* !- Overlay */
69
69
  .modal-overlay {
@@ -161,7 +161,7 @@ html.modal--active body {
161
161
  }
162
162
  }
163
163
  }
164
- .modal--active .modal-rail {
164
+ .modal_active .modal-rail {
165
165
 
166
166
  .modal-close {
167
167
  opacity: 1;
@@ -187,7 +187,7 @@ html.modal--active body {
187
187
  opacity: 0;
188
188
  transition: opacity .2s ease-out;
189
189
  }
190
- &.modal--active .modal-overlay {
190
+ &.modal_active .modal-overlay {
191
191
  opacity: 1;
192
192
  }
193
193
  }
@@ -201,68 +201,68 @@ html.modal--active body {
201
201
  transform-origin: center top;
202
202
  transition: all .2s ease-out;
203
203
  }
204
- &.modal--active .modal-window {
204
+ &.modal_active .modal-window {
205
205
  transform: scale(1);
206
206
  opacity: 1;
207
207
  }
208
208
  }
209
209
 
210
210
  /* !- Zoom in */
211
- .modal--effect-in {
211
+ .modal_effect-in {
212
212
  & .modal-window {
213
213
  transform: scale(.9);
214
214
  }
215
- &.modal--active .modal-window {
215
+ &.modal_active .modal-window {
216
216
  transform: scale(1);
217
217
  }
218
218
  }
219
219
 
220
220
  /* !- Zoom out */
221
- .modal--effect-out {
221
+ .modal_effect-out {
222
222
  & .modal-window {
223
223
  transform: scale(1.1);
224
224
  }
225
- &.modal--active .modal-window {
225
+ &.modal_active .modal-window {
226
226
  transform: scale(1);
227
227
  }
228
228
  }
229
229
 
230
230
  /* !- Slide up */
231
- .modal--effect-up {
231
+ .modal_effect-up {
232
232
  & .modal-window {
233
233
  transform: translateY(30px);
234
234
  }
235
- &.modal--active .modal-window {
235
+ &.modal_active .modal-window {
236
236
  transform: translateY(0);
237
237
  }
238
238
  }
239
239
 
240
240
  /* !- Slide down */
241
- .modal--effect-down {
241
+ .modal_effect-down {
242
242
  & .modal-window {
243
243
  transform: translateY(-30px);
244
244
  }
245
- &.modal--active .modal-window {
245
+ &.modal_active .modal-window {
246
246
  transform: translateY(0);
247
247
  }
248
248
  }
249
249
 
250
250
  /* !- Slide from left */
251
- .modal--effect-left {
251
+ .modal_effect-left {
252
252
  & .modal-window {
253
253
  transform: translateX(-30px);
254
254
  }
255
- &.modal--active .modal-window {
255
+ &.modal_active .modal-window {
256
256
  transform: translateX(0);
257
257
  }
258
258
  }
259
259
 
260
260
  /* !- Slide from right */
261
- .modal--effect-right {
261
+ .modal_effect-right {
262
262
  & .modal-window {
263
263
  transform: translateX(30px);
264
264
  }
265
- &.modal--active .modal-window {
265
+ &.modal_active .modal-window {
266
266
  transform: translateX(0);
267
267
  }
268
268
  }