@gitlab/ui 52.4.0 → 52.6.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 +14 -0
- package/dist/components/charts/sparkline/sparkline.js +28 -1
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/package.json +3 -3
- package/src/components/charts/sparkline/sparkline.spec.js +11 -0
- package/src/components/charts/sparkline/sparkline.stories.js +13 -0
- package/src/components/charts/sparkline/sparkline.vue +29 -0
- package/src/scss/utilities.scss +50 -0
- package/src/scss/utility-mixins/border.scss +20 -0
- package/src/scss/utility-mixins/spacing.scss +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "52.
|
|
3
|
+
"version": "52.6.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -115,10 +115,10 @@
|
|
|
115
115
|
"bootstrap-vue-vue3": "npm:bootstrap-vue@2.23.1",
|
|
116
116
|
"cypress": "^11.2.0",
|
|
117
117
|
"emoji-regex": "^10.0.0",
|
|
118
|
-
"eslint": "8.
|
|
118
|
+
"eslint": "8.29.0",
|
|
119
119
|
"eslint-import-resolver-jest": "3.0.2",
|
|
120
120
|
"eslint-plugin-cypress": "2.12.1",
|
|
121
|
-
"eslint-plugin-storybook": "0.6.
|
|
121
|
+
"eslint-plugin-storybook": "0.6.8",
|
|
122
122
|
"file-loader": "^4.2.0",
|
|
123
123
|
"glob": "^7.2.0",
|
|
124
124
|
"identity-obj-proxy": "^3.0.0",
|
|
@@ -8,6 +8,9 @@ let mockChartInstance;
|
|
|
8
8
|
|
|
9
9
|
jest.mock('echarts', () => ({
|
|
10
10
|
getInstanceByDom: () => mockChartInstance,
|
|
11
|
+
graphic: {
|
|
12
|
+
LinearGradient: jest.fn(),
|
|
13
|
+
},
|
|
11
14
|
}));
|
|
12
15
|
|
|
13
16
|
let triggerResize = () => {};
|
|
@@ -176,4 +179,12 @@ describe('sparkline chart component', () => {
|
|
|
176
179
|
await wrapper.vm.$nextTick();
|
|
177
180
|
expect(getLastYValue().exists()).toBe(false);
|
|
178
181
|
});
|
|
182
|
+
|
|
183
|
+
it('gradient will set the series itemStyle color', async () => {
|
|
184
|
+
wrapper.setProps({ gradient: ['red', 'green'] });
|
|
185
|
+
|
|
186
|
+
await wrapper.vm.$nextTick();
|
|
187
|
+
|
|
188
|
+
expect(getChartOptions().series[0].itemStyle.color).toBeDefined();
|
|
189
|
+
});
|
|
179
190
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GlSparklineChart } from '../../../charts';
|
|
2
|
+
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
2
3
|
import readme from './sparkline.md';
|
|
3
4
|
|
|
4
5
|
const chartData = [
|
|
@@ -11,16 +12,24 @@ const chartData = [
|
|
|
11
12
|
['Sun', 18],
|
|
12
13
|
];
|
|
13
14
|
|
|
15
|
+
const customGradient = [
|
|
16
|
+
colorFromDefaultPalette(0),
|
|
17
|
+
colorFromDefaultPalette(1),
|
|
18
|
+
colorFromDefaultPalette(2),
|
|
19
|
+
];
|
|
20
|
+
|
|
14
21
|
const generateProps = ({
|
|
15
22
|
data = chartData,
|
|
16
23
|
height = 50,
|
|
17
24
|
tooltipLabel = 'tooltipLabel',
|
|
18
25
|
showLastYValue = true,
|
|
26
|
+
gradient,
|
|
19
27
|
} = {}) => ({
|
|
20
28
|
data,
|
|
21
29
|
height,
|
|
22
30
|
tooltipLabel,
|
|
23
31
|
showLastYValue,
|
|
32
|
+
gradient,
|
|
24
33
|
});
|
|
25
34
|
|
|
26
35
|
const Template = (args) => ({
|
|
@@ -33,6 +42,7 @@ const Template = (args) => ({
|
|
|
33
42
|
:height="height"
|
|
34
43
|
:tooltip-label="tooltipLabel"
|
|
35
44
|
:show-last-y-value="showLastYValue"
|
|
45
|
+
:gradient="gradient"
|
|
36
46
|
/>
|
|
37
47
|
</div>`,
|
|
38
48
|
});
|
|
@@ -40,6 +50,9 @@ const Template = (args) => ({
|
|
|
40
50
|
export const Default = Template.bind({});
|
|
41
51
|
Default.args = generateProps();
|
|
42
52
|
|
|
53
|
+
export const WithChartColorGradient = Template.bind({});
|
|
54
|
+
WithChartColorGradient.args = generateProps({ gradient: customGradient });
|
|
55
|
+
|
|
43
56
|
export default {
|
|
44
57
|
title: 'charts/sparkline-chart',
|
|
45
58
|
component: GlSparklineChart,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<!-- eslint-disable vue/multi-word-component-names -->
|
|
2
2
|
<script>
|
|
3
3
|
import merge from 'lodash/merge';
|
|
4
|
+
import { graphic } from 'echarts';
|
|
4
5
|
import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
|
|
5
6
|
import {
|
|
6
7
|
defaultChartOptions,
|
|
@@ -13,6 +14,19 @@ import ChartTooltip from '../tooltip/tooltip.vue';
|
|
|
13
14
|
// the padding is needed so the mark points don't overflow when visible
|
|
14
15
|
const gridPadding = symbolSize / 2;
|
|
15
16
|
|
|
17
|
+
const generateGradient = (colors) => {
|
|
18
|
+
return new graphic.LinearGradient(
|
|
19
|
+
0,
|
|
20
|
+
0,
|
|
21
|
+
0,
|
|
22
|
+
1,
|
|
23
|
+
colors.map((color, index) => {
|
|
24
|
+
const offset = index / (colors.length - 1);
|
|
25
|
+
return { offset, color };
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
16
30
|
export default {
|
|
17
31
|
components: { Chart, ChartTooltip },
|
|
18
32
|
directives: {
|
|
@@ -50,6 +64,14 @@ export default {
|
|
|
50
64
|
required: false,
|
|
51
65
|
default: true,
|
|
52
66
|
},
|
|
67
|
+
/**
|
|
68
|
+
* Sets a colour gradient for the sparkline
|
|
69
|
+
*/
|
|
70
|
+
gradient: {
|
|
71
|
+
type: Array,
|
|
72
|
+
required: false,
|
|
73
|
+
default: () => [],
|
|
74
|
+
},
|
|
53
75
|
},
|
|
54
76
|
data() {
|
|
55
77
|
return {
|
|
@@ -119,8 +141,15 @@ export default {
|
|
|
119
141
|
],
|
|
120
142
|
},
|
|
121
143
|
data,
|
|
144
|
+
itemStyle: this.itemStyle,
|
|
122
145
|
};
|
|
123
146
|
},
|
|
147
|
+
itemStyle() {
|
|
148
|
+
if (this.gradient.length) {
|
|
149
|
+
return { color: generateGradient(this.gradient) };
|
|
150
|
+
}
|
|
151
|
+
return {};
|
|
152
|
+
},
|
|
124
153
|
lastYValue() {
|
|
125
154
|
const latestEntry = this.data.slice(-1)[0];
|
|
126
155
|
|
package/src/scss/utilities.scss
CHANGED
|
@@ -1165,6 +1165,30 @@
|
|
|
1165
1165
|
border-color: $gray-500 !important;
|
|
1166
1166
|
}
|
|
1167
1167
|
|
|
1168
|
+
.gl-border-red-500 {
|
|
1169
|
+
border-color: $red-500;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
.gl-border-red-500\! {
|
|
1173
|
+
border-color: $red-500 !important;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
.gl-border-orange-500 {
|
|
1177
|
+
border-color: $orange-500;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
.gl-border-orange-500\! {
|
|
1181
|
+
border-color: $orange-500 !important;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
.gl-border-green-500 {
|
|
1185
|
+
border-color: $green-500;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
.gl-border-green-500\! {
|
|
1189
|
+
border-color: $green-500 !important;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1168
1192
|
.gl-border-blue-200 {
|
|
1169
1193
|
border-color: $blue-200;
|
|
1170
1194
|
}
|
|
@@ -1405,6 +1429,22 @@
|
|
|
1405
1429
|
border-width: $gl-border-size-1 !important;
|
|
1406
1430
|
}
|
|
1407
1431
|
|
|
1432
|
+
.gl-border-2 {
|
|
1433
|
+
border-width: $gl-border-size-2;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
.gl-border-2\! {
|
|
1437
|
+
border-width: $gl-border-size-2 !important;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
.gl-border-3 {
|
|
1441
|
+
border-width: $gl-border-size-3;
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
.gl-border-3\! {
|
|
1445
|
+
border-width: $gl-border-size-3 !important;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1408
1448
|
.gl-border-4 {
|
|
1409
1449
|
border-width: $gl-border-size-4;
|
|
1410
1450
|
}
|
|
@@ -6390,6 +6430,16 @@
|
|
|
6390
6430
|
margin-left: $gl-spacing-scale-3 !important;
|
|
6391
6431
|
}
|
|
6392
6432
|
}
|
|
6433
|
+
.gl-sm-ml-5 {
|
|
6434
|
+
@include gl-media-breakpoint-up(sm) {
|
|
6435
|
+
margin-left: $gl-spacing-scale-5;
|
|
6436
|
+
}
|
|
6437
|
+
}
|
|
6438
|
+
.gl-sm-ml-5\! {
|
|
6439
|
+
@include gl-media-breakpoint-up(sm) {
|
|
6440
|
+
margin-left: $gl-spacing-scale-5 !important;
|
|
6441
|
+
}
|
|
6442
|
+
}
|
|
6393
6443
|
.gl-sm-ml-7 {
|
|
6394
6444
|
@include gl-media-breakpoint-up(sm) {
|
|
6395
6445
|
margin-left: $gl-spacing-scale-7;
|
|
@@ -127,6 +127,18 @@
|
|
|
127
127
|
border-color: $gray-500;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
@mixin gl-border-red-500 {
|
|
131
|
+
border-color: $red-500;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@mixin gl-border-orange-500 {
|
|
135
|
+
border-color: $orange-500;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@mixin gl-border-green-500 {
|
|
139
|
+
border-color: $green-500;
|
|
140
|
+
}
|
|
141
|
+
|
|
130
142
|
@mixin gl-border-blue-200($hover: true) {
|
|
131
143
|
border-color: $blue-200;
|
|
132
144
|
}
|
|
@@ -250,6 +262,14 @@
|
|
|
250
262
|
border-width: $gl-border-size-1;
|
|
251
263
|
}
|
|
252
264
|
|
|
265
|
+
@mixin gl-border-2 {
|
|
266
|
+
border-width: $gl-border-size-2;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
@mixin gl-border-3 {
|
|
270
|
+
border-width: $gl-border-size-3;
|
|
271
|
+
}
|
|
272
|
+
|
|
253
273
|
@mixin gl-border-4 {
|
|
254
274
|
border-width: $gl-border-size-4;
|
|
255
275
|
}
|