@gitlab/ui 52.3.1 → 52.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "52.3.1",
3
+ "version": "52.5.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.28.0",
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.7",
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
 
@@ -4939,6 +4939,14 @@
4939
4939
  min-height: $gl-spacing-scale-8 !important;
4940
4940
  }
4941
4941
 
4942
+ .gl-max-w-0 {
4943
+ max-width: 0;
4944
+ }
4945
+
4946
+ .gl-max-w-0\! {
4947
+ max-width: 0 !important;
4948
+ }
4949
+
4942
4950
  .gl-max-w-15 {
4943
4951
  max-width: $gl-spacing-scale-15;
4944
4952
  }
@@ -354,6 +354,10 @@
354
354
  min-height: $gl-spacing-scale-8;
355
355
  }
356
356
 
357
+ @mixin gl-max-w-0 {
358
+ max-width: 0;
359
+ }
360
+
357
361
  @mixin gl-max-w-15 {
358
362
  max-width: $gl-spacing-scale-15;
359
363
  }