@broxus/react-uikit 0.5.0 → 0.5.2

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.
@@ -8,9 +8,24 @@ const js_utils_1 = require("@broxus/js-utils");
8
8
  const classnames_1 = __importDefault(require("classnames"));
9
9
  function addModalMode(...args) {
10
10
  (0, js_utils_1.addClass)(document?.documentElement, (0, classnames_1.default)(args ?? 'uk-modal-page'));
11
+ try {
12
+ const scrollWidth = (0, js_utils_1.getScrollWidth)();
13
+ if (document.documentElement.dir === 'rtl') {
14
+ document.documentElement.style.paddingLeft = `${scrollWidth}px`;
15
+ }
16
+ else {
17
+ document.documentElement.style.paddingRight = `${scrollWidth}px`;
18
+ }
19
+ }
20
+ catch { }
11
21
  }
12
22
  exports.addModalMode = addModalMode;
13
23
  function removeModalMode(...args) {
14
24
  (0, js_utils_1.removeClass)(document?.documentElement, (0, classnames_1.default)(args ?? 'uk-modal-page'));
25
+ try {
26
+ document.documentElement.style.paddingLeft = '';
27
+ document.documentElement.style.paddingRight = '';
28
+ }
29
+ catch { }
15
30
  }
16
31
  exports.removeModalMode = removeModalMode;
@@ -1,22 +1,13 @@
1
- // Name: List
2
- // Description: Styles for lists
1
+ // Name: Subnav
2
+ // Description: Component to create a sub navigation
3
3
  //
4
- // Component: `uk-list`
4
+ // Component: `uk-subnav`
5
5
  //
6
- // Modifiers: `uk-list-disc`
7
- // `uk-list-circle`
8
- // `uk-list-square`
9
- // `uk-list-decimal`
10
- // `uk-list-hyphen`
11
- // `uk-list-muted`
12
- // `uk-list-emphasis`
13
- // `uk-list-primary`
14
- // `uk-list-secondary`
15
- // `uk-list-bullet`
16
- // `uk-list-divider`
17
- // `uk-list-striped`
18
- // `uk-list-large`
19
- // `uk-list-collapse`
6
+ // Modifiers: `uk-subnav-divider`
7
+ // `uk-subnav-pill`
8
+ //
9
+ // States: `uk-active`
10
+ // `uk-first-column`
20
11
  //
21
12
  // ========================================================================
22
13
 
@@ -28,219 +19,200 @@
28
19
 
29
20
 
30
21
  /* ========================================================================
31
- Component: List
22
+ Component: Subnav
32
23
  ========================================================================== */
33
24
 
34
- .uk-list {
35
- list-style: none;
36
- padding: 0;
37
- }
38
-
39
- /*
40
- * Remove margin from the last-child
41
- */
42
-
43
- .uk-list > * > :last-child {
44
- margin-bottom: 0;
45
- }
46
-
47
25
  /*
48
- * Style
26
+ * 1. Allow items to wrap into the next line
27
+ * 2. Center items vertically if they have a different height
28
+ * 3. Gutter
29
+ * 4. Reset list
49
30
  */
50
31
 
