@gitlab/ui 115.9.1 → 115.9.3
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/dist/components/base/avatar/avatar.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/tailwind.css.map +1 -1
- package/dist/tokens/build/js/tokens.dark.js +1 -1
- package/dist/tokens/build/js/tokens.js +1 -1
- package/dist/tokens/css/tokens.css +2 -2
- package/dist/tokens/css/tokens.dark.css +1 -1
- package/dist/tokens/figma/contextual.tokens.json +1 -1
- package/dist/tokens/js/tokens.dark.js +1 -1
- package/dist/tokens/js/tokens.js +1 -1
- package/dist/tokens/json/tokens.dark.json +2 -2
- package/dist/tokens/json/tokens.json +2 -2
- package/dist/tokens/scss/_tokens.dark.scss +1 -1
- package/dist/tokens/scss/_tokens.scss +1 -1
- package/package.json +1 -2
- package/src/components/base/avatar/avatar.vue +1 -0
- package/src/tokens/build/css/tokens.css +2 -2
- package/src/tokens/build/css/tokens.dark.css +1 -1
- package/src/tokens/build/figma/contextual.tokens.json +1 -1
- package/src/tokens/build/js/tokens.dark.js +1 -1
- package/src/tokens/build/js/tokens.js +1 -1
- package/src/tokens/build/json/tokens.dark.json +2 -2
- package/src/tokens/build/json/tokens.json +2 -2
- package/src/tokens/build/scss/_tokens.dark.scss +1 -1
- package/src/tokens/build/scss/_tokens.scss +1 -1
- package/src/tokens/contextual/table.tokens.json +1 -1
- package/dist/tokens/tokens_table.js +0 -265
- package/dist/tokens/tokens_tailwind_table.js +0 -278
- package/src/tokens/tokens_table.vue +0 -303
- package/src/tokens/tokens_tailwind_table.vue +0 -360
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Fuse from 'fuse.js';
|
|
3
|
-
import GlBadge from '../components/base/badge/badge.vue';
|
|
4
|
-
import GlButton from '../components/base/button/button.vue';
|
|
5
|
-
import GlCollapsibleListbox from '../components/base/new_dropdowns/listbox/listbox.vue';
|
|
6
|
-
import GlSearchBoxByType from '../components/base/search_box_by_type/search_box_by_type.vue';
|
|
7
|
-
import GlLink from '../components/base/link/link.vue';
|
|
8
|
-
import GlTable from '../components/base/table/table.vue';
|
|
9
|
-
import GlPagination from '../components/base/pagination/pagination.vue';
|
|
10
|
-
import { GlTooltipDirective } from '../directives/tooltip/tooltip';
|
|
11
|
-
import TOKENS_DEFAULT from './build/json/tokens.json';
|
|
12
|
-
import TOKENS_DARK from './build/json/tokens.dark.json';
|
|
13
|
-
|
|
14
|
-
export default {
|
|
15
|
-
name: 'TokensTable',
|
|
16
|
-
tokens: {
|
|
17
|
-
default: TOKENS_DEFAULT,
|
|
18
|
-
dark: TOKENS_DARK,
|
|
19
|
-
},
|
|
20
|
-
components: {
|
|
21
|
-
GlBadge,
|
|
22
|
-
GlButton,
|
|
23
|
-
GlCollapsibleListbox,
|
|
24
|
-
GlSearchBoxByType,
|
|
25
|
-
GlLink,
|
|
26
|
-
GlTable,
|
|
27
|
-
GlPagination,
|
|
28
|
-
},
|
|
29
|
-
directives: {
|
|
30
|
-
GlTooltip: GlTooltipDirective,
|
|
31
|
-
},
|
|
32
|
-
fields: [
|
|
33
|
-
{
|
|
34
|
-
key: 'description',
|
|
35
|
-
label: 'Description',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
key: 'value',
|
|
39
|
-
label: 'Value',
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
data() {
|
|
43
|
-
return {
|
|
44
|
-
filter: '',
|
|
45
|
-
platforms: [
|
|
46
|
-
{
|
|
47
|
-
value: 'name',
|
|
48
|
-
text: 'Name',
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
value: 'figma',
|
|
52
|
-
text: 'Figma',
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
value: 'css',
|
|
56
|
-
text: 'CSS',
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
value: 'scss',
|
|
60
|
-
text: 'SCSS',
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
modes: [
|
|
64
|
-
{
|
|
65
|
-
value: 'default',
|
|
66
|
-
text: 'Default',
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
value: 'dark',
|
|
70
|
-
text: 'Dark',
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
selectedPlatform: 'name',
|
|
74
|
-
selectedMode: 'default',
|
|
75
|
-
currentPage: 1,
|
|
76
|
-
perPage: 50,
|
|
77
|
-
totalFilteredItems: 0,
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
watch: {
|
|
81
|
-
selectedPlatform: 'refresh',
|
|
82
|
-
selectedMode: 'refresh',
|
|
83
|
-
filter: 'resetCurrentPage',
|
|
84
|
-
},
|
|
85
|
-
methods: {
|
|
86
|
-
isColor(type) {
|
|
87
|
-
return type === 'color';
|
|
88
|
-
},
|
|
89
|
-
isAliasValue(value) {
|
|
90
|
-
return typeof value === 'string' && value.includes('{');
|
|
91
|
-
},
|
|
92
|
-
isAliasObject(value) {
|
|
93
|
-
return (
|
|
94
|
-
typeof value === 'object' && Object.values(value).some((val) => this.isAliasValue(val))
|
|
95
|
-
);
|
|
96
|
-
},
|
|
97
|
-
getAliasValueName(value) {
|
|
98
|
-
if (this.isAliasValue(value)) {
|
|
99
|
-
return value.slice(1, -1);
|
|
100
|
-
}
|
|
101
|
-
return value;
|
|
102
|
-
},
|
|
103
|
-
getValueLabel(token) {
|
|
104
|
-
const value = token.original.$value;
|
|
105
|
-
if (this.isAliasObject(value)) {
|
|
106
|
-
return this.getAliasValueName(value[this.selectedMode]);
|
|
107
|
-
}
|
|
108
|
-
if (this.isAliasValue(value)) {
|
|
109
|
-
return this.getAliasValueName(value);
|
|
110
|
-
}
|
|
111
|
-
return token.$value;
|
|
112
|
-
},
|
|
113
|
-
transformTokenToTableColumns(token) {
|
|
114
|
-
return {
|
|
115
|
-
id: token.path.filter(Boolean).join('-'),
|
|
116
|
-
name: this.formatTokenName(this.selectedPlatform, token),
|
|
117
|
-
type: token.$type,
|
|
118
|
-
value: token.$value,
|
|
119
|
-
valueLabel: this.getValueLabel(token),
|
|
120
|
-
deprecated: token.$deprecated ? 'deprecated' : '',
|
|
121
|
-
description: token.$description,
|
|
122
|
-
};
|
|
123
|
-
},
|
|
124
|
-
filterItems(items, filter) {
|
|
125
|
-
if (!filter) return items;
|
|
126
|
-
|
|
127
|
-
const fuse = new Fuse(items, {
|
|
128
|
-
keys: Object.keys(items[0]),
|
|
129
|
-
includeScore: true,
|
|
130
|
-
});
|
|
131
|
-
const results = fuse.search(filter);
|
|
132
|
-
|
|
133
|
-
return results
|
|
134
|
-
.sort((a, b) => {
|
|
135
|
-
if (a.item.deprecated && !b.item.deprecated) return 1;
|
|
136
|
-
if (!a.item.deprecated && b.item.deprecated) return -1;
|
|
137
|
-
return a.score - b.score;
|
|
138
|
-
})
|
|
139
|
-
.map(({ item }) => item);
|
|
140
|
-
},
|
|
141
|
-
paginateItems(items, currentPage, perPage) {
|
|
142
|
-
const start = (currentPage - 1) * perPage;
|
|
143
|
-
return items.slice(start, start + perPage);
|
|
144
|
-
},
|
|
145
|
-
itemsProvider({ currentPage, perPage, filter }) {
|
|
146
|
-
try {
|
|
147
|
-
const items = this.transformTokensToTableRows(this.$options.tokens[this.selectedMode]);
|
|
148
|
-
const filteredItems = this.filterItems(items, filter);
|
|
149
|
-
this.totalFilteredItems = filteredItems.length;
|
|
150
|
-
const paginatedFilteredItems = this.paginateItems(filteredItems, currentPage, perPage);
|
|
151
|
-
return paginatedFilteredItems;
|
|
152
|
-
} catch (e) {
|
|
153
|
-
// eslint-disable-next-line no-console
|
|
154
|
-
console.error('Failed to provide items', e);
|
|
155
|
-
return [];
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
transformTokensToTableRows(tokens) {
|
|
159
|
-
const tokensArray = [];
|
|
160
|
-
|
|
161
|
-
Object.keys(tokens).forEach((key) => {
|
|
162
|
-
const token = tokens[key];
|
|
163
|
-
if (token.$value) {
|
|
164
|
-
tokensArray.push(this.transformTokenToTableColumns(token));
|
|
165
|
-
} else {
|
|
166
|
-
tokensArray.push(...this.transformTokensToTableRows(token));
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
tokensArray
|
|
171
|
-
// Sort tokensArray by id
|
|
172
|
-
.sort((a, b) => {
|
|
173
|
-
if (a.id < b.id) {
|
|
174
|
-
return -1;
|
|
175
|
-
}
|
|
176
|
-
if (a.id > b.id) {
|
|
177
|
-
return 1;
|
|
178
|
-
}
|
|
179
|
-
return 0;
|
|
180
|
-
})
|
|
181
|
-
// Sort tokensArray so deprecated items are last
|
|
182
|
-
.sort((a, b) => {
|
|
183
|
-
if (a.deprecated && !b.deprecated) {
|
|
184
|
-
return 1;
|
|
185
|
-
}
|
|
186
|
-
if (!a.deprecated && b.deprecated) {
|
|
187
|
-
return -1;
|
|
188
|
-
}
|
|
189
|
-
return 0;
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
return tokensArray;
|
|
193
|
-
},
|
|
194
|
-
formatTokenName(format, token) {
|
|
195
|
-
let figmaPrefix = '';
|
|
196
|
-
const prefix = token.prefix === false ? '' : 'gl';
|
|
197
|
-
switch (format) {
|
|
198
|
-
case 'figma':
|
|
199
|
-
if (token.filePath.match('contextual')) {
|
|
200
|
-
figmaPrefix = '🔒/';
|
|
201
|
-
}
|
|
202
|
-
if (token.$deprecated) {
|
|
203
|
-
figmaPrefix = '⚠️ DEPRECATED/';
|
|
204
|
-
}
|
|
205
|
-
return `${figmaPrefix}${token.path.filter(Boolean).join('-')}`;
|
|
206
|
-
case 'css':
|
|
207
|
-
return `var(--${[prefix, ...token.path].filter(Boolean).join('-')})`;
|
|
208
|
-
case 'scss':
|
|
209
|
-
return `$${[prefix, ...token.path].filter(Boolean).join('-')}`;
|
|
210
|
-
default:
|
|
211
|
-
return token.path.filter(Boolean).join('.');
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
getTokenName(token) {
|
|
215
|
-
return `$${token.prefix === false ? '' : 'gl-'}${token.path.filter(Boolean).join('-')}`;
|
|
216
|
-
},
|
|
217
|
-
copyToClipboard(value) {
|
|
218
|
-
navigator.clipboard.writeText(value);
|
|
219
|
-
},
|
|
220
|
-
resetCurrentPage() {
|
|
221
|
-
this.currentPage = 1;
|
|
222
|
-
},
|
|
223
|
-
refresh() {
|
|
224
|
-
this.$root.$emit('bv::refresh::table', 'tokens-table');
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
};
|
|
228
|
-
</script>
|
|
229
|
-
|
|
230
|
-
<template>
|
|
231
|
-
<div>
|
|
232
|
-
<p class="gl-text-sm gl-text-subtle">
|
|
233
|
-
For full token details, see
|
|
234
|
-
<gl-link
|
|
235
|
-
href="https://gitlab.com/gitlab-org/gitlab-ui/-/tree/main/src/tokens/build/json"
|
|
236
|
-
target="_blank"
|
|
237
|
-
>https://gitlab.com/gitlab-org/gitlab-ui/-/tree/main/src/tokens/build/json</gl-link
|
|
238
|
-
>
|
|
239
|
-
</p>
|
|
240
|
-
<div class="gl-mb-5 gl-flex gl-items-center gl-gap-3">
|
|
241
|
-
<gl-search-box-by-type v-model="filter" debounce="250" class="gl-grow" />
|
|
242
|
-
<gl-collapsible-listbox
|
|
243
|
-
v-model="selectedPlatform"
|
|
244
|
-
:selected="selectedPlatform"
|
|
245
|
-
:items="platforms"
|
|
246
|
-
@search="query = $event"
|
|
247
|
-
/>
|
|
248
|
-
<gl-collapsible-listbox
|
|
249
|
-
v-model="selectedMode"
|
|
250
|
-
:selected="selectedMode"
|
|
251
|
-
:items="modes"
|
|
252
|
-
@search="query = $event"
|
|
253
|
-
/>
|
|
254
|
-
</div>
|
|
255
|
-
<gl-table
|
|
256
|
-
id="tokens-table"
|
|
257
|
-
:filter="filter"
|
|
258
|
-
:items="itemsProvider"
|
|
259
|
-
:fields="$options.fields"
|
|
260
|
-
:tbody-tr-attr="(item) => ({ id: item.id })"
|
|
261
|
-
:current-page="currentPage"
|
|
262
|
-
:per-page="perPage"
|
|
263
|
-
hover
|
|
264
|
-
fixed
|
|
265
|
-
stacked="sm"
|
|
266
|
-
>
|
|
267
|
-
<template #cell(description)="{ item: { name, deprecated, description } }">
|
|
268
|
-
<code class="gl-text-base gl-text-strong">
|
|
269
|
-
{{ name }}
|
|
270
|
-
<gl-button
|
|
271
|
-
v-gl-tooltip
|
|
272
|
-
:title="`Copy ${selectedPlatform} value to clipboard`"
|
|
273
|
-
icon="copy-to-clipboard"
|
|
274
|
-
:aria-label="`Copy ${selectedPlatform} value to clipboard`"
|
|
275
|
-
size="small"
|
|
276
|
-
@click="copyToClipboard(name)"
|
|
277
|
-
/>
|
|
278
|
-
</code>
|
|
279
|
-
<gl-badge v-if="deprecated" variant="danger">Deprecated</gl-badge>
|
|
280
|
-
<div v-if="description" class="gl-mt-3 gl-text-subtle">
|
|
281
|
-
{{ description }}
|
|
282
|
-
</div>
|
|
283
|
-
</template>
|
|
284
|
-
<template #cell(value)="{ item: { type, value, valueLabel } }">
|
|
285
|
-
<div class="gl-flex gl-items-center gl-gap-3">
|
|
286
|
-
<div
|
|
287
|
-
v-if="isColor(type)"
|
|
288
|
-
class="gl-h-5 gl-w-5 gl-rounded-base"
|
|
289
|
-
:style="{ 'background-color': value }"
|
|
290
|
-
></div>
|
|
291
|
-
<code class="gl-min-w-0 gl-text-base gl-text-strong">{{ valueLabel }}</code>
|
|
292
|
-
</div>
|
|
293
|
-
</template>
|
|
294
|
-
</gl-table>
|
|
295
|
-
|
|
296
|
-
<gl-pagination
|
|
297
|
-
v-model="currentPage"
|
|
298
|
-
align="center"
|
|
299
|
-
:per-page="perPage"
|
|
300
|
-
:total-items="totalFilteredItems"
|
|
301
|
-
/>
|
|
302
|
-
</div>
|
|
303
|
-
</template>
|
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Fuse from 'fuse.js';
|
|
3
|
-
import GlBadge from '../components/base/badge/badge.vue';
|
|
4
|
-
import GlButton from '../components/base/button/button.vue';
|
|
5
|
-
import GlSearchBoxByType from '../components/base/search_box_by_type/search_box_by_type.vue';
|
|
6
|
-
import GlLink from '../components/base/link/link.vue';
|
|
7
|
-
import GlTable from '../components/base/table/table.vue';
|
|
8
|
-
import GlPagination from '../components/base/pagination/pagination.vue';
|
|
9
|
-
import { GlTooltipDirective } from '../directives/tooltip/tooltip';
|
|
10
|
-
import TOKENS_DEFAULT from './build/docs/tokens-tailwind-docs.json';
|
|
11
|
-
import TOKENS_DARK from './build/docs/tokens-tailwind-docs.dark.json';
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
name: 'TokensTable',
|
|
15
|
-
tokens: {
|
|
16
|
-
default: TOKENS_DEFAULT,
|
|
17
|
-
dark: TOKENS_DARK,
|
|
18
|
-
},
|
|
19
|
-
components: {
|
|
20
|
-
GlBadge,
|
|
21
|
-
GlButton,
|
|
22
|
-
GlSearchBoxByType,
|
|
23
|
-
GlLink,
|
|
24
|
-
GlTable,
|
|
25
|
-
GlPagination,
|
|
26
|
-
},
|
|
27
|
-
directives: {
|
|
28
|
-
GlTooltip: GlTooltipDirective,
|
|
29
|
-
},
|
|
30
|
-
fields: [
|
|
31
|
-
{
|
|
32
|
-
key: 'description',
|
|
33
|
-
label: 'Description',
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
key: 'value',
|
|
37
|
-
label: 'Light mode',
|
|
38
|
-
thClass: 'gl-w-1/5',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
key: 'value_dark',
|
|
42
|
-
label: 'Dark mode',
|
|
43
|
-
thClass: 'gl-w-1/5',
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
data() {
|
|
47
|
-
return {
|
|
48
|
-
filter: '',
|
|
49
|
-
currentPage: 1,
|
|
50
|
-
perPage: 50,
|
|
51
|
-
totalFilteredItems: 0,
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
watch: {
|
|
55
|
-
filter: 'resetCurrentPage',
|
|
56
|
-
},
|
|
57
|
-
methods: {
|
|
58
|
-
isColor(type) {
|
|
59
|
-
return type === 'color';
|
|
60
|
-
},
|
|
61
|
-
isAliasValue(value) {
|
|
62
|
-
return typeof value === 'string' && value.includes('{');
|
|
63
|
-
},
|
|
64
|
-
isAliasObject(value) {
|
|
65
|
-
return (
|
|
66
|
-
typeof value === 'object' && Object.values(value).some((val) => this.isAliasValue(val))
|
|
67
|
-
);
|
|
68
|
-
},
|
|
69
|
-
getAliasValueName(value) {
|
|
70
|
-
if (this.isAliasValue(value)) {
|
|
71
|
-
return value.slice(1, -1);
|
|
72
|
-
}
|
|
73
|
-
return value;
|
|
74
|
-
},
|
|
75
|
-
getValueLabel(token) {
|
|
76
|
-
const value = token.original.$value;
|
|
77
|
-
if (this.isAliasObject(value)) {
|
|
78
|
-
return this.getAliasValueName(value.default);
|
|
79
|
-
}
|
|
80
|
-
if (this.isAliasValue(value)) {
|
|
81
|
-
return this.getAliasValueName(value);
|
|
82
|
-
}
|
|
83
|
-
return token.$value;
|
|
84
|
-
},
|
|
85
|
-
getDarkValueLabel(token) {
|
|
86
|
-
const value = token.original.$value;
|
|
87
|
-
if (this.isAliasObject(value)) {
|
|
88
|
-
return this.getAliasValueName(value.dark);
|
|
89
|
-
}
|
|
90
|
-
if (this.isAliasValue(value)) {
|
|
91
|
-
return this.getAliasValueName(value);
|
|
92
|
-
}
|
|
93
|
-
return token.$value;
|
|
94
|
-
},
|
|
95
|
-
transformTokenToTableColumns(token) {
|
|
96
|
-
return {
|
|
97
|
-
id: token.path.filter(Boolean).join('-'),
|
|
98
|
-
name: this.formatTokenName('name', token),
|
|
99
|
-
type: token.$type,
|
|
100
|
-
value: token.$value,
|
|
101
|
-
valueLabel: this.getValueLabel(token),
|
|
102
|
-
darkValueLabel: this.getDarkValueLabel(token),
|
|
103
|
-
deprecated: token.$deprecated ? 'deprecated' : '',
|
|
104
|
-
description: token.$description,
|
|
105
|
-
className: this.formatContextToClass(token.context),
|
|
106
|
-
cssValue: token.cssWithValue,
|
|
107
|
-
figmaName: this.formatTokenName('figma', token),
|
|
108
|
-
cssName: this.formatTokenName('css', token),
|
|
109
|
-
scssName: this.formatTokenName('scss', token),
|
|
110
|
-
};
|
|
111
|
-
},
|
|
112
|
-
filterItems(items, filter) {
|
|
113
|
-
if (!filter) return items;
|
|
114
|
-
|
|
115
|
-
const fuse = new Fuse(items, {
|
|
116
|
-
keys: Object.keys(items[0]),
|
|
117
|
-
includeScore: true,
|
|
118
|
-
});
|
|
119
|
-
const results = fuse.search(filter);
|
|
120
|
-
|
|
121
|
-
return results
|
|
122
|
-
.sort((a, b) => {
|
|
123
|
-
if (a.item.deprecated && !b.item.deprecated) return 1;
|
|
124
|
-
if (!a.item.deprecated && b.item.deprecated) return -1;
|
|
125
|
-
return a.score - b.score;
|
|
126
|
-
})
|
|
127
|
-
.map(({ item }) => item);
|
|
128
|
-
},
|
|
129
|
-
paginateItems(items, currentPage, perPage) {
|
|
130
|
-
const start = (currentPage - 1) * perPage;
|
|
131
|
-
return items.slice(start, start + perPage);
|
|
132
|
-
},
|
|
133
|
-
itemsProvider({ currentPage, perPage, filter }) {
|
|
134
|
-
try {
|
|
135
|
-
const items = this.transformTokensToTableRows(this.$options.tokens.default);
|
|
136
|
-
const filteredItems = this.filterItems(items, filter);
|
|
137
|
-
this.totalFilteredItems = filteredItems.length;
|
|
138
|
-
const paginatedFilteredItems = this.paginateItems(filteredItems, currentPage, perPage);
|
|
139
|
-
return paginatedFilteredItems;
|
|
140
|
-
} catch (e) {
|
|
141
|
-
// eslint-disable-next-line no-console
|
|
142
|
-
console.error('Failed to provide items', e);
|
|
143
|
-
return [];
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
transformTokensToTableRows(tokens, context = []) {
|
|
147
|
-
const tokensArray = [];
|
|
148
|
-
|
|
149
|
-
Object.keys(tokens).forEach((key) => {
|
|
150
|
-
const token = tokens[key];
|
|
151
|
-
if (token.$value) {
|
|
152
|
-
tokensArray.push(
|
|
153
|
-
this.transformTokenToTableColumns({ ...token, context: [...context, key] }),
|
|
154
|
-
);
|
|
155
|
-
} else if (key !== 'colors') {
|
|
156
|
-
tokensArray.push(...this.transformTokensToTableRows(token, [...context, key]));
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
tokensArray
|
|
161
|
-
// Sort tokensArray by id
|
|
162
|
-
.sort((a, b) => {
|
|
163
|
-
if (a.id < b.id) {
|
|
164
|
-
return -1;
|
|
165
|
-
}
|
|
166
|
-
if (a.id > b.id) {
|
|
167
|
-
return 1;
|
|
168
|
-
}
|
|
169
|
-
return 0;
|
|
170
|
-
})
|
|
171
|
-
// Sort tokensArray so deprecated items are last
|
|
172
|
-
.sort((a, b) => {
|
|
173
|
-
if (a.deprecated && !b.deprecated) {
|
|
174
|
-
return 1;
|
|
175
|
-
}
|
|
176
|
-
if (!a.deprecated && b.deprecated) {
|
|
177
|
-
return -1;
|
|
178
|
-
}
|
|
179
|
-
return 0;
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
return tokensArray;
|
|
183
|
-
},
|
|
184
|
-
formatTokenName(format, token) {
|
|
185
|
-
let figmaPrefix = '';
|
|
186
|
-
const prefix = token.prefix === false ? '' : 'gl';
|
|
187
|
-
switch (format) {
|
|
188
|
-
case 'figma':
|
|
189
|
-
if (token.filePath.match('contextual')) {
|
|
190
|
-
figmaPrefix = '🔒/';
|
|
191
|
-
}
|
|
192
|
-
if (token.$deprecated) {
|
|
193
|
-
figmaPrefix = '⚠️ DEPRECATED/';
|
|
194
|
-
}
|
|
195
|
-
return `${figmaPrefix}${token.path.filter(Boolean).join('-')}`;
|
|
196
|
-
case 'css':
|
|
197
|
-
return `var(--${[prefix, ...token.path].filter(Boolean).join('-')})`;
|
|
198
|
-
case 'scss':
|
|
199
|
-
return `$${[prefix, ...token.path].filter(Boolean).join('-')}`;
|
|
200
|
-
default:
|
|
201
|
-
return token.path.filter(Boolean).join('.');
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
formatContextToClass(context) {
|
|
205
|
-
const cleanContext = context.filter((segment) => segment !== 'color');
|
|
206
|
-
if (cleanContext[0] === 'background') {
|
|
207
|
-
cleanContext[0] = 'bg';
|
|
208
|
-
}
|
|
209
|
-
// eslint-disable-next-line @gitlab/tailwind-no-interpolation
|
|
210
|
-
return `gl-${cleanContext.join('-')}`;
|
|
211
|
-
},
|
|
212
|
-
copyToClipboard(value) {
|
|
213
|
-
navigator.clipboard.writeText(value);
|
|
214
|
-
},
|
|
215
|
-
resetCurrentPage() {
|
|
216
|
-
this.currentPage = 1;
|
|
217
|
-
},
|
|
218
|
-
refresh() {
|
|
219
|
-
this.$root.$emit('bv::refresh::table', 'tokens-table');
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
</script>
|
|
224
|
-
|
|
225
|
-
<template>
|
|
226
|
-
<div>
|
|
227
|
-
<p class="gl-text-sm gl-text-subtle">
|
|
228
|
-
For full token details, see
|
|
229
|
-
<gl-link
|
|
230
|
-
href="https://gitlab.com/gitlab-org/gitlab-ui/-/tree/main/src/tokens/build/json"
|
|
231
|
-
target="_blank"
|
|
232
|
-
>https://gitlab.com/gitlab-org/gitlab-ui/-/tree/main/src/tokens/build/json</gl-link
|
|
233
|
-
>
|
|
234
|
-
</p>
|
|
235
|
-
<div class="gl-mb-5 gl-flex gl-items-center gl-gap-3">
|
|
236
|
-
<gl-search-box-by-type v-model="filter" debounce="250" class="gl-grow" />
|
|
237
|
-
</div>
|
|
238
|
-
<gl-table
|
|
239
|
-
id="tokens-table"
|
|
240
|
-
:filter="filter"
|
|
241
|
-
:items="itemsProvider"
|
|
242
|
-
:fields="$options.fields"
|
|
243
|
-
:tbody-tr-attr="(item) => ({ id: item.id })"
|
|
244
|
-
:current-page="currentPage"
|
|
245
|
-
:per-page="perPage"
|
|
246
|
-
hover
|
|
247
|
-
fixed
|
|
248
|
-
stacked="sm"
|
|
249
|
-
>
|
|
250
|
-
<template
|
|
251
|
-
#cell(description)="{
|
|
252
|
-
item: { name, deprecated, description, className, figmaName, cssName, scssName },
|
|
253
|
-
}"
|
|
254
|
-
>
|
|
255
|
-
<strong class="gl-heading-4 !gl-mb-2 gl-flex gl-items-center gl-gap-3">
|
|
256
|
-
{{ name }}
|
|
257
|
-
<gl-button
|
|
258
|
-
v-gl-tooltip
|
|
259
|
-
title="Copy token name value to clipboard"
|
|
260
|
-
icon="copy-to-clipboard"
|
|
261
|
-
aria-label="Copy token name value to clipboard"
|
|
262
|
-
size="small"
|
|
263
|
-
@click="copyToClipboard(name)"
|
|
264
|
-
/>
|
|
265
|
-
<gl-badge v-if="deprecated" variant="danger">Deprecated</gl-badge>
|
|
266
|
-
</strong>
|
|
267
|
-
|
|
268
|
-
<p v-if="description" class="gl-mt-3 gl-text-subtle">
|
|
269
|
-
{{ description }}
|
|
270
|
-
</p>
|
|
271
|
-
|
|
272
|
-
<ul class="!gl-m-0 gl-flex gl-list-none gl-flex-col !gl-p-0">
|
|
273
|
-
<li>
|
|
274
|
-
<code class="gl-text-base gl-text-strong">
|
|
275
|
-
<span class="gl-inline-block gl-w-12">Tailwind:</span> {{ className }}
|
|
276
|
-
<gl-button
|
|
277
|
-
v-gl-tooltip
|
|
278
|
-
title="Copy Tailwind class to clipboard"
|
|
279
|
-
icon="copy-to-clipboard"
|
|
280
|
-
aria-label="Copy Tailwind class to clipboard"
|
|
281
|
-
size="small"
|
|
282
|
-
category="tertiary"
|
|
283
|
-
@click="copyToClipboard(className)"
|
|
284
|
-
/>
|
|
285
|
-
</code>
|
|
286
|
-
</li>
|
|
287
|
-
<li>
|
|
288
|
-
<code class="gl-text-base gl-text-strong">
|
|
289
|
-
<span class="gl-inline-block gl-w-12">Figma:</span> {{ figmaName }}
|
|
290
|
-
<gl-button
|
|
291
|
-
v-gl-tooltip
|
|
292
|
-
title="Copy Figma value to clipboard"
|
|
293
|
-
icon="copy-to-clipboard"
|
|
294
|
-
aria-label="Copy Figma value to clipboard"
|
|
295
|
-
size="small"
|
|
296
|
-
category="tertiary"
|
|
297
|
-
@click="copyToClipboard(figmaName)"
|
|
298
|
-
/>
|
|
299
|
-
</code>
|
|
300
|
-
</li>
|
|
301
|
-
<li>
|
|
302
|
-
<code class="gl-text-base gl-text-strong">
|
|
303
|
-
<span class="gl-inline-block gl-w-12">CSS:</span> {{ cssName }}
|
|
304
|
-
<gl-button
|
|
305
|
-
v-gl-tooltip
|
|
306
|
-
title="Copy CSS value to clipboard"
|
|
307
|
-
icon="copy-to-clipboard"
|
|
308
|
-
aria-label="Copy CSS value to clipboard"
|
|
309
|
-
size="small"
|
|
310
|
-
category="tertiary"
|
|
311
|
-
@click="copyToClipboard(cssName)"
|
|
312
|
-
/>
|
|
313
|
-
</code>
|
|
314
|
-
</li>
|
|
315
|
-
<li>
|
|
316
|
-
<code class="gl-text-base gl-text-strong">
|
|
317
|
-
<span class="gl-inline-block gl-w-12">SCSS:</span> {{ scssName }}
|
|
318
|
-
<gl-button
|
|
319
|
-
v-gl-tooltip
|
|
320
|
-
title="Copy SCSS value to clipboard"
|
|
321
|
-
icon="copy-to-clipboard"
|
|
322
|
-
aria-label="Copy SCSS value to clipboard"
|
|
323
|
-
size="small"
|
|
324
|
-
category="tertiary"
|
|
325
|
-
@click="copyToClipboard(scssName)"
|
|
326
|
-
/>
|
|
327
|
-
</code>
|
|
328
|
-
</li>
|
|
329
|
-
</ul>
|
|
330
|
-
</template>
|
|
331
|
-
<template #cell(value)="{ item: { type, valueLabel, cssValue } }">
|
|
332
|
-
<div class="gl-flex gl-items-start gl-gap-3">
|
|
333
|
-
<div
|
|
334
|
-
v-if="isColor(type)"
|
|
335
|
-
class="gl-border gl-h-5 gl-w-5 gl-rounded-base"
|
|
336
|
-
:style="{ 'background-color': cssValue }"
|
|
337
|
-
></div>
|
|
338
|
-
<code class="gl-min-w-0 gl-text-base gl-text-strong">{{ valueLabel }}</code>
|
|
339
|
-
</div>
|
|
340
|
-
</template>
|
|
341
|
-
<template #cell(value_dark)="{ item: { type, darkValueLabel, cssValue } }">
|
|
342
|
-
<div class="gl-flex gl-items-start gl-gap-3">
|
|
343
|
-
<div
|
|
344
|
-
v-if="isColor(type)"
|
|
345
|
-
class="gl-dark-scope gl-border gl-h-5 gl-w-5 gl-rounded-base"
|
|
346
|
-
:style="{ 'background-color': cssValue }"
|
|
347
|
-
></div>
|
|
348
|
-
<code class="gl-min-w-0 gl-text-base gl-text-strong">{{ darkValueLabel }}</code>
|
|
349
|
-
</div>
|
|
350
|
-
</template>
|
|
351
|
-
</gl-table>
|
|
352
|
-
|
|
353
|
-
<gl-pagination
|
|
354
|
-
v-model="currentPage"
|
|
355
|
-
align="center"
|
|
356
|
-
:per-page="perPage"
|
|
357
|
-
:total-items="totalFilteredItems"
|
|
358
|
-
/>
|
|
359
|
-
</div>
|
|
360
|
-
</template>
|