@gitlab/ui 115.9.2 → 115.10.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/dist/components/base/avatar/avatar.js +1 -1
- package/dist/components/base/form/form_textarea/form_textarea.js +9 -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/css/tokens.css +1 -1
- package/package.json +4 -5
- package/src/components/base/avatar/avatar.vue +1 -0
- package/src/components/base/form/form_textarea/form_textarea.vue +10 -2
- package/src/tokens/build/css/tokens.css +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,278 +0,0 @@
|
|
|
1
|
-
import Fuse from 'fuse.js';
|
|
2
|
-
import GlBadge from '../components/base/badge/badge';
|
|
3
|
-
import GlButton from '../components/base/button/button';
|
|
4
|
-
import GlSearchBoxByType from '../components/base/search_box_by_type/search_box_by_type';
|
|
5
|
-
import GlLink from '../components/base/link/link';
|
|
6
|
-
import GlTable from '../components/base/table/table';
|
|
7
|
-
import GlPagination from '../components/base/pagination/pagination';
|
|
8
|
-
import { GlTooltipDirective } from '../directives/tooltip/tooltip';
|
|
9
|
-
import TOKENS_DEFAULT from './build/docs/tokens-tailwind-docs.json';
|
|
10
|
-
import TOKENS_DARK from './build/docs/tokens-tailwind-docs.dark.json';
|
|
11
|
-
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
12
|
-
|
|
13
|
-
var script = {
|
|
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
|
-
key: 'description',
|
|
32
|
-
label: 'Description'
|
|
33
|
-
}, {
|
|
34
|
-
key: 'value',
|
|
35
|
-
label: 'Light mode',
|
|
36
|
-
thClass: 'gl-w-1/5'
|
|
37
|
-
}, {
|
|
38
|
-
key: 'value_dark',
|
|
39
|
-
label: 'Dark mode',
|
|
40
|
-
thClass: 'gl-w-1/5'
|
|
41
|
-
}],
|
|
42
|
-
data() {
|
|
43
|
-
return {
|
|
44
|
-
filter: '',
|
|
45
|
-
currentPage: 1,
|
|
46
|
-
perPage: 50,
|
|
47
|
-
totalFilteredItems: 0
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
watch: {
|
|
51
|
-
filter: 'resetCurrentPage'
|
|
52
|
-
},
|
|
53
|
-
methods: {
|
|
54
|
-
isColor(type) {
|
|
55
|
-
return type === 'color';
|
|
56
|
-
},
|
|
57
|
-
isAliasValue(value) {
|
|
58
|
-
return typeof value === 'string' && value.includes('{');
|
|
59
|
-
},
|
|
60
|
-
isAliasObject(value) {
|
|
61
|
-
return typeof value === 'object' && Object.values(value).some(val => this.isAliasValue(val));
|
|
62
|
-
},
|
|
63
|
-
getAliasValueName(value) {
|
|
64
|
-
if (this.isAliasValue(value)) {
|
|
65
|
-
return value.slice(1, -1);
|
|
66
|
-
}
|
|
67
|
-
return value;
|
|
68
|
-
},
|
|
69
|
-
getValueLabel(token) {
|
|
70
|
-
const value = token.original.$value;
|
|
71
|
-
if (this.isAliasObject(value)) {
|
|
72
|
-
return this.getAliasValueName(value.default);
|
|
73
|
-
}
|
|
74
|
-
if (this.isAliasValue(value)) {
|
|
75
|
-
return this.getAliasValueName(value);
|
|
76
|
-
}
|
|
77
|
-
return token.$value;
|
|
78
|
-
},
|
|
79
|
-
getDarkValueLabel(token) {
|
|
80
|
-
const value = token.original.$value;
|
|
81
|
-
if (this.isAliasObject(value)) {
|
|
82
|
-
return this.getAliasValueName(value.dark);
|
|
83
|
-
}
|
|
84
|
-
if (this.isAliasValue(value)) {
|
|
85
|
-
return this.getAliasValueName(value);
|
|
86
|
-
}
|
|
87
|
-
return token.$value;
|
|
88
|
-
},
|
|
89
|
-
transformTokenToTableColumns(token) {
|
|
90
|
-
return {
|
|
91
|
-
id: token.path.filter(Boolean).join('-'),
|
|
92
|
-
name: this.formatTokenName('name', token),
|
|
93
|
-
type: token.$type,
|
|
94
|
-
value: token.$value,
|
|
95
|
-
valueLabel: this.getValueLabel(token),
|
|
96
|
-
darkValueLabel: this.getDarkValueLabel(token),
|
|
97
|
-
deprecated: token.$deprecated ? 'deprecated' : '',
|
|
98
|
-
description: token.$description,
|
|
99
|
-
className: this.formatContextToClass(token.context),
|
|
100
|
-
cssValue: token.cssWithValue,
|
|
101
|
-
figmaName: this.formatTokenName('figma', token),
|
|
102
|
-
cssName: this.formatTokenName('css', token),
|
|
103
|
-
scssName: this.formatTokenName('scss', token)
|
|
104
|
-
};
|
|
105
|
-
},
|
|
106
|
-
filterItems(items, filter) {
|
|
107
|
-
if (!filter) return items;
|
|
108
|
-
const fuse = new Fuse(items, {
|
|
109
|
-
keys: Object.keys(items[0]),
|
|
110
|
-
includeScore: true
|
|
111
|
-
});
|
|
112
|
-
const results = fuse.search(filter);
|
|
113
|
-
return results.sort((a, b) => {
|
|
114
|
-
if (a.item.deprecated && !b.item.deprecated) return 1;
|
|
115
|
-
if (!a.item.deprecated && b.item.deprecated) return -1;
|
|
116
|
-
return a.score - b.score;
|
|
117
|
-
}).map(_ref => {
|
|
118
|
-
let {
|
|
119
|
-
item
|
|
120
|
-
} = _ref;
|
|
121
|
-
return item;
|
|
122
|
-
});
|
|
123
|
-
},
|
|
124
|
-
paginateItems(items, currentPage, perPage) {
|
|
125
|
-
const start = (currentPage - 1) * perPage;
|
|
126
|
-
return items.slice(start, start + perPage);
|
|
127
|
-
},
|
|
128
|
-
itemsProvider(_ref2) {
|
|
129
|
-
let {
|
|
130
|
-
currentPage,
|
|
131
|
-
perPage,
|
|
132
|
-
filter
|
|
133
|
-
} = _ref2;
|
|
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) {
|
|
147
|
-
let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
148
|
-
const tokensArray = [];
|
|
149
|
-
Object.keys(tokens).forEach(key => {
|
|
150
|
-
const token = tokens[key];
|
|
151
|
-
if (token.$value) {
|
|
152
|
-
tokensArray.push(this.transformTokenToTableColumns({
|
|
153
|
-
...token,
|
|
154
|
-
context: [...context, key]
|
|
155
|
-
}));
|
|
156
|
-
} else if (key !== 'colors') {
|
|
157
|
-
tokensArray.push(...this.transformTokensToTableRows(token, [...context, key]));
|
|
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
|
-
return tokensArray;
|
|
182
|
-
},
|
|
183
|
-
formatTokenName(format, token) {
|
|
184
|
-
let figmaPrefix = '';
|
|
185
|
-
const prefix = token.prefix === false ? '' : 'gl';
|
|
186
|
-
switch (format) {
|
|
187
|
-
case 'figma':
|
|
188
|
-
if (token.filePath.match('contextual')) {
|
|
189
|
-
figmaPrefix = '🔒/';
|
|
190
|
-
}
|
|
191
|
-
if (token.$deprecated) {
|
|
192
|
-
figmaPrefix = '⚠️ DEPRECATED/';
|
|
193
|
-
}
|
|
194
|
-
return `${figmaPrefix}${token.path.filter(Boolean).join('-')}`;
|
|
195
|
-
case 'css':
|
|
196
|
-
return `var(--${[prefix, ...token.path].filter(Boolean).join('-')})`;
|
|
197
|
-
case 'scss':
|
|
198
|
-
return `$${[prefix, ...token.path].filter(Boolean).join('-')}`;
|
|
199
|
-
default:
|
|
200
|
-
return token.path.filter(Boolean).join('.');
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
formatContextToClass(context) {
|
|
204
|
-
const cleanContext = context.filter(segment => segment !== 'color');
|
|
205
|
-
if (cleanContext[0] === 'background') {
|
|
206
|
-
cleanContext[0] = 'bg';
|
|
207
|
-
}
|
|
208
|
-
// eslint-disable-next-line @gitlab/tailwind-no-interpolation
|
|
209
|
-
return `gl-${cleanContext.join('-')}`;
|
|
210
|
-
},
|
|
211
|
-
copyToClipboard(value) {
|
|
212
|
-
navigator.clipboard.writeText(value);
|
|
213
|
-
},
|
|
214
|
-
resetCurrentPage() {
|
|
215
|
-
this.currentPage = 1;
|
|
216
|
-
},
|
|
217
|
-
refresh() {
|
|
218
|
-
this.$root.$emit('bv::refresh::table', 'tokens-table');
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
/* script */
|
|
224
|
-
const __vue_script__ = script;
|
|
225
|
-
|
|
226
|
-
/* template */
|
|
227
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('p',{staticClass:"gl-text-sm gl-text-subtle"},[_vm._v("\n For full token details, see\n "),_c('gl-link',{attrs:{"href":"https://gitlab.com/gitlab-org/gitlab-ui/-/tree/main/src/tokens/build/json","target":"_blank"}},[_vm._v("https://gitlab.com/gitlab-org/gitlab-ui/-/tree/main/src/tokens/build/json")])],1),_vm._v(" "),_c('div',{staticClass:"gl-mb-5 gl-flex gl-items-center gl-gap-3"},[_c('gl-search-box-by-type',{staticClass:"gl-grow",attrs:{"debounce":"250"},model:{value:(_vm.filter),callback:function ($$v) {_vm.filter=$$v;},expression:"filter"}})],1),_vm._v(" "),_c('gl-table',{attrs:{"id":"tokens-table","filter":_vm.filter,"items":_vm.itemsProvider,"fields":_vm.$options.fields,"tbody-tr-attr":function (item) { return ({ id: item.id }); },"current-page":_vm.currentPage,"per-page":_vm.perPage,"hover":"","fixed":"","stacked":"sm"},scopedSlots:_vm._u([{key:"cell(description)",fn:function(ref){
|
|
228
|
-
var ref_item = ref.item;
|
|
229
|
-
var name = ref_item.name;
|
|
230
|
-
var deprecated = ref_item.deprecated;
|
|
231
|
-
var description = ref_item.description;
|
|
232
|
-
var className = ref_item.className;
|
|
233
|
-
var figmaName = ref_item.figmaName;
|
|
234
|
-
var cssName = ref_item.cssName;
|
|
235
|
-
var scssName = ref_item.scssName;
|
|
236
|
-
return [_c('strong',{staticClass:"gl-heading-4 !gl-mb-2 gl-flex gl-items-center gl-gap-3"},[_vm._v("\n "+_vm._s(name)+"\n "),_c('gl-button',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip"}],attrs:{"title":"Copy token name value to clipboard","icon":"copy-to-clipboard","aria-label":"Copy token name value to clipboard","size":"small"},on:{"click":function($event){return _vm.copyToClipboard(name)}}}),_vm._v(" "),(deprecated)?_c('gl-badge',{attrs:{"variant":"danger"}},[_vm._v("Deprecated")]):_vm._e()],1),_vm._v(" "),(description)?_c('p',{staticClass:"gl-mt-3 gl-text-subtle"},[_vm._v("\n "+_vm._s(description)+"\n ")]):_vm._e(),_vm._v(" "),_c('ul',{staticClass:"!gl-m-0 gl-flex gl-list-none gl-flex-col !gl-p-0"},[_c('li',[_c('code',{staticClass:"gl-text-base gl-text-strong"},[_c('span',{staticClass:"gl-inline-block gl-w-12"},[_vm._v("Tailwind:")]),_vm._v(" "+_vm._s(className)+"\n "),_c('gl-button',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip"}],attrs:{"title":"Copy Tailwind class to clipboard","icon":"copy-to-clipboard","aria-label":"Copy Tailwind class to clipboard","size":"small","category":"tertiary"},on:{"click":function($event){return _vm.copyToClipboard(className)}}})],1)]),_vm._v(" "),_c('li',[_c('code',{staticClass:"gl-text-base gl-text-strong"},[_c('span',{staticClass:"gl-inline-block gl-w-12"},[_vm._v("Figma:")]),_vm._v(" "+_vm._s(figmaName)+"\n "),_c('gl-button',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip"}],attrs:{"title":"Copy Figma value to clipboard","icon":"copy-to-clipboard","aria-label":"Copy Figma value to clipboard","size":"small","category":"tertiary"},on:{"click":function($event){return _vm.copyToClipboard(figmaName)}}})],1)]),_vm._v(" "),_c('li',[_c('code',{staticClass:"gl-text-base gl-text-strong"},[_c('span',{staticClass:"gl-inline-block gl-w-12"},[_vm._v("CSS:")]),_vm._v(" "+_vm._s(cssName)+"\n "),_c('gl-button',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip"}],attrs:{"title":"Copy CSS value to clipboard","icon":"copy-to-clipboard","aria-label":"Copy CSS value to clipboard","size":"small","category":"tertiary"},on:{"click":function($event){return _vm.copyToClipboard(cssName)}}})],1)]),_vm._v(" "),_c('li',[_c('code',{staticClass:"gl-text-base gl-text-strong"},[_c('span',{staticClass:"gl-inline-block gl-w-12"},[_vm._v("SCSS:")]),_vm._v(" "+_vm._s(scssName)+"\n "),_c('gl-button',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip"}],attrs:{"title":"Copy SCSS value to clipboard","icon":"copy-to-clipboard","aria-label":"Copy SCSS value to clipboard","size":"small","category":"tertiary"},on:{"click":function($event){return _vm.copyToClipboard(scssName)}}})],1)])])]}},{key:"cell(value)",fn:function(ref){
|
|
237
|
-
var ref_item = ref.item;
|
|
238
|
-
var type = ref_item.type;
|
|
239
|
-
var valueLabel = ref_item.valueLabel;
|
|
240
|
-
var cssValue = ref_item.cssValue;
|
|
241
|
-
return [_c('div',{staticClass:"gl-flex gl-items-start gl-gap-3"},[(_vm.isColor(type))?_c('div',{staticClass:"gl-border gl-h-5 gl-w-5 gl-rounded-base",style:({ 'background-color': cssValue })}):_vm._e(),_vm._v(" "),_c('code',{staticClass:"gl-min-w-0 gl-text-base gl-text-strong"},[_vm._v(_vm._s(valueLabel))])])]}},{key:"cell(value_dark)",fn:function(ref){
|
|
242
|
-
var ref_item = ref.item;
|
|
243
|
-
var type = ref_item.type;
|
|
244
|
-
var darkValueLabel = ref_item.darkValueLabel;
|
|
245
|
-
var cssValue = ref_item.cssValue;
|
|
246
|
-
return [_c('div',{staticClass:"gl-flex gl-items-start gl-gap-3"},[(_vm.isColor(type))?_c('div',{staticClass:"gl-dark-scope gl-border gl-h-5 gl-w-5 gl-rounded-base",style:({ 'background-color': cssValue })}):_vm._e(),_vm._v(" "),_c('code',{staticClass:"gl-min-w-0 gl-text-base gl-text-strong"},[_vm._v(_vm._s(darkValueLabel))])])]}}])}),_vm._v(" "),_c('gl-pagination',{attrs:{"align":"center","per-page":_vm.perPage,"total-items":_vm.totalFilteredItems},model:{value:(_vm.currentPage),callback:function ($$v) {_vm.currentPage=$$v;},expression:"currentPage"}})],1)};
|
|
247
|
-
var __vue_staticRenderFns__ = [];
|
|
248
|
-
|
|
249
|
-
/* style */
|
|
250
|
-
const __vue_inject_styles__ = undefined;
|
|
251
|
-
/* scoped */
|
|
252
|
-
const __vue_scope_id__ = undefined;
|
|
253
|
-
/* module identifier */
|
|
254
|
-
const __vue_module_identifier__ = undefined;
|
|
255
|
-
/* functional template */
|
|
256
|
-
const __vue_is_functional_template__ = false;
|
|
257
|
-
/* style inject */
|
|
258
|
-
|
|
259
|
-
/* style inject SSR */
|
|
260
|
-
|
|
261
|
-
/* style inject shadow dom */
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const __vue_component__ = /*#__PURE__*/__vue_normalize__(
|
|
266
|
-
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
267
|
-
__vue_inject_styles__,
|
|
268
|
-
__vue_script__,
|
|
269
|
-
__vue_scope_id__,
|
|
270
|
-
__vue_is_functional_template__,
|
|
271
|
-
__vue_module_identifier__,
|
|
272
|
-
false,
|
|
273
|
-
undefined,
|
|
274
|
-
undefined,
|
|
275
|
-
undefined
|
|
276
|
-
);
|
|
277
|
-
|
|
278
|
-
export { __vue_component__ as default };
|
|
@@ -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>
|