@gitlab/ui 137.1.2 → 137.2.1
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/charts/chart/chart.js +81 -20
- package/dist/components/charts/gauge/gauge.js +3 -13
- package/dist/components/charts/heatmap/heatmap.js +33 -13
- package/dist/components/charts/legend/legend.js +13 -1
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/tokens/build/js/tokens.dark.js +196 -191
- package/dist/tokens/build/js/tokens.js +218 -213
- package/dist/tokens/color_mode.js +17 -0
- package/dist/utils/charts/color_mode.js +95 -0
- package/dist/utils/charts/css_values.js +105 -0
- package/dist/utils/charts/theme.js +72 -7
- package/dist/utils/constants.js +5 -5
- package/package.json +6 -6
- package/src/components/base/alert/alert.scss +13 -48
- package/src/components/charts/chart/chart.vue +68 -22
- package/src/components/charts/gauge/gauge.vue +1 -12
- package/src/components/charts/heatmap/heatmap.vue +34 -10
- package/src/components/charts/legend/legend.vue +13 -1
- package/src/scss/themes.scss +23 -5
- package/src/tokens/build/css/tokens.css +20 -15
- package/src/tokens/build/css/tokens.dark.css +32 -27
- package/src/tokens/build/docs/tokens-tailwind-docs.dark.json +199 -199
- package/src/tokens/build/docs/tokens-tailwind-docs.json +198 -198
- package/src/tokens/build/figma/constants.dark.json +33 -33
- package/src/tokens/build/figma/constants.json +33 -33
- package/src/tokens/build/figma/mode.dark.json +66 -16
- package/src/tokens/build/figma/mode.json +54 -4
- package/src/tokens/build/js/tokens.dark.js +195 -190
- package/src/tokens/build/js/tokens.js +217 -212
- package/src/tokens/build/json/tokens.dark.json +378 -218
- package/src/tokens/build/json/tokens.json +388 -228
- package/src/tokens/build/scss/_tokens.dark.scss +32 -27
- package/src/tokens/build/scss/_tokens.scss +20 -15
- package/src/tokens/build/scss/_tokens_custom_properties.scss +5 -0
- package/src/tokens/color_mode.js +16 -0
- package/src/tokens/constant/color.neutral.tokens.json +33 -33
- package/src/tokens/contextual/alert.tokens.json +80 -35
- package/src/tokens/semantic/action.tokens.json +3 -3
- package/src/tokens/semantic/feedback.tokens.json +6 -6
- package/src/utils/charts/color_mode.js +83 -0
- package/src/utils/charts/css_values.js +59 -0
- package/src/utils/charts/theme.js +72 -5
- package/src/utils/constants.js +5 -5
|
@@ -2,6 +2,8 @@ import * as echarts from 'echarts';
|
|
|
2
2
|
import { merge } from 'lodash-es';
|
|
3
3
|
import { validRenderers, toolboxHeight, defaultWidth, defaultHeight } from '../../../utils/charts/config';
|
|
4
4
|
import { themeName, createTheme } from '../../../utils/charts/theme';
|
|
5
|
+
import { resolveCssValues } from '../../../utils/charts/css_values';
|
|
6
|
+
import { onColorModeChange } from '../../../utils/charts/color_mode';
|
|
5
7
|
import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
|
|
6
8
|
import { debounceByAnimationFrame } from '../../../utils/utils';
|
|
7
9
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
@@ -126,32 +128,91 @@ var script = {
|
|
|
126
128
|
},
|
|
127
129
|
async mounted() {
|
|
128
130
|
await this.$nextTick();
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
width: defaultWidth,
|
|
132
|
-
height: defaultHeight
|
|
133
|
-
});
|
|
134
|
-
// FIXME: temporary workaround to ensure compatibility with @vue/compat
|
|
135
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
136
|
-
chart.__v_skip = true;
|
|
137
|
-
this.chart = chart;
|
|
138
|
-
if (this.groupId.length) {
|
|
139
|
-
this.chart.group = this.groupId;
|
|
140
|
-
echarts.connect(this.groupId);
|
|
141
|
-
}
|
|
142
|
-
this.chart.on('click', this.handleClick);
|
|
143
|
-
/**
|
|
144
|
-
* Emitted after calling `echarts.init`
|
|
145
|
-
*/
|
|
146
|
-
this.$emit('created', this.chart);
|
|
147
|
-
this.draw();
|
|
148
|
-
this.setChartSize();
|
|
131
|
+
this.initChart();
|
|
132
|
+
this.observeColorMode();
|
|
149
133
|
},
|
|
150
134
|
beforeDestroy() {
|
|
135
|
+
var _this$unsubscribeColo;
|
|
151
136
|
if (!this.chart) return;
|
|
152
137
|
this.chart.off('click', this.handleClick);
|
|
138
|
+
(_this$unsubscribeColo = this.unsubscribeColorMode) === null || _this$unsubscribeColo === void 0 ? void 0 : _this$unsubscribeColo.call(this);
|
|
153
139
|
},
|
|
154
140
|
methods: {
|
|
141
|
+
initChart() {
|
|
142
|
+
const chart = echarts.init(this.$refs.chart, this.theme(), {
|
|
143
|
+
renderer: this.renderer,
|
|
144
|
+
width: defaultWidth,
|
|
145
|
+
height: defaultHeight
|
|
146
|
+
});
|
|
147
|
+
// FIXME: temporary workaround to ensure compatibility with @vue/compat
|
|
148
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
149
|
+
chart.__v_skip = true;
|
|
150
|
+
this.chart = chart;
|
|
151
|
+
if (this.groupId.length) {
|
|
152
|
+
this.chart.group = this.groupId;
|
|
153
|
+
echarts.connect(this.groupId);
|
|
154
|
+
}
|
|
155
|
+
this.chart.on('click', this.handleClick);
|
|
156
|
+
/**
|
|
157
|
+
* Emitted after calling `echarts.init`
|
|
158
|
+
*/
|
|
159
|
+
this.$emit('created', this.chart);
|
|
160
|
+
this.draw();
|
|
161
|
+
this.setChartSize();
|
|
162
|
+
},
|
|
163
|
+
/**
|
|
164
|
+
* The SVG renderer consumes the registered theme as-is, leaving its `var(--token)` colours for
|
|
165
|
+
* the browser to resolve. Canvas cannot, so it gets a copy resolved against this element.
|
|
166
|
+
*/
|
|
167
|
+
theme() {
|
|
168
|
+
if (this.renderer !== 'canvas') {
|
|
169
|
+
return themeName;
|
|
170
|
+
}
|
|
171
|
+
return resolveCssValues(createTheme(this.options), this.$refs.chart);
|
|
172
|
+
},
|
|
173
|
+
/**
|
|
174
|
+
* Rebuilding the chart discards its interaction state, so the legend selection and zoom range
|
|
175
|
+
* are carried over. Only these stateful fields are copied: the full option from getOption()
|
|
176
|
+
* holds colours resolved against the old colour mode.
|
|
177
|
+
*/
|
|
178
|
+
preservedState() {
|
|
179
|
+
const _this$chart$getOption = this.chart.getOption(),
|
|
180
|
+
_this$chart$getOption2 = _this$chart$getOption.legend,
|
|
181
|
+
legend = _this$chart$getOption2 === void 0 ? [] : _this$chart$getOption2,
|
|
182
|
+
_this$chart$getOption3 = _this$chart$getOption.dataZoom,
|
|
183
|
+
dataZoom = _this$chart$getOption3 === void 0 ? [] : _this$chart$getOption3;
|
|
184
|
+
return {
|
|
185
|
+
legend: legend.map(_ref => {
|
|
186
|
+
let selected = _ref.selected;
|
|
187
|
+
return {
|
|
188
|
+
selected
|
|
189
|
+
};
|
|
190
|
+
}),
|
|
191
|
+
dataZoom: dataZoom.map(_ref2 => {
|
|
192
|
+
let start = _ref2.start,
|
|
193
|
+
end = _ref2.end;
|
|
194
|
+
return {
|
|
195
|
+
start,
|
|
196
|
+
end
|
|
197
|
+
};
|
|
198
|
+
})
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
/**
|
|
202
|
+
* Colours resolved for canvas are frozen at init, so the chart has to be rebuilt when the
|
|
203
|
+
* colour mode changes. SVG re-resolves on its own and needs no subscription.
|
|
204
|
+
*/
|
|
205
|
+
observeColorMode() {
|
|
206
|
+
if (this.renderer !== 'canvas') {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
this.unsubscribeColorMode = onColorModeChange(this.$refs.chart, () => {
|
|
210
|
+
const state = this.preservedState();
|
|
211
|
+
this.chart.dispose();
|
|
212
|
+
this.initChart();
|
|
213
|
+
this.chart.setOption(state);
|
|
214
|
+
});
|
|
215
|
+
},
|
|
155
216
|
draw() {
|
|
156
217
|
this.chart.setOption(this.modifiedOptions);
|
|
157
218
|
/**
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { merge, uniq, sortBy } from 'lodash-es';
|
|
2
|
-
import { gaugeSafeHues, gaugeWarningHue
|
|
2
|
+
import { gaugeSafeHues, gaugeWarningHue } from '../../../utils/charts/theme';
|
|
3
3
|
import Chart from '../chart/chart';
|
|
4
4
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
5
5
|
|
|
6
|
-
const AXIS_LABEL_FONT_SIZE_PX = 14;
|
|
7
6
|
const ARC_RADIUS = '80%';
|
|
8
|
-
const DETAIL_FONT_SIZE_PX = 30;
|
|
9
|
-
const DETAIL_FONT_FAMILY = 'sans-serif';
|
|
10
|
-
const DETAIL_FONT_WEIGHT = 'bold';
|
|
11
7
|
const POINTER_LENGTH = '65%';
|
|
12
8
|
const POINTER_WIDTH_PX = 5;
|
|
13
9
|
const gaugeChartSeries = _ref => {
|
|
@@ -24,17 +20,11 @@ const gaugeChartSeries = _ref => {
|
|
|
24
20
|
formatter: () => {
|
|
25
21
|
const currentValue = Number.isFinite(value) ? value : null;
|
|
26
22
|
return text || (currentValue !== null && currentValue !== void 0 ? currentValue : '--');
|
|
27
|
-
}
|
|
28
|
-
color: `${gaugeNeutralHues[0]}`,
|
|
29
|
-
fontSize: DETAIL_FONT_SIZE_PX,
|
|
30
|
-
fontFamily: DETAIL_FONT_FAMILY,
|
|
31
|
-
fontWeight: DETAIL_FONT_WEIGHT
|
|
23
|
+
}
|
|
32
24
|
},
|
|
33
25
|
axisLabel: {
|
|
34
26
|
show: true,
|
|
35
|
-
|
|
36
|
-
formatter: theValue => Number.isFinite(theValue) ? theValue : '--',
|
|
37
|
-
color: `${gaugeNeutralHues[1]}`
|
|
27
|
+
formatter: theValue => Number.isFinite(theValue) ? theValue : '--'
|
|
38
28
|
},
|
|
39
29
|
axisLine: {
|
|
40
30
|
lineStyle: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { merge } from 'lodash-es';
|
|
2
|
-
import { GL_COLOR_NEUTRAL_100, GL_COLOR_NEUTRAL_0 } from '../../../tokens/build/js/tokens';
|
|
3
2
|
import { getTooltipTitle, getTooltipContent } from '../../../utils/charts/config';
|
|
4
3
|
import { HEIGHT_AUTO_CLASSES } from '../../../utils/charts/constants';
|
|
5
|
-
import { heatmapHues } from '../../../utils/charts/theme';
|
|
4
|
+
import { heatmapHuesDark, heatmapHues, heatmapSurfaceDark, heatmapSurface } from '../../../utils/charts/theme';
|
|
5
|
+
import { isDarkMode, onColorModeChange } from '../../../utils/charts/color_mode';
|
|
6
6
|
import { engineeringNotation } from '../../../utils/number_utils';
|
|
7
7
|
import TooltipDefaultFormat from '../shared/tooltip/tooltip_default_format/tooltip_default_format';
|
|
8
8
|
import Chart from '../chart/chart';
|
|
@@ -61,10 +61,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
61
61
|
|
|
62
62
|
const defaultOptions = {
|
|
63
63
|
visualMap: {
|
|
64
|
-
show: false
|
|
65
|
-
inRange: {
|
|
66
|
-
color: heatmapHues
|
|
67
|
-
}
|
|
64
|
+
show: false
|
|
68
65
|
},
|
|
69
66
|
series: {
|
|
70
67
|
type: 'heatmap'
|
|
@@ -201,10 +198,20 @@ var script = {
|
|
|
201
198
|
left: '0',
|
|
202
199
|
top: '0'
|
|
203
200
|
},
|
|
204
|
-
selectedFormatTooltipText: this.formatTooltipText || this.defaultFormatTooltipText
|
|
201
|
+
selectedFormatTooltipText: this.formatTooltipText || this.defaultFormatTooltipText,
|
|
202
|
+
// ECharts interpolates the visualMap stops numerically, so these colours cannot be CSS
|
|
203
|
+
// custom properties and have to be picked for the current colour mode instead. Resolved on
|
|
204
|
+
// mount, because the mode depends on where this chart sits in the document.
|
|
205
|
+
isDark: false
|
|
205
206
|
};
|
|
206
207
|
},
|
|
207
208
|
computed: {
|
|
209
|
+
hues() {
|
|
210
|
+
return this.isDark ? heatmapHuesDark : heatmapHues;
|
|
211
|
+
},
|
|
212
|
+
surface() {
|
|
213
|
+
return this.isDark ? heatmapSurfaceDark : heatmapSurface;
|
|
214
|
+
},
|
|
208
215
|
computedOptions() {
|
|
209
216
|
const _getRange = getRange(this.dataSeries),
|
|
210
217
|
min = _getRange.min,
|
|
@@ -219,11 +226,14 @@ var script = {
|
|
|
219
226
|
right: '32px',
|
|
220
227
|
show: true,
|
|
221
228
|
borderWidth: 0,
|
|
222
|
-
backgroundColor:
|
|
229
|
+
backgroundColor: this.surface.plate
|
|
223
230
|
},
|
|
224
231
|
visualMap: {
|
|
225
232
|
min,
|
|
226
|
-
max
|
|
233
|
+
max,
|
|
234
|
+
inRange: {
|
|
235
|
+
color: this.hues
|
|
236
|
+
}
|
|
227
237
|
},
|
|
228
238
|
xAxis: {
|
|
229
239
|
data: this.xAxisLabels,
|
|
@@ -243,7 +253,7 @@ var script = {
|
|
|
243
253
|
show: true,
|
|
244
254
|
interval: 0,
|
|
245
255
|
lineStyle: {
|
|
246
|
-
color:
|
|
256
|
+
color: this.surface.separator,
|
|
247
257
|
width: 2
|
|
248
258
|
}
|
|
249
259
|
},
|
|
@@ -270,7 +280,7 @@ var script = {
|
|
|
270
280
|
show: true,
|
|
271
281
|
interval: 0,
|
|
272
282
|
lineStyle: {
|
|
273
|
-
color:
|
|
283
|
+
color: this.surface.separator,
|
|
274
284
|
width: 2
|
|
275
285
|
}
|
|
276
286
|
}
|
|
@@ -290,8 +300,8 @@ var script = {
|
|
|
290
300
|
const _getRange2 = getRange(this.dataSeries),
|
|
291
301
|
min = _getRange2.min,
|
|
292
302
|
max = _getRange2.max;
|
|
293
|
-
const step = (max - min) /
|
|
294
|
-
return
|
|
303
|
+
const step = (max - min) / this.hues.length;
|
|
304
|
+
return this.hues.map((color, index) => {
|
|
295
305
|
const lowerBound = engineeringNotation(min + step * index);
|
|
296
306
|
const upperBound = engineeringNotation(min + step * (index + 1));
|
|
297
307
|
return {
|
|
@@ -305,6 +315,16 @@ var script = {
|
|
|
305
315
|
return this.height === 'auto';
|
|
306
316
|
}
|
|
307
317
|
},
|
|
318
|
+
mounted() {
|
|
319
|
+
this.isDark = isDarkMode(this.$el);
|
|
320
|
+
this.unsubscribeColorMode = onColorModeChange(this.$el, isDark => {
|
|
321
|
+
this.isDark = isDark;
|
|
322
|
+
});
|
|
323
|
+
},
|
|
324
|
+
beforeDestroy() {
|
|
325
|
+
var _this$unsubscribeColo;
|
|
326
|
+
(_this$unsubscribeColo = this.unsubscribeColorMode) === null || _this$unsubscribeColo === void 0 ? void 0 : _this$unsubscribeColo.call(this);
|
|
327
|
+
},
|
|
308
328
|
methods: {
|
|
309
329
|
defaultFormatTooltipText(params) {
|
|
310
330
|
this.tooltip.title = getTooltipTitle(params, this.computedOptions.xAxis.name);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as echarts from 'echarts';
|
|
2
2
|
import { defaultFontSize } from '../../../utils/charts/config';
|
|
3
|
+
import { defaultFontFamily } from '../../../utils/charts/theme';
|
|
3
4
|
import { LEGEND_AVERAGE_TEXT, LEGEND_CURRENT_TEXT, LEGEND_MIN_TEXT, LEGEND_MAX_TEXT, LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE } from '../../../utils/charts/constants';
|
|
4
5
|
import { engineeringNotation, average } from '../../../utils/number_utils';
|
|
5
6
|
import GlTruncate from '../../utilities/truncate/truncate';
|
|
@@ -144,7 +145,7 @@ var script = {
|
|
|
144
145
|
computed: {
|
|
145
146
|
fontStyle() {
|
|
146
147
|
return {
|
|
147
|
-
fontFamily: this.textStyle.fontFamily ||
|
|
148
|
+
fontFamily: this.textStyle.fontFamily || defaultFontFamily,
|
|
148
149
|
fontSize: `${this.textStyle.fontSize || defaultFontSize}px`
|
|
149
150
|
};
|
|
150
151
|
},
|
|
@@ -152,6 +153,17 @@ var script = {
|
|
|
152
153
|
return this.seriesInfo.length === 1;
|
|
153
154
|
}
|
|
154
155
|
},
|
|
156
|
+
watch: {
|
|
157
|
+
/**
|
|
158
|
+
* When the canvas renderer rebuilds the chart on a colour-mode change it disposes the old
|
|
159
|
+
* ECharts instance and creates a new one. The parent emits `created` with the new instance and
|
|
160
|
+
* updates this prop, so we must rebind our persistent listener to the new instance.
|
|
161
|
+
*/
|
|
162
|
+
chart(newChart, oldChart) {
|
|
163
|
+
oldChart.off('legendselectchanged', this.suppressLastActiveSeriesLabelToggle);
|
|
164
|
+
newChart.on('legendselectchanged', this.suppressLastActiveSeriesLabelToggle);
|
|
165
|
+
}
|
|
166
|
+
},
|
|
155
167
|
created() {
|
|
156
168
|
this.chart.on('legendselectchanged', this.suppressLastActiveSeriesLabelToggle);
|
|
157
169
|
},
|