51
- .uk-list > :nth-child(n+2),
52
- .uk-list > * > ul {
53
- margin-top: var(--list-margin-top);
54
- }
32
+ .uk-subnav {
33
+ /* 2 */
34
+ align-items: center;
35
+ display: flex;
55
36
 
37
+ /* 1 */
38
+ flex-wrap: wrap;
39
+ list-style: none;
56
40
 
57
- /* Marker modifiers
58
- * Moving `::marker` inside `::before` to style it differently
59
- * To style the `::marker` is currently only supported in Firefox and Safari
60
- ========================================================================== */
41
+ /* 3 */
42
+ margin-left: calc(var(--subnav-margin-horizontal) * -1);
61
43
 
62
- .uk-list-disc > *,
63
- .uk-list-circle > *,
64
- .uk-list-square > *,
65
- .uk-list-decimal > *,
66
- .uk-list-hyphen > * {
67
- padding-left: var(--list-padding-left);
44
+ /* 4 */
45
+ padding: 0;
46
+ @if mixin-exists(hook-subnav) {
47
+ @include hook-subnav;
48
+ }
68
49
  }
69
50
 
70
51
  /*
71
- * Type modifiers
52
+ * 1. Space is allocated solely based on content dimensions: 0 0 auto
53
+ * 2. Gutter
54
+ * 3. Create position context for dropdowns
72
55
  */
73
56
 
74
- .uk-list-decimal {
75
- counter-reset: decimal;
76
- }
57
+ .uk-subnav > * {
58
+ /* 1 */
59
+ flex: none;
77
60
 
78
- .uk-list-decimal > * {
79
- counter-increment: decimal;
80
- }
61
+ /* 2 */
62
+ padding-left: var(--subnav-margin-horizontal);
81
63
 
82
- [class*='uk-list'] > ::before {
83
- content: '';
84
- display: list-item;
85
- height: var(--list-marker-height);
86
- left: calc(var(--list-padding-left) * -1);
87
- list-style-position: inside;
88
- margin-bottom: calc(var(--list-marker-height) * -1);
64
+ /* 3 */
89
65
  position: relative;
90
- text-align: right;
91
- width: var(--list-padding-left);
92
- }
93
-
94
- .uk-list-disc > ::before {
95
- list-style-type: disc;
96
66
  }
97
67
 
98
- .uk-list-circle > ::before {
99
- list-style-type: circle;
100
- }
101
-
102
- .uk-list-square > ::before {
103
- list-style-type: square;
104
- }
105
68
 
106
- .uk-list-decimal > ::before {
107
- content: counter(decimal, decimal) '\200A.\00A0';
108
- }
109
-
110
- .uk-list-hyphen > ::before {
111
- content: '–\00A0\00A0';
112
- }
69
+ /* Items
70
+ ========================================================================== */
113
71
 
114
72
  /*
115
- * Color modifiers
73
+ * Items must target `a` elements to exclude other elements (e.g. dropdowns)
74
+ * Using `:first-child` instead of `a` to support `span` elements for text
75
+ * 1. Center content vertically, e.g. an icon
76
+ * 2. Imitate white space gap when using flexbox
77
+ * 3. Style
116
78
  */
117
79
 
118
- .uk-list-muted > ::before {
119
- color: var(--list-muted-color) !important;
120
- }
80
+ .uk-subnav > * > :first-child {
81
+ align-items: center;
121
82
 
122
- .uk-list-emphasis > ::before {
123
- color: var(--list-emphasis-color) !important;
124
- }
83
+ /* 3 */
84
+ color: var(--subnav-item-color);
125
85
 
126
- .uk-list-primary > ::before {
127
- color: var(--list-primary-color) !important;
128
- }
86
+ /* 2 */
87
+ column-gap: 0.25em;
129
88
 
130
- .uk-list-secondary > ::before {
131
- color: var(--list-secondary-color) !important;
89
+ /* 1 */
90
+ display: flex;
91
+ @if mixin-exists(hook-subnav-item) {
92
+ @include hook-subnav-item;
93
+ }
132
94
  }
133
95
 
134
-
135
- /* Image bullet modifier
136
- ========================================================================== */
137
-
138
- .uk-list-bullet > * {
139
- padding-left: var(--list-padding-left);
96
+ /* Hover + Focus */
97
+ .uk-subnav > * > a:hover,
98
+ .uk-subnav > * > a:focus {
99
+ color: var(--subnav-item-hover-color);
100
+ outline: none;
101
+ text-decoration: var(--subnav-item-hover-text-decoration);
102
+ @if mixin-exists(hook-subnav-item-hover) {
103
+ @include hook-subnav-item-hover;
104
+ }
140
105
  }
141
106
 
142
- .uk-list-bullet > ::before {
143
- background-position: 50% 50%;
144
- background-repeat: no-repeat;
145
- content: '';
146
- height: var(--list-marker-height);
147
- left: calc(var(--list-padding-left) * -1);
148
- margin-bottom: calc(var(--list-marker-height) * -1);
149
- position: relative;
150
- width: var(--list-padding-left);
151
- @if mixin-exists(svg-fill) {
152
- @include svg-fill($list-bullet-icon-image-path, '#000', $list-bullet-icon-color);
107
+ /* Active */
108
+ .uk-subnav > .uk-active > a {
109
+ color: var(--subnav-item-active-color);
110
+ @if mixin-exists(hook-subnav-item-active) {
111
+ @include hook-subnav-item-active;
153
112
  }
154
113
  }
155
114
 
156
115
 
157
- /* Style modifiers
116
+ /* Divider modifier
158
117
  ========================================================================== */
159
118
 
160
119
  /*
161
- * Divider
120
+ * Set gutter
162
121
  */
163
122
 
164
- .uk-list-divider > :nth-child(n+2) {
165
- border-top: var(--list-divider-border-width) solid var(--list-divider-border);
166
- margin-top: var(--list-divider-margin-top);
167
- padding-top: var(--list-divider-margin-top);
168
- @if mixin-exists(hook-list-divider) {
169
- @include hook-list-divider;
170
- }
123
+ .uk-subnav-divider {
124
+ margin-left: calc((var(--subnav-divider-margin-horizontal) * 2 + var(--subnav-divider-border-width)) * -1);
171
125
  }
172
126
 
173
127
  /*
174
- * Striped
128
+ * Align items and divider vertically
175
129
  */
176
130
 
177
- .uk-list-striped > * {
178
- padding: var(--list-striped-padding-vertical) var(--list-striped-padding-horizontal);
179
- @if mixin-exists(hook-list-striped) {
180
- @include hook-list-striped;
181
- }
131
+ .uk-subnav-divider > * {
132
+ align-items: center;
133
+ display: flex;
182
134
  }
183
135
 
184
- .uk-list-striped > :nth-of-type(odd) {
185
- background: var(--list-striped-background);
136
+ /*
137
+ * Divider
138
+ * 1. `nth-child` makes it also work without JS if it's only one row
139
+ */
140
+
141
+ .uk-subnav-divider > ::before {
142
+ border-left: var(--subnav-divider-border-width) solid transparent;
143
+ content: '';
144
+ height: var(--subnav-divider-border-height);
145
+ margin-left: calc(var(--subnav-divider-margin-horizontal) - var(subnav-margin-horizontal));
146
+ margin-right: var(--subnav-divider-margin-horizontal);
186
147
  }
187
148
 
188
- .uk-list-striped > :nth-child(n+2) {
189
- margin-top: 0;
149
+ /* 1 */
150
+ .uk-subnav-divider > :nth-child(n+2):not(.uk-first-column)::before {
151
+ border-left-color: var(--subnav-divider-border);
152
+ @if mixin-exists(hook-subnav-divider) {
153
+ @include hook-subnav-divider;
154
+ }
190
155
  }
191
156
 
192
157
 
193
- /* Size modifier
158
+ /* Pill modifier
194
159
  ========================================================================== */
195
160
 
196
- .uk-list-large > :nth-child(n+2),
197
- .uk-list-large > * > ul {
198
- margin-top: var(--list-large-margin-top);
161
+ .uk-subnav-pill > * > :first-child {
162
+ background: var(--subnav-pill-item-background);
163
+ color: var(--subnav-pill-item-color);
164
+ padding: var(--subnav-pill-item-padding-vertical) var(--subnav-pill-item-padding-horizontal);
165
+ @if mixin-exists(hook-subnav-pill-item) {
166
+ @include hook-subnav-pill-item;
167
+ }
199
168
  }
200
169
 
201
- .uk-list-collapse > :nth-child(n+2),
202
- .uk-list-collapse > * > ul {
203
- margin-top: 0;
170
+ /* Hover + Focus */
171
+ .uk-subnav-pill > * > a:hover,
172
+ .uk-subnav-pill > * > a:focus {
173
+ background-color: var(--subnav-pill-item-hover-background);
174
+ color: var(--subnav-pill-item-hover-color);
175
+ @if mixin-exists(hook-subnav-pill-item-hover) {
176
+ @include hook-subnav-pill-item-hover;
177
+ }
204
178
  }
205
179
 
206
- /*
207
- * Divider
208
- */
209
-
210
- .uk-list-large.uk-list-divider > :nth-child(n+2) {
211
- margin-top: var(--list-large-divider-margin-top);
212
- padding-top: var(--list-large-divider-margin-top);
180
+ /* OnClick */
181
+ .uk-subnav-pill > * > a:active {
182
+ background-color: var(--subnav-pill-item-onclick-background);
183
+ color: var(--subnav-pill-item-onclick-color);
184
+ @if mixin-exists(hook-subnav-pill-item-onclick) {
185
+ @include hook-subnav-pill-item-onclick;
186
+ }
213
187
  }
214
188
 
215
- .uk-list-collapse.uk-list-divider > :nth-child(n+2) {
216
- margin-top: 0;
217
- padding-top: 0;
189
+ /* Active */
190
+ .uk-subnav-pill > .uk-active > a {
191
+ background-color: var(--subnav-pill-item-active-background);
192
+ color: var(--subnav-pill-item-active-color);
193
+ @if mixin-exists(hook-subnav-pill-item-active) {
194
+ @include hook-subnav-pill-item-active;
195
+ }
218
196
  }
219
197
 
220
- /*
221
- * Striped
222
- */
223
-
224
- .uk-list-large.uk-list-striped > * {
225
- padding: var(--list-large-striped-padding-vertical) var(--list-large-striped-padding-horizontal);
226
- }
227
198
 
228
- .uk-list-collapse.uk-list-striped > * {
229
- padding-bottom: 0;
230
- padding-top: 0;
231
- }
199
+ /* Disabled
200
+ * The same for all style modifiers
201
+ ========================================================================== */
232
202
 
233
- .uk-list-large.uk-list-striped > :nth-child(n+2),
234
- .uk-list-collapse.uk-list-striped > :nth-child(n+2) {
235
- margin-top: 0;
203
+ .uk-subnav > .uk-disabled > a {
204
+ color: var(--subnav-item-disabled-color);
205
+ @if mixin-exists(hook-subnav-item-disabled) {
206
+ @include hook-subnav-item-disabled;
207
+ }
236
208
  }
237
209
 
238
210
 
239
211
  // Hooks
240
212
  // ========================================================================
241
213
 
242
- @if mixin-exists(hook-list-misc) {
243
- @include hook-list-misc;
214
+ @if mixin-exists(hook-subnav-misc) {
215
+ @include hook-subnav-misc;
244
216
  }
245
217
 
246
218
 
@@ -248,31 +220,39 @@
248
220
  // ========================================================================
249
221
 
250
222
  :root {
251
- --list-margin-top: var(--global-small-margin);
252
- --list-padding-left: #{$list-padding-left};
253
- --list-marker-height: calc(var(--global-line-height) * 1em);
254
- --list-muted-color: var(--global-muted-color);
255
- --list-emphasis-color: var(--global-emphasis-color);
256
- --list-primary-color: var(--global-primary-background);
257
- --list-secondary-color: var(--global-secondary-background);
258
- --list-bullet-icon-color: var(--global-color);
259
- --list-divider-margin-top: var(--global-small-margin);
260
- --list-divider-border-width: var(--global-border-width);
261
- --list-divider-border: var(--global-border);
262
- --list-striped-padding-vertical: var(--global-small-margin);
263
- --list-striped-padding-horizontal: var(--global-small-margin);
264
- --list-striped-background: var(--global-muted-background);
265
- --list-large-margin-top: var(--global-margin);
266
- --list-large-divider-margin-top: var(--global-margin);
267
- --list-large-striped-padding-vertical: var(--global-margin);
268
- --list-large-striped-padding-horizontal: var(--global-small-margin);
223
+ --subnav-margin-horizontal: #{$subnav-margin-horizontal};
224
+ --subnav-item-color: var(--global-muted-color);
225
+ --subnav-item-hover-color: var(--global-color);
226
+ --subnav-item-hover-text-decoration: #{$subnav-item-hover-text-decoration};
227
+ --subnav-item-active-color: var(--global-emphasis-color);
228
+ --subnav-divider-margin-horizontal: #{$subnav-margin-horizontal};
229
+ --subnav-divider-border-height: #{$subnav-divider-border-height};
230
+ --subnav-divider-border-width: var(--global-border-width);
231
+ --subnav-divider-border: var(--global-border);
232
+ --subnav-pill-item-padding-vertical: #{$subnav-pill-item-padding-vertical};
233
+ --subnav-pill-item-padding-horizontal: #{$subnav-pill-item-padding-horizontal};
234
+ --subnav-pill-item-background: #{$subnav-pill-item-background};
235
+ --subnav-pill-item-color: #{$subnav-item-color};
236
+ --subnav-pill-item-hover-background: var(--global-muted-background);
237
+ --subnav-pill-item-hover-color: var(--global-color);
238
+ --subnav-pill-item-onclick-background: #{$subnav-pill-item-hover-background};
239
+ --subnav-pill-item-onclick-color: #{$subnav-pill-item-hover-color};
240
+ --subnav-pill-item-active-background: var(--global-primary-background);
241
+ --subnav-pill-item-active-color: var(--global-inverse-color);
242
+ --subnav-item-disabled-color: var(--global-muted-color);
269
243
 
270
244
  // Inverse
271
- --inverse-list-muted-color: var(--inverse-global-muted-color);
272
- --inverse-list-emphasis-color: var(--inverse-global-emphasis-color);
273
- --inverse-list-primary-color: var(--inverse-global-primary-background);
274
- --inverse-list-secondary-color: var(--inverse-global-primary-background);
275
- --inverse-list-divider-border: var(--inverse-global-border);
276
- --inverse-list-striped-background: var(--inverse-global-muted-background);
277
- --inverse-list-bullet-icon-color: var(--inverse-global-color);
245
+ --inverse-subnav-item-color: var(--inverse-global-muted-color);
246
+ --inverse-subnav-item-hover-color: var(--inverse-global-color);
247
+ --inverse-subnav-item-active-color: var(--inverse-global-emphasis-color);
248
+ --inverse-subnav-divider-border: var(--inverse-global-border);
249
+ --inverse-subnav-pill-item-background: #{$inverse-subnav-pill-item-background};
250
+ --inverse-subnav-pill-item-color: var(--inverse-global-muted-color);
251
+ --inverse-subnav-pill-item-hover-background: var(--inverse-global-muted-background);
252
+ --inverse-subnav-pill-item-hover-color: var(--inverse-global-color);
253
+ --inverse-subnav-pill-item-onclick-background: #{$inverse-subnav-pill-item-hover-background};
254
+ --inverse-subnav-pill-item-onclick-color: #{$inverse-subnav-pill-item-hover-color};
255
+ --inverse-subnav-pill-item-active-background: var(--inverse-global-primary-background);
256
+ --inverse-subnav-pill-item-active-color: var(--inverse-global-inverse-color);
257
+ --inverse-subnav-item-disabled-color: var(--inverse-global-muted-color);
278
258
  }
File without changes
@@ -0,0 +1 @@
1
+ "use strict";