@gitlab/ui 52.3.0 → 52.3.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/CHANGELOG.md +8 -0
- package/dist/components/charts/chart/chart.js +18 -2
- package/dist/utils/charts/config.js +2 -1
- package/dist/utils/charts/theme.js +6 -1
- package/package.json +9 -9
- package/src/components/charts/chart/chart.spec.js +17 -0
- package/src/components/charts/chart/chart.vue +24 -2
- package/src/utils/charts/config.js +1 -0
- package/src/utils/charts/theme.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [52.3.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v52.3.0...v52.3.1) (2022-12-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **charts:** add background color to toolbox title ([517b70c](https://gitlab.com/gitlab-org/gitlab-ui/commit/517b70ca9afcbe90adb1bd92f55c16b489093e6a))
|
|
7
|
+
* **charts:** add space between toolbox and chart ([94c1ea8](https://gitlab.com/gitlab-org/gitlab-ui/commit/94c1ea80509165bf1f2b9630740059d791d613e4))
|
|
8
|
+
|
|
1
9
|
# [52.3.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v52.2.1...v52.3.0) (2022-12-08)
|
|
2
10
|
|
|
3
11
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as echarts from 'echarts';
|
|
2
|
-
import { validRenderers, defaultWidth, defaultHeight } from '../../../utils/charts/config';
|
|
2
|
+
import { validRenderers, defaultWidth, defaultHeight, toolboxHeight } from '../../../utils/charts/config';
|
|
3
3
|
import { themeName, createTheme } from '../../../utils/charts/theme';
|
|
4
4
|
import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
|
|
5
5
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
@@ -11,6 +11,17 @@ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
|
11
11
|
* https://echarts.apache.org/en/api.html#echartsInstance.resize
|
|
12
12
|
*/
|
|
13
13
|
const sizeValidator = size => Number.isFinite(size) || size === 'auto' || size == null;
|
|
14
|
+
const isChartWithToolbox = options => (options === null || options === void 0 ? void 0 : options.toolbox) !== undefined;
|
|
15
|
+
const increaseChartGridTop = (options, increaseBy) => {
|
|
16
|
+
var _options$grid;
|
|
17
|
+
return {
|
|
18
|
+
...options,
|
|
19
|
+
grid: {
|
|
20
|
+
...options.grid,
|
|
21
|
+
top: ((options === null || options === void 0 ? void 0 : (_options$grid = options.grid) === null || _options$grid === void 0 ? void 0 : _options$grid.top) || 0) + increaseBy
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
14
25
|
var script = {
|
|
15
26
|
directives: {
|
|
16
27
|
resizeObserver: GlResizeObserverDirective
|
|
@@ -78,6 +89,11 @@ var script = {
|
|
|
78
89
|
chart: null
|
|
79
90
|
};
|
|
80
91
|
},
|
|
92
|
+
computed: {
|
|
93
|
+
normalizedOptions() {
|
|
94
|
+
return isChartWithToolbox(this.options) ? increaseChartGridTop(this.options, toolboxHeight) : this.options;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
81
97
|
watch: {
|
|
82
98
|
options() {
|
|
83
99
|
if (this.chart) {
|
|
@@ -120,7 +136,7 @@ var script = {
|
|
|
120
136
|
},
|
|
121
137
|
methods: {
|
|
122
138
|
draw() {
|
|
123
|
-
this.chart.setOption(this.
|
|
139
|
+
this.chart.setOption(this.normalizedOptions);
|
|
124
140
|
/**
|
|
125
141
|
* Emitted after calling `echarts.setOption`
|
|
126
142
|
*/
|
|
@@ -15,6 +15,7 @@ const defaultFontSize = 12;
|
|
|
15
15
|
const defaultHeight = 400;
|
|
16
16
|
const defaultWidth = 300;
|
|
17
17
|
const validRenderers = ['canvas', 'svg'];
|
|
18
|
+
const toolboxHeight = 14;
|
|
18
19
|
const axes = {
|
|
19
20
|
name: 'Value',
|
|
20
21
|
type: 'value',
|
|
@@ -504,4 +505,4 @@ const getDefaultTooltipContent = function (params) {
|
|
|
504
505
|
};
|
|
505
506
|
};
|
|
506
507
|
|
|
507
|
-
export { annotationsYAxisCoords, axes, dataZoomAdjustments, defaultAreaOpacity, defaultChartOptions, defaultFontSize, defaultHeight, defaultWidth, generateAnnotationSeries, generateBarSeries, generateLineSeries, getAnnotationsConfig, getDataZoomConfig, getDefaultTooltipContent, getThresholdConfig, grid, gridWithSecondaryYAxis, lineStyle, mergeAnnotationAxisToOptions, mergeSeriesToOptions, parseAnnotations, symbolSize, validRenderers, xAxis, yAxis };
|
|
508
|
+
export { annotationsYAxisCoords, axes, dataZoomAdjustments, defaultAreaOpacity, defaultChartOptions, defaultFontSize, defaultHeight, defaultWidth, generateAnnotationSeries, generateBarSeries, generateLineSeries, getAnnotationsConfig, getDataZoomConfig, getDefaultTooltipContent, getThresholdConfig, grid, gridWithSecondaryYAxis, lineStyle, mergeAnnotationAxisToOptions, mergeSeriesToOptions, parseAnnotations, symbolSize, toolboxHeight, validRenderers, xAxis, yAxis };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { scrollHandleSvgPath } from '../svgs/svg_paths';
|
|
2
2
|
import { hexToRgba } from '../utils';
|
|
3
3
|
|
|
4
|
+
const white = '#fff';
|
|
4
5
|
const whiteNormal = '#f0f0f0';
|
|
5
6
|
const red500 = '#dd2b0e';
|
|
6
7
|
const gray50 = '#ececef';
|
|
@@ -42,6 +43,7 @@ const dataVizOrange700 = '#92430a';
|
|
|
42
43
|
const dataVizOrange800 = '#6f3500';
|
|
43
44
|
const dataVizOrange900 = '#5e2f05';
|
|
44
45
|
const dataVizOrange950 = '#4b2707';
|
|
46
|
+
const glBorderRadiusBase = '0.25rem';
|
|
45
47
|
|
|
46
48
|
const themeName = 'gitlab';
|
|
47
49
|
const heatmapHues = [gray100, dataVizBlue200, dataVizBlue400, dataVizBlue600, dataVizBlue800];
|
|
@@ -163,7 +165,10 @@ const createTheme = function () {
|
|
|
163
165
|
emphasis: {
|
|
164
166
|
iconStyle: {
|
|
165
167
|
borderWidth: 0,
|
|
166
|
-
color: gray900
|
|
168
|
+
color: gray900,
|
|
169
|
+
textBackgroundColor: white,
|
|
170
|
+
textBorderRadius: glBorderRadiusBase,
|
|
171
|
+
textPadding: [8, 12]
|
|
167
172
|
}
|
|
168
173
|
},
|
|
169
174
|
iconStyle: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "52.3.
|
|
3
|
+
"version": "52.3.1",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -91,14 +91,14 @@
|
|
|
91
91
|
"@rollup/plugin-commonjs": "^11.1.0",
|
|
92
92
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
93
93
|
"@rollup/plugin-replace": "^2.3.2",
|
|
94
|
-
"@storybook/addon-a11y": "6.5.
|
|
95
|
-
"@storybook/addon-docs": "6.5.
|
|
96
|
-
"@storybook/addon-essentials": "6.5.
|
|
97
|
-
"@storybook/addon-storyshots": "6.5.
|
|
98
|
-
"@storybook/addon-storyshots-puppeteer": "6.5.
|
|
99
|
-
"@storybook/addon-viewport": "6.5.
|
|
100
|
-
"@storybook/theming": "6.5.
|
|
101
|
-
"@storybook/vue": "6.5.
|
|
94
|
+
"@storybook/addon-a11y": "6.5.14",
|
|
95
|
+
"@storybook/addon-docs": "6.5.14",
|
|
96
|
+
"@storybook/addon-essentials": "6.5.14",
|
|
97
|
+
"@storybook/addon-storyshots": "6.5.14",
|
|
98
|
+
"@storybook/addon-storyshots-puppeteer": "6.5.14",
|
|
99
|
+
"@storybook/addon-viewport": "6.5.14",
|
|
100
|
+
"@storybook/theming": "6.5.14",
|
|
101
|
+
"@storybook/vue": "6.5.14",
|
|
102
102
|
"@vue/compat": "^3.2.40",
|
|
103
103
|
"@vue/compiler-sfc": "^3.2.40",
|
|
104
104
|
"@vue/test-utils": "1.3.0",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
2
|
import * as echarts from 'echarts';
|
|
3
|
+
import { toolboxHeight } from '~/utils/charts/config';
|
|
3
4
|
import { createTheme } from '~/utils/charts/theme';
|
|
4
5
|
import { useMockResizeObserver } from '~helpers/mock_dom_observer';
|
|
5
6
|
import Chart from './chart.vue';
|
|
@@ -118,8 +119,11 @@ describe('chart component', () => {
|
|
|
118
119
|
|
|
119
120
|
describe('draw method', () => {
|
|
120
121
|
it('sets chart options', () => {
|
|
122
|
+
expect(wrapper.vm.chart.setOption).toHaveBeenCalledTimes(1);
|
|
123
|
+
|
|
121
124
|
wrapper.vm.draw();
|
|
122
125
|
|
|
126
|
+
expect(wrapper.vm.chart.setOption).toHaveBeenCalledTimes(2);
|
|
123
127
|
expect(wrapper.vm.chart.setOption).toHaveBeenCalledWith(options);
|
|
124
128
|
});
|
|
125
129
|
|
|
@@ -142,4 +146,17 @@ describe('chart component', () => {
|
|
|
142
146
|
});
|
|
143
147
|
});
|
|
144
148
|
});
|
|
149
|
+
|
|
150
|
+
describe('with toolbox in options', () => {
|
|
151
|
+
it('increases grid top by `toolboxHeight`', async () => {
|
|
152
|
+
const optionsWithToolbox = { toolbox: {} };
|
|
153
|
+
wrapper = shallowMount(Chart, { propsData: { options: optionsWithToolbox } });
|
|
154
|
+
await wrapper.vm.$nextTick();
|
|
155
|
+
|
|
156
|
+
expect(wrapper.vm.chart.setOption).toHaveBeenCalledWith({
|
|
157
|
+
...optionsWithToolbox,
|
|
158
|
+
grid: { top: toolboxHeight },
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
});
|
|
145
162
|
});
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
<!-- eslint-disable vue/multi-word-component-names -->
|
|
2
2
|
<script>
|
|
3
3
|
import * as echarts from 'echarts';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
defaultHeight,
|
|
6
|
+
defaultWidth,
|
|
7
|
+
validRenderers,
|
|
8
|
+
toolboxHeight,
|
|
9
|
+
} from '../../../utils/charts/config';
|
|
5
10
|
import { createTheme, themeName } from '../../../utils/charts/theme';
|
|
6
11
|
import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
|
|
7
12
|
|
|
@@ -11,6 +16,16 @@ import { GlResizeObserverDirective } from '../../../directives/resize_observer/r
|
|
|
11
16
|
*/
|
|
12
17
|
const sizeValidator = (size) => Number.isFinite(size) || size === 'auto' || size == null;
|
|
13
18
|
|
|
19
|
+
const isChartWithToolbox = (options) => options?.toolbox !== undefined;
|
|
20
|
+
|
|
21
|
+
const increaseChartGridTop = (options, increaseBy) => ({
|
|
22
|
+
...options,
|
|
23
|
+
grid: {
|
|
24
|
+
...options.grid,
|
|
25
|
+
top: (options?.grid?.top || 0) + increaseBy,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
14
29
|
export default {
|
|
15
30
|
directives: {
|
|
16
31
|
resizeObserver: GlResizeObserverDirective,
|
|
@@ -78,6 +93,13 @@ export default {
|
|
|
78
93
|
chart: null,
|
|
79
94
|
};
|
|
80
95
|
},
|
|
96
|
+
computed: {
|
|
97
|
+
normalizedOptions() {
|
|
98
|
+
return isChartWithToolbox(this.options)
|
|
99
|
+
? increaseChartGridTop(this.options, toolboxHeight)
|
|
100
|
+
: this.options;
|
|
101
|
+
},
|
|
102
|
+
},
|
|
81
103
|
watch: {
|
|
82
104
|
options() {
|
|
83
105
|
if (this.chart) {
|
|
@@ -123,7 +145,7 @@ export default {
|
|
|
123
145
|
},
|
|
124
146
|
methods: {
|
|
125
147
|
draw() {
|
|
126
|
-
this.chart.setOption(this.
|
|
148
|
+
this.chart.setOption(this.normalizedOptions);
|
|
127
149
|
/**
|
|
128
150
|
* Emitted after calling `echarts.setOption`
|
|
129
151
|
*/
|
|
@@ -40,6 +40,8 @@ import {
|
|
|
40
40
|
dataVizOrange800,
|
|
41
41
|
dataVizOrange950,
|
|
42
42
|
dataVizOrange900,
|
|
43
|
+
glBorderRadiusBase,
|
|
44
|
+
white,
|
|
43
45
|
} from '../../../scss_to_js/scss_variables';
|
|
44
46
|
import { scrollHandleSvgPath } from '../svgs/svg_paths';
|
|
45
47
|
import { hexToRgba } from '../utils';
|
|
@@ -209,6 +211,9 @@ export const createTheme = (options = {}) => ({
|
|
|
209
211
|
iconStyle: {
|
|
210
212
|
borderWidth: 0,
|
|
211
213
|
color: gray900,
|
|
214
|
+
textBackgroundColor: white,
|
|
215
|
+
textBorderRadius: glBorderRadiusBase,
|
|
216
|
+
textPadding: [8, 12],
|
|
212
217
|
},
|
|
213
218
|
},
|
|
214
219
|
iconStyle: {
|