@gitlab/ui 80.10.0 → 80.12.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/CHANGELOG.md +19 -0
- package/README.md +1 -20
- package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +5 -9
- package/dist/components/base/new_dropdowns/constants.js +1 -2
- package/dist/components/charts/discrete_scatter/discrete_scatter.js +1 -1
- package/dist/components/charts/heatmap/heatmap.js +1 -1
- package/dist/components/charts/legend/legend.js +1 -1
- package/dist/components/charts/line/line.js +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/tailwind.css.map +1 -1
- package/dist/tokens/build/js/tokens.dark.js +106 -1
- package/dist/tokens/build/js/tokens.js +70 -1
- package/dist/tokens/common_story_options.js +1 -1
- package/dist/tokens/css/tokens.css +77 -8
- package/dist/tokens/css/tokens.dark.css +111 -6
- package/dist/tokens/js/tokens.dark.js +105 -0
- package/dist/tokens/js/tokens.js +69 -0
- package/dist/tokens/json/tokens.dark.json +4002 -2053
- package/dist/tokens/json/tokens.json +1207 -14
- package/dist/tokens/scss/_tokens.dark.scss +111 -6
- package/dist/tokens/scss/_tokens.scss +77 -8
- package/dist/tokens/scss/_tokens_custom_properties.scss +315 -0
- package/dist/tokens/tailwind/tokens.cjs +9 -8
- package/dist/utils/charts/config.js +1 -1
- package/dist/utils/charts/mock_data.js +1 -1
- package/dist/utils/charts/theme.js +1 -1
- package/dist/utils/utils.js +1 -19
- package/package.json +1 -1
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.spec.js +17 -55
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.vue +4 -16
- package/src/components/base/new_dropdowns/constants.js +0 -1
- package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.stories.js +0 -28
- package/src/components/charts/area/area.stories.js +1 -1
- package/src/components/charts/discrete_scatter/discrete_scatter.vue +1 -1
- package/src/components/charts/heatmap/heatmap.vue +1 -1
- package/src/components/charts/legend/legend.stories.js +1 -1
- package/src/components/charts/legend/legend.vue +1 -1
- package/src/components/charts/line/line.vue +1 -1
- package/src/components/charts/stacked_column/stacked_column.stories.js +1 -1
- package/src/scss/tokens.scss +2 -2
- package/src/scss/variables.scss +1 -1
- package/src/tokens/build/css/tokens.css +77 -8
- package/src/tokens/build/css/tokens.dark.css +111 -6
- package/src/tokens/build/js/tokens.dark.js +105 -0
- package/src/tokens/build/js/tokens.js +69 -0
- package/src/tokens/build/json/tokens.dark.json +4002 -2053
- package/src/tokens/build/json/tokens.json +1207 -14
- package/src/tokens/build/scss/_tokens.dark.scss +111 -6
- package/src/tokens/build/scss/_tokens.scss +77 -8
- package/src/tokens/build/scss/_tokens_custom_properties.scss +315 -0
- package/src/tokens/build/tailwind/tokens.cjs +9 -8
- package/src/tokens/color.constant.tokens.json +292 -0
- package/src/tokens/color.constant.tokens.stories.js +19 -0
- package/src/tokens/color.dark.tokens.stories.js +1 -1
- package/src/tokens/color.data_viz.dark.tokens.stories.js +1 -1
- package/src/tokens/color.data_viz.tokens.stories.js +1 -1
- package/src/tokens/color.theme.dark.tokens.stories.js +1 -1
- package/src/tokens/color.theme.tokens.stories.js +1 -1
- package/src/tokens/color.tokens.stories.js +1 -1
- package/src/tokens/color.transparency.tokens.stories.js +1 -1
- package/src/tokens/common_story_options.js +1 -1
- package/src/tokens/text.dark.tokens.stories.js +1 -1
- package/src/tokens/text.tokens.json +20 -14
- package/src/tokens/text.tokens.stories.js +1 -1
- package/src/utils/charts/config.js +1 -1
- package/src/utils/charts/mock_data.js +1 -1
- package/src/utils/charts/theme.js +1 -1
- package/src/utils/utils.js +0 -18
- package/src/utils/utils.spec.js +0 -52
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
{
|
|
2
|
+
"color": {
|
|
3
|
+
"blue": {
|
|
4
|
+
"50": {
|
|
5
|
+
"$value": "#e9f3fc",
|
|
6
|
+
"$type": "color"
|
|
7
|
+
},
|
|
8
|
+
"100": {
|
|
9
|
+
"$value": "#cbe2f9",
|
|
10
|
+
"$type": "color"
|
|
11
|
+
},
|
|
12
|
+
"200": {
|
|
13
|
+
"$value": "#9dc7f1",
|
|
14
|
+
"$type": "color"
|
|
15
|
+
},
|
|
16
|
+
"300": {
|
|
17
|
+
"$value": "#63a6e9",
|
|
18
|
+
"$type": "color"
|
|
19
|
+
},
|
|
20
|
+
"400": {
|
|
21
|
+
"$value": "#428fdc",
|
|
22
|
+
"$type": "color"
|
|
23
|
+
},
|
|
24
|
+
"500": {
|
|
25
|
+
"$value": "#1f75cb",
|
|
26
|
+
"$type": "color"
|
|
27
|
+
},
|
|
28
|
+
"600": {
|
|
29
|
+
"$value": "#1068bf",
|
|
30
|
+
"$type": "color"
|
|
31
|
+
},
|
|
32
|
+
"700": {
|
|
33
|
+
"$value": "#0b5cad",
|
|
34
|
+
"$type": "color"
|
|
35
|
+
},
|
|
36
|
+
"800": {
|
|
37
|
+
"$value": "#064787",
|
|
38
|
+
"$type": "color"
|
|
39
|
+
},
|
|
40
|
+
"900": {
|
|
41
|
+
"$value": "#033464",
|
|
42
|
+
"$type": "color"
|
|
43
|
+
},
|
|
44
|
+
"950": {
|
|
45
|
+
"$value": "#002850",
|
|
46
|
+
"$type": "color"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"neutral": {
|
|
50
|
+
"0": {
|
|
51
|
+
"$value": "#fff",
|
|
52
|
+
"$type": "color"
|
|
53
|
+
},
|
|
54
|
+
"10": {
|
|
55
|
+
"$value": "#fbfafd",
|
|
56
|
+
"$type": "color"
|
|
57
|
+
},
|
|
58
|
+
"50": {
|
|
59
|
+
"$value": "#ececef",
|
|
60
|
+
"$type": "color"
|
|
61
|
+
},
|
|
62
|
+
"100": {
|
|
63
|
+
"$value": "#dcdcde",
|
|
64
|
+
"$type": "color"
|
|
65
|
+
},
|
|
66
|
+
"200": {
|
|
67
|
+
"$value": "#bfbfc3",
|
|
68
|
+
"$type": "color"
|
|
69
|
+
},
|
|
70
|
+
"300": {
|
|
71
|
+
"$value": "#a4a3a8",
|
|
72
|
+
"$type": "color"
|
|
73
|
+
},
|
|
74
|
+
"400": {
|
|
75
|
+
"$value": "#89888d",
|
|
76
|
+
"$type": "color"
|
|
77
|
+
},
|
|
78
|
+
"500": {
|
|
79
|
+
"$value": "#737278",
|
|
80
|
+
"$type": "color"
|
|
81
|
+
},
|
|
82
|
+
"600": {
|
|
83
|
+
"$value": "#626168",
|
|
84
|
+
"$type": "color"
|
|
85
|
+
},
|
|
86
|
+
"700": {
|
|
87
|
+
"$value": "#535158",
|
|
88
|
+
"$type": "color"
|
|
89
|
+
},
|
|
90
|
+
"800": {
|
|
91
|
+
"$value": "#434248",
|
|
92
|
+
"$type": "color"
|
|
93
|
+
},
|
|
94
|
+
"900": {
|
|
95
|
+
"$value": "#333238",
|
|
96
|
+
"$type": "color"
|
|
97
|
+
},
|
|
98
|
+
"950": {
|
|
99
|
+
"$value": "#1f1e24",
|
|
100
|
+
"$type": "color"
|
|
101
|
+
},
|
|
102
|
+
"1000": {
|
|
103
|
+
"$value": "#000",
|
|
104
|
+
"$type": "color"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"green": {
|
|
108
|
+
"50": {
|
|
109
|
+
"$value": "#ecf4ee",
|
|
110
|
+
"$type": "color"
|
|
111
|
+
},
|
|
112
|
+
"100": {
|
|
113
|
+
"$value": "#c3e6cd",
|
|
114
|
+
"$type": "color"
|
|
115
|
+
},
|
|
116
|
+
"200": {
|
|
117
|
+
"$value": "#91d4a8",
|
|
118
|
+
"$type": "color"
|
|
119
|
+
},
|
|
120
|
+
"300": {
|
|
121
|
+
"$value": "#52b87a",
|
|
122
|
+
"$type": "color"
|
|
123
|
+
},
|
|
124
|
+
"400": {
|
|
125
|
+
"$value": "#2da160",
|
|
126
|
+
"$type": "color"
|
|
127
|
+
},
|
|
128
|
+
"500": {
|
|
129
|
+
"$value": "#108548",
|
|
130
|
+
"$type": "color"
|
|
131
|
+
},
|
|
132
|
+
"600": {
|
|
133
|
+
"$value": "#217645",
|
|
134
|
+
"$type": "color"
|
|
135
|
+
},
|
|
136
|
+
"700": {
|
|
137
|
+
"$value": "#24663b",
|
|
138
|
+
"$type": "color"
|
|
139
|
+
},
|
|
140
|
+
"800": {
|
|
141
|
+
"$value": "#0d532a",
|
|
142
|
+
"$type": "color"
|
|
143
|
+
},
|
|
144
|
+
"900": {
|
|
145
|
+
"$value": "#0a4020",
|
|
146
|
+
"$type": "color"
|
|
147
|
+
},
|
|
148
|
+
"950": {
|
|
149
|
+
"$value": "#072b15",
|
|
150
|
+
"$type": "color"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"orange": {
|
|
154
|
+
"50": {
|
|
155
|
+
"$value": "#fdf1dd",
|
|
156
|
+
"$type": "color"
|
|
157
|
+
},
|
|
158
|
+
"100": {
|
|
159
|
+
"$value": "#f5d9a8",
|
|
160
|
+
"$type": "color"
|
|
161
|
+
},
|
|
162
|
+
"200": {
|
|
163
|
+
"$value": "#e9be74",
|
|
164
|
+
"$type": "color"
|
|
165
|
+
},
|
|
166
|
+
"300": {
|
|
167
|
+
"$value": "#d99530",
|
|
168
|
+
"$type": "color"
|
|
169
|
+
},
|
|
170
|
+
"400": {
|
|
171
|
+
"$value": "#c17d10",
|
|
172
|
+
"$type": "color"
|
|
173
|
+
},
|
|
174
|
+
"500": {
|
|
175
|
+
"$value": "#ab6100",
|
|
176
|
+
"$type": "color"
|
|
177
|
+
},
|
|
178
|
+
"600": {
|
|
179
|
+
"$value": "#9e5400",
|
|
180
|
+
"$type": "color"
|
|
181
|
+
},
|
|
182
|
+
"700": {
|
|
183
|
+
"$value": "#8f4700",
|
|
184
|
+
"$type": "color"
|
|
185
|
+
},
|
|
186
|
+
"800": {
|
|
187
|
+
"$value": "#703800",
|
|
188
|
+
"$type": "color"
|
|
189
|
+
},
|
|
190
|
+
"900": {
|
|
191
|
+
"$value": "#5c2900",
|
|
192
|
+
"$type": "color"
|
|
193
|
+
},
|
|
194
|
+
"950": {
|
|
195
|
+
"$value": "#421f00",
|
|
196
|
+
"$type": "color"
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"purple": {
|
|
200
|
+
"50": {
|
|
201
|
+
"$value": "#f4f0ff",
|
|
202
|
+
"$type": "color"
|
|
203
|
+
},
|
|
204
|
+
"100": {
|
|
205
|
+
"$value": "#e1d8f9",
|
|
206
|
+
"$type": "color"
|
|
207
|
+
},
|
|
208
|
+
"200": {
|
|
209
|
+
"$value": "#cbbbf2",
|
|
210
|
+
"$type": "color"
|
|
211
|
+
},
|
|
212
|
+
"300": {
|
|
213
|
+
"$value": "#ac93e6",
|
|
214
|
+
"$type": "color"
|
|
215
|
+
},
|
|
216
|
+
"400": {
|
|
217
|
+
"$value": "#9475db",
|
|
218
|
+
"$type": "color"
|
|
219
|
+
},
|
|
220
|
+
"500": {
|
|
221
|
+
"$value": "#7b58cf",
|
|
222
|
+
"$type": "color"
|
|
223
|
+
},
|
|
224
|
+
"600": {
|
|
225
|
+
"$value": "#694cc0",
|
|
226
|
+
"$type": "color"
|
|
227
|
+
},
|
|
228
|
+
"700": {
|
|
229
|
+
"$value": "#5943b6",
|
|
230
|
+
"$type": "color"
|
|
231
|
+
},
|
|
232
|
+
"800": {
|
|
233
|
+
"$value": "#453894",
|
|
234
|
+
"$type": "color"
|
|
235
|
+
},
|
|
236
|
+
"900": {
|
|
237
|
+
"$value": "#2f2a6b",
|
|
238
|
+
"$type": "color"
|
|
239
|
+
},
|
|
240
|
+
"950": {
|
|
241
|
+
"$value": "#232150",
|
|
242
|
+
"$type": "color"
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
"red": {
|
|
246
|
+
"50": {
|
|
247
|
+
"$value": "#fcf1ef",
|
|
248
|
+
"$type": "color"
|
|
249
|
+
},
|
|
250
|
+
"100": {
|
|
251
|
+
"$value": "#fdd4cd",
|
|
252
|
+
"$type": "color"
|
|
253
|
+
},
|
|
254
|
+
"200": {
|
|
255
|
+
"$value": "#fcb5aa",
|
|
256
|
+
"$type": "color"
|
|
257
|
+
},
|
|
258
|
+
"300": {
|
|
259
|
+
"$value": "#f57f6c",
|
|
260
|
+
"$type": "color"
|
|
261
|
+
},
|
|
262
|
+
"400": {
|
|
263
|
+
"$value": "#ec5941",
|
|
264
|
+
"$type": "color"
|
|
265
|
+
},
|
|
266
|
+
"500": {
|
|
267
|
+
"$value": "#dd2b0e",
|
|
268
|
+
"$type": "color"
|
|
269
|
+
},
|
|
270
|
+
"600": {
|
|
271
|
+
"$value": "#c91c00",
|
|
272
|
+
"$type": "color"
|
|
273
|
+
},
|
|
274
|
+
"700": {
|
|
275
|
+
"$value": "#ae1800",
|
|
276
|
+
"$type": "color"
|
|
277
|
+
},
|
|
278
|
+
"800": {
|
|
279
|
+
"$value": "#8d1300",
|
|
280
|
+
"$type": "color"
|
|
281
|
+
},
|
|
282
|
+
"900": {
|
|
283
|
+
"$value": "#660e00",
|
|
284
|
+
"$type": "color"
|
|
285
|
+
},
|
|
286
|
+
"950": {
|
|
287
|
+
"$value": "#4d0a00",
|
|
288
|
+
"$type": "color"
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import COMPILED_TOKENS from '../../dist/tokens/json/tokens.json';
|
|
2
|
+
import { createDesignTokenStory } from './common_story_options';
|
|
3
|
+
|
|
4
|
+
export const Neutral = createDesignTokenStory({ tokens: COMPILED_TOKENS.color.neutral });
|
|
5
|
+
|
|
6
|
+
export const Blue = createDesignTokenStory({ tokens: COMPILED_TOKENS.color.blue });
|
|
7
|
+
|
|
8
|
+
export const Green = createDesignTokenStory({ tokens: COMPILED_TOKENS.color.green });
|
|
9
|
+
|
|
10
|
+
export const Orange = createDesignTokenStory({ tokens: COMPILED_TOKENS.color.orange });
|
|
11
|
+
|
|
12
|
+
export const Red = createDesignTokenStory({ tokens: COMPILED_TOKENS.color.red });
|
|
13
|
+
|
|
14
|
+
export const Purple = createDesignTokenStory({ tokens: COMPILED_TOKENS.color.purple });
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line storybook/csf-component
|
|
17
|
+
export default {
|
|
18
|
+
title: 'tokens/color/constant',
|
|
19
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import COMPILED_TOKENS from '
|
|
1
|
+
import COMPILED_TOKENS from './build/json/tokens.dark.json';
|
|
2
2
|
import { createDesignTokenStory } from './common_story_options';
|
|
3
3
|
|
|
4
4
|
export const DataVizGreen = createDesignTokenStory({ tokens: COMPILED_TOKENS['data-viz'].green });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import COMPILED_TOKENS from '
|
|
1
|
+
import COMPILED_TOKENS from './build/json/tokens.json';
|
|
2
2
|
import { createDesignTokenStory } from './common_story_options';
|
|
3
3
|
|
|
4
4
|
export const DataVizGreen = createDesignTokenStory({ tokens: COMPILED_TOKENS['data-viz'].green });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import COMPILED_TOKENS from '
|
|
1
|
+
import COMPILED_TOKENS from './build/json/tokens.dark.json';
|
|
2
2
|
import { createDesignTokenStory } from './common_story_options';
|
|
3
3
|
|
|
4
4
|
export const ThemeIndigo = createDesignTokenStory({ tokens: COMPILED_TOKENS.theme.indigo });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import COMPILED_TOKENS from '
|
|
1
|
+
import COMPILED_TOKENS from './build/json/tokens.json';
|
|
2
2
|
import { createDesignTokenStory } from './common_story_options';
|
|
3
3
|
|
|
4
4
|
export const ThemeIndigo = createDesignTokenStory({ tokens: COMPILED_TOKENS.theme.indigo });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import COMPILED_TOKENS from '
|
|
1
|
+
import COMPILED_TOKENS from './build/json/tokens.json';
|
|
2
2
|
import { createDesignTokenStory } from './common_story_options';
|
|
3
3
|
|
|
4
4
|
export const Gray = createDesignTokenStory({ tokens: COMPILED_TOKENS['t-gray-a'] });
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"color": {
|
|
34
34
|
"default": {
|
|
35
35
|
"$value": {
|
|
36
|
-
"default": "
|
|
37
|
-
"dark": "
|
|
36
|
+
"default": "{color.neutral.800}",
|
|
37
|
+
"dark": "{color.neutral.50}"
|
|
38
38
|
},
|
|
39
39
|
"$type": "color",
|
|
40
40
|
"$description": "Used for the default text color.",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
},
|
|
43
43
|
"subtle": {
|
|
44
44
|
"$value": {
|
|
45
|
-
"default": "
|
|
46
|
-
"dark": "
|
|
45
|
+
"default": "{color.neutral.600}",
|
|
46
|
+
"dark": "{color.neutral.200}"
|
|
47
47
|
},
|
|
48
48
|
"$type": "color",
|
|
49
49
|
"$description": "Used for supplemental text that doesn't need to be as prominent as other text.",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
},
|
|
52
52
|
"strong": {
|
|
53
53
|
"$value": {
|
|
54
|
-
"default": "
|
|
55
|
-
"dark": "
|
|
54
|
+
"default": "{color.neutral.950}",
|
|
55
|
+
"dark": "{color.neutral.0}"
|
|
56
56
|
},
|
|
57
57
|
"$type": "color",
|
|
58
58
|
"$description": "Used for text with the highest contrast.",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
},
|
|
61
61
|
"heading": {
|
|
62
62
|
"$value": {
|
|
63
|
-
"default": "
|
|
64
|
-
"dark": "
|
|
63
|
+
"default": "{color.neutral.950}",
|
|
64
|
+
"dark": "{color.neutral.0}"
|
|
65
65
|
},
|
|
66
66
|
"$type": "color",
|
|
67
67
|
"$description": "Used for headings level 1-6.",
|
|
@@ -69,29 +69,35 @@
|
|
|
69
69
|
},
|
|
70
70
|
"link": {
|
|
71
71
|
"$value": {
|
|
72
|
-
"default": "
|
|
73
|
-
"dark": "
|
|
72
|
+
"default": "{color.blue.700}",
|
|
73
|
+
"dark": "{color.blue.300}"
|
|
74
74
|
},
|
|
75
75
|
"$type": "color",
|
|
76
76
|
"$description": "Used for default text links.",
|
|
77
77
|
"themeable": true
|
|
78
78
|
},
|
|
79
79
|
"danger": {
|
|
80
|
-
"$value":
|
|
80
|
+
"$value": {
|
|
81
|
+
"default": "{color.red.600}",
|
|
82
|
+
"dark": "{color.red.300}"
|
|
83
|
+
},
|
|
81
84
|
"$type": "color",
|
|
82
85
|
"$description": "Used for text indicating a problem, critical state, destructive action, error, failure, removal, stop, or declination.",
|
|
83
86
|
"themeable": true
|
|
84
87
|
},
|
|
85
88
|
"success": {
|
|
86
|
-
"$value":
|
|
89
|
+
"$value": {
|
|
90
|
+
"default": "{color.green.600}",
|
|
91
|
+
"dark": "{color.green.300}"
|
|
92
|
+
},
|
|
87
93
|
"$type": "color",
|
|
88
94
|
"$description": "Used for text indicating success or validity.",
|
|
89
95
|
"themeable": true
|
|
90
96
|
},
|
|
91
97
|
"disabled": {
|
|
92
98
|
"$value": {
|
|
93
|
-
"default": "
|
|
94
|
-
"dark": "
|
|
99
|
+
"default": "{color.neutral.400}",
|
|
100
|
+
"dark": "{color.neutral.400}"
|
|
95
101
|
},
|
|
96
102
|
"$type": "color",
|
|
97
103
|
"$description": "Used for disabled text.",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import castArray from 'lodash/castArray';
|
|
2
2
|
import merge from 'lodash/merge';
|
|
3
|
-
import { BLUE_500 } from '
|
|
3
|
+
import { BLUE_500 } from '../../tokens/build/js/tokens';
|
|
4
4
|
import { GlBreakpointInstance } from '../breakpoints';
|
|
5
5
|
import { columnOptions } from '../constants';
|
|
6
6
|
import { areDatesEqual } from '../datetime_utility';
|
|
@@ -63,7 +63,7 @@ import {
|
|
|
63
63
|
DATA_VIZ_ORANGE_800,
|
|
64
64
|
DATA_VIZ_ORANGE_950,
|
|
65
65
|
DATA_VIZ_ORANGE_900,
|
|
66
|
-
} from '
|
|
66
|
+
} from '../../tokens/build/js/tokens';
|
|
67
67
|
import { scrollHandleSvgPath } from '../svgs/svg_paths';
|
|
68
68
|
import { hexToRgba } from '../utils';
|
|
69
69
|
|
package/src/utils/utils.js
CHANGED
|
@@ -204,21 +204,3 @@ export function stopEvent(
|
|
|
204
204
|
export function filterVisible(els) {
|
|
205
205
|
return (els || []).filter((el) => isVisible(el));
|
|
206
206
|
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Given an element, returns a Rect object
|
|
210
|
-
* with top and bottom boundaries removed.
|
|
211
|
-
*/
|
|
212
|
-
export function getHorizontalBoundingClientRect(el) {
|
|
213
|
-
const rect = el?.getBoundingClientRect();
|
|
214
|
-
|
|
215
|
-
if (rect) {
|
|
216
|
-
return {
|
|
217
|
-
x: rect.x,
|
|
218
|
-
width: rect.width,
|
|
219
|
-
y: 0, // top of the document
|
|
220
|
-
height: document.documentElement.clientHeight, // bottom of the document
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
return null;
|
|
224
|
-
}
|
package/src/utils/utils.spec.js
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
isElementTabbable,
|
|
4
4
|
focusFirstFocusableElement,
|
|
5
5
|
stopEvent,
|
|
6
|
-
getHorizontalBoundingClientRect,
|
|
7
6
|
} from './utils';
|
|
8
7
|
|
|
9
8
|
describe('isElementFocusable', () => {
|
|
@@ -154,55 +153,4 @@ describe('stopEvent', () => {
|
|
|
154
153
|
expect(event.stopPropagation).not.toHaveBeenCalled();
|
|
155
154
|
expect(event.stopImmediatePropagation).toHaveBeenCalledTimes(1);
|
|
156
155
|
});
|
|
157
|
-
|
|
158
|
-
describe('getHorizontalBoundingClientRect', () => {
|
|
159
|
-
describe('when there is a reference element', () => {
|
|
160
|
-
let mainElement;
|
|
161
|
-
|
|
162
|
-
const [
|
|
163
|
-
MAIN_LEFT_BOUNDARY,
|
|
164
|
-
MAIN_WIDTH,
|
|
165
|
-
MAIN_TOP_BOUNDARY,
|
|
166
|
-
MAIN_HEIGHT,
|
|
167
|
-
DOCUMENT_TOP_BOUNDARY,
|
|
168
|
-
DOCUMENT_HEIGHT,
|
|
169
|
-
] = [10, 20, 30, 40, 0, 50];
|
|
170
|
-
|
|
171
|
-
beforeEach(() => {
|
|
172
|
-
mainElement = document.createElement('main');
|
|
173
|
-
jest.spyOn(mainElement, 'getBoundingClientRect').mockImplementation(() => {
|
|
174
|
-
return {
|
|
175
|
-
x: MAIN_LEFT_BOUNDARY,
|
|
176
|
-
width: MAIN_WIDTH,
|
|
177
|
-
y: MAIN_TOP_BOUNDARY,
|
|
178
|
-
height: MAIN_HEIGHT,
|
|
179
|
-
};
|
|
180
|
-
});
|
|
181
|
-
Object.defineProperty(document.documentElement, 'clientHeight', {
|
|
182
|
-
get() {
|
|
183
|
-
return DOCUMENT_HEIGHT;
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
afterEach(() => {
|
|
189
|
-
mainElement = null;
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it("returns the element's horizontal boundaries and the document's vertical boundaries", () => {
|
|
193
|
-
expect(getHorizontalBoundingClientRect(mainElement)).toEqual({
|
|
194
|
-
x: MAIN_LEFT_BOUNDARY,
|
|
195
|
-
width: MAIN_WIDTH,
|
|
196
|
-
y: DOCUMENT_TOP_BOUNDARY,
|
|
197
|
-
height: DOCUMENT_HEIGHT,
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
describe('when there is no reference element', () => {
|
|
203
|
-
it('returns `null`', () => {
|
|
204
|
-
expect(getHorizontalBoundingClientRect(null)).toEqual(null);
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
156
|
});
|