@gitlab/ui 32.44.0 → 32.47.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/config.js +15 -3
  3. package/dist/components/base/form/form_combobox/form_combobox.documentation.js +2 -9
  4. package/dist/components/base/form/form_combobox/form_combobox.js +5 -0
  5. package/dist/components/base/form/form_group/form_group.js +11 -1
  6. package/dist/components/base/form/input_group_text/input_group_text.documentation.js +1 -5
  7. package/dist/components/base/label/label.documentation.js +2 -9
  8. package/dist/components/base/label/label.js +23 -1
  9. package/dist/components/base/skeleton_loader/skeleton_loader.documentation.js +2 -28
  10. package/dist/components/base/skeleton_loader/skeleton_loader.js +30 -0
  11. package/dist/components/charts/chart/chart.js +17 -4
  12. package/dist/components/charts/discrete_scatter/discrete_scatter.documentation.js +1 -7
  13. package/dist/components/charts/heatmap/heatmap.js +1 -9
  14. package/dist/components/charts/sparkline/sparkline.js +1 -1
  15. package/dist/components/charts/stacked_column/stacked_column.documentation.js +2 -5
  16. package/dist/components/charts/tooltip/tooltip.documentation.js +1 -5
  17. package/dist/config.js +15 -3
  18. package/dist/index.css +1 -1
  19. package/dist/index.css.map +1 -1
  20. package/dist/utility_classes.css +1 -1
  21. package/dist/utility_classes.css.map +1 -1
  22. package/documentation/documented_stories.js +7 -0
  23. package/package.json +1 -1
  24. package/src/components/base/form/form_combobox/form_combobox.documentation.js +0 -8
  25. package/src/components/base/form/form_combobox/form_combobox.md +0 -2
  26. package/src/components/base/form/form_combobox/form_combobox.stories.js +30 -30
  27. package/src/components/base/form/form_combobox/form_combobox.vue +4 -0
  28. package/src/components/base/form/form_group/form_group.scss +4 -0
  29. package/src/components/base/form/form_group/form_group.spec.js +66 -64
  30. package/src/components/base/form/form_group/form_group.stories.js +36 -13
  31. package/src/components/base/form/form_group/form_group.vue +15 -2
  32. package/src/components/base/form/input_group_text/input_group_text.documentation.js +0 -3
  33. package/src/components/base/form/input_group_text/input_group_text.stories.js +24 -18
  34. package/src/components/base/label/label.documentation.js +2 -12
  35. package/src/components/base/label/label.md +2 -7
  36. package/src/components/base/label/label.stories.js +66 -92
  37. package/src/components/base/label/label.vue +22 -2
  38. package/src/components/base/skeleton_loader/skeleton_loader.documentation.js +0 -27
  39. package/src/components/base/skeleton_loader/skeleton_loader.md +0 -2
  40. package/src/components/base/skeleton_loader/skeleton_loader.stories.js +23 -9
  41. package/src/components/base/skeleton_loader/skeleton_loader.vue +24 -0
  42. package/src/components/charts/chart/chart.spec.js +33 -4
  43. package/src/components/charts/chart/chart.vue +16 -4
  44. package/src/components/charts/discrete_scatter/discrete_scatter.documentation.js +0 -5
  45. package/src/components/charts/discrete_scatter/discrete_scatter.stories.js +34 -46
  46. package/src/components/charts/heatmap/heatmap.vue +2 -9
  47. package/src/components/charts/sparkline/sparkline.vue +7 -1
  48. package/src/components/charts/stacked_column/stacked_column.documentation.js +0 -2
  49. package/src/components/charts/stacked_column/stacked_column.md +0 -2
  50. package/src/components/charts/stacked_column/stacked_column.stories.js +74 -99
  51. package/src/components/charts/tooltip/tooltip.documentation.js +0 -3
  52. package/src/components/charts/tooltip/tooltip.stories.js +59 -44
  53. package/src/scss/utilities.scss +8 -0
  54. package/src/scss/utility-mixins/transform.scss +4 -0
  55. package/dist/components/base/form/form_combobox/examples/form_combobox.basic.example.js +0 -50
  56. package/dist/components/base/form/form_combobox/examples/index.js +0 -13
  57. package/dist/components/base/form/input_group_text/examples/index.js +0 -13
  58. package/dist/components/base/form/input_group_text/examples/input_group_text.basic.example.js +0 -38
  59. package/dist/components/base/label/examples/index.js +0 -19
  60. package/dist/components/base/label/examples/label.basic.example.js +0 -38
  61. package/dist/components/base/label/examples/label.scoped.example.js +0 -38
  62. package/dist/components/base/skeleton_loader/examples/ci_header_skeleton.basic.example.js +0 -38
  63. package/dist/components/base/skeleton_loader/examples/default_skeleton.basic.example.js +0 -38
  64. package/dist/components/base/skeleton_loader/examples/default_skeleton_custom_props.basic.example.js +0 -38
  65. package/dist/components/base/skeleton_loader/examples/index.js +0 -37
  66. package/dist/components/base/skeleton_loader/examples/issue_card_skeleton.basic.example.js +0 -38
  67. package/dist/components/base/skeleton_loader/examples/job_log_skeleton.basic.example.js +0 -38
  68. package/dist/components/charts/discrete_scatter/examples/discrete_scatter.basic.example.js +0 -51
  69. package/dist/components/charts/discrete_scatter/examples/index.js +0 -13
  70. package/dist/components/charts/stacked_column/examples/index.js +0 -13
  71. package/dist/components/charts/stacked_column/examples/stacked_column.basic.example.js +0 -46
  72. package/dist/components/charts/tooltip/examples/chart_tooltip.basic.example.js +0 -54
  73. package/dist/components/charts/tooltip/examples/index.js +0 -13
  74. package/src/components/base/form/form_combobox/examples/form_combobox.basic.example.vue +0 -31
  75. package/src/components/base/form/form_combobox/examples/index.js +0 -15
  76. package/src/components/base/form/input_group_text/examples/index.js +0 -15
  77. package/src/components/base/form/input_group_text/examples/input_group_text.basic.example.vue +0 -3
  78. package/src/components/base/label/examples/index.js +0 -22
  79. package/src/components/base/label/examples/label.basic.example.vue +0 -3
  80. package/src/components/base/label/examples/label.scoped.example.vue +0 -3
  81. package/src/components/base/skeleton_loader/examples/ci_header_skeleton.basic.example.vue +0 -10
  82. package/src/components/base/skeleton_loader/examples/default_skeleton.basic.example.vue +0 -3
  83. package/src/components/base/skeleton_loader/examples/default_skeleton_custom_props.basic.example.vue +0 -9
  84. package/src/components/base/skeleton_loader/examples/index.js +0 -44
  85. package/src/components/base/skeleton_loader/examples/issue_card_skeleton.basic.example.vue +0 -26
  86. package/src/components/base/skeleton_loader/examples/job_log_skeleton.basic.example.vue +0 -13
  87. package/src/components/charts/discrete_scatter/discrete_scatter.md +0 -1
  88. package/src/components/charts/discrete_scatter/examples/discrete_scatter.basic.example.vue +0 -31
  89. package/src/components/charts/discrete_scatter/examples/index.js +0 -15
  90. package/src/components/charts/stacked_column/examples/index.js +0 -15
  91. package/src/components/charts/stacked_column/examples/stacked_column.basic.example.vue +0 -18
  92. package/src/components/charts/tooltip/examples/chart_tooltip.basic.example.vue +0 -32
  93. package/src/components/charts/tooltip/examples/index.js +0 -15
@@ -1,110 +1,84 @@
1
- import { withKnobs, text, color, select, boolean } from '@storybook/addon-knobs';
2
- import { documentedStoriesOf } from '../../../../documentation/documented_stories';
3
1
  import { GlLabel } from '../../../../index';
4
2
  import { labelSizeOptions, tooltipPlacements } from '../../../utils/constants';
5
3
  import readme from './label.md';
6
4
 
7
- const components = {
8
- GlLabel,
9
- };
5
+ const template = `
6
+ <div class="gl-display-flex">
7
+ <gl-label
8
+ :background-color="backgroundColor"
9
+ :size="size"
10
+ :title="title"
11
+ :description="description"
12
+ :tooltip-placement="tooltipPlacement"
13
+ :target="target"
14
+ :scoped="scoped"
15
+ :show-close-button="showCloseButton"
16
+ :disabled="disabled"
17
+ />
18
+ </div>`;
19
+
20
+ const Template = (args, { argTypes }) => ({
21
+ components: { GlLabel },
22
+ props: Object.keys(argTypes),
23
+ template,
24
+ });
10
25
 
11
26
  const generateProps = ({
12
27
  title = 'Label title',
13
28
  size = labelSizeOptions.default,
14
29
  tooltipPlacement = tooltipPlacements.top,
15
30
  scoped = false,
31
+ description = '',
32
+ target = '#',
33
+ backgroundColor = '#D9C2EE',
16
34
  showCloseButton = false,
17
- } = {}) => {
18
- const props = {
19
- backgroundColor: {
20
- default: color('Background color', '#D9C2EE'),
21
- },
22
- title: {
23
- default: text('Label title', title),
35
+ disabled = false,
36
+ } = {}) => ({
37
+ backgroundColor,
38
+ title,
39
+ description,
40
+ size,
41
+ tooltipPlacement,
42
+ target,
43
+ scoped,
44
+ showCloseButton,
45
+ disabled,
46
+ });
47
+
48
+ export const Default = Template.bind({});
49
+ Default.args = generateProps();
50
+
51
+ export const Scoped = Template.bind({});
52
+ Scoped.args = generateProps({ title: 'scoped::label', scoped: true });
53
+
54
+ export const WithCloseButton = Template.bind({});
55
+ WithCloseButton.args = generateProps({ showCloseButton: true });
56
+
57
+ export default {
58
+ title: 'base/label',
59
+ component: GlLabel,
60
+ parameters: {
61
+ knobs: { disable: true },
62
+ docs: {
63
+ description: {
64
+ component: readme,
65
+ },
24
66
  },
25
- description: {
26
- default: text('Label description', ''),
67
+ },
68
+ argTypes: {
69
+ backgroundColor: {
70
+ control: {
71
+ type: 'color',
72
+ },
27
73
  },
28
74
  size: {
29
- type: String,
30
- default: select('Size', labelSizeOptions, size),
75
+ options: labelSizeOptions,
31
76
  },
32
77
  tooltipPlacement: {
33
- type: String,
34
- default: select('Tooltip Placement', tooltipPlacements, tooltipPlacement),
35
- },
36
- target: {
37
- default: text('Link to label target', '#'),
38
- },
39
- scoped: {
40
- default: boolean('Label is scoped', scoped),
41
- },
42
- showCloseButton: {
43
- default: boolean('Show close button', showCloseButton),
78
+ options: tooltipPlacements,
79
+ control: {
80
+ type: 'select',
81
+ },
44
82
  },
45
- disabled: {
46
- default: boolean('Close button disabled', false),
47
- },
48
- };
49
-
50
- return props;
83
+ },
51
84
  };
52
-
53
- documentedStoriesOf('base/label', readme)
54
- .addDecorator(withKnobs)
55
- .add('default', () => ({
56
- props: generateProps(),
57
- components,
58
- template: `
59
- <div class="gl-display-flex">
60
- <gl-label
61
- :background-color="backgroundColor"
62
- :size="size"
63
- :title="title"
64
- :description="description"
65
- :tooltip-placement="tooltipPlacement"
66
- :target="target"
67
- :scoped="scoped"
68
- :show-close-button="showCloseButton"
69
- :disabled="disabled"
70
- />
71
- </div>`,
72
- }))
73
- .add('scoped', () => ({
74
- props: generateProps({ title: 'scoped::label', scoped: true }),
75
- components,
76
- template: `
77
- <div class="gl-display-flex">
78
- <gl-label
79
- :background-color="backgroundColor"
80
- :size="size"
81
- :title="title"
82
- :description="description"
83
- :tooltip-placement="tooltipPlacement"
84
- :target="target"
85
- :scoped="scoped"
86
- :show-close-button="showCloseButton"
87
- :disabled="disabled"
88
- />
89
- </div>
90
- `,
91
- }))
92
- .add('with close button', () => ({
93
- props: generateProps({ showCloseButton: true }),
94
- components,
95
- template: `
96
- <div class="gl-display-flex">
97
- <gl-label
98
- :background-color="backgroundColor"
99
- :size="size"
100
- :title="title"
101
- :description="description"
102
- :tooltip-placement="tooltipPlacement"
103
- :target="target"
104
- :scoped="scoped"
105
- :show-close-button="showCloseButton"
106
- :disabled="disabled"
107
- />
108
- </div>
109
- `,
110
- }));
@@ -96,6 +96,26 @@ export default {
96
96
  this.splitScopedLabelIndex = this.title.lastIndexOf('::');
97
97
  },
98
98
  },
99
+ methods: {
100
+ onClick(e) {
101
+ /**
102
+ * Emitted when label is clicked
103
+ *
104
+ * @event click
105
+ * @type {object}
106
+ */
107
+ this.$emit('click', e);
108
+ },
109
+ onClose(e) {
110
+ /**
111
+ * Emitted when x is clicked
112
+ *
113
+ * @event close
114
+ * @type {object}
115
+ */
116
+ this.$emit('close', e);
117
+ },
118
+ },
99
119
  };
100
120
  </script>
101
121
 
@@ -106,7 +126,7 @@ export default {
106
126
  :class="cssClasses"
107
127
  :style="cssVariables"
108
128
  v-bind="$attrs"
109
- @click="$emit('click', $event)"
129
+ @click="onClick"
110
130
  >
111
131
  <gl-link :href="target" class="gl-label-link">
112
132
  <span class="gl-label-text">
@@ -122,7 +142,7 @@ export default {
122
142
  label="Remove label"
123
143
  variant="reset"
124
144
  :disabled="disabled"
125
- @click="$emit('close', $event)"
145
+ @click="onClose"
126
146
  />
127
147
  <gl-tooltip
128
148
  v-if="description"
@@ -1,33 +1,6 @@
1
- import examples from './examples';
2
1
  import * as description from './skeleton_loader.md';
3
2
 
4
3
  export default {
5
4
  followsDesignSystem: true,
6
5
  description,
7
- examples,
8
- propsInfo: {
9
- width: {
10
- additionalInfo:
11
- 'It will be set in the viewbox attr in the <svg />. Defaults to 400 when skeleton is passed via the slot. Defaults to 235 when default skeleton is used',
12
- },
13
- height: {
14
- additionalInfo:
15
- 'It will be set in the viewbox attr in the <svg />. Defaults to 130 when skeleton is passed via the slot. Defaults to the combined height of the lines when default skeleton is used',
16
- },
17
- uniqueKey: {
18
- additionalInfo: 'Defaults to unique id',
19
- },
20
- preserveAspectRatio: {
21
- additionalInfo: 'Aspect ratio option of <svg/>',
22
- },
23
- baseUrl: {
24
- additionalInfo: `Required if you're using <base url="/" /> in your <head />. Defaults to an empty string. This prop is common used as: <gl-skeleton-loader :base-url="$route.fullPath" /> which will fill the SVG attribute with the relative path.`,
25
- },
26
- lines: {
27
- additionalInfo: 'Number of lines to show when using the default skeleton',
28
- },
29
- equalWidthLines: {
30
- additionalInfo: 'If the default skeleton lines should all be the same width',
31
- },
32
- },
33
6
  };
@@ -1,5 +1,3 @@
1
- ## Usage
2
-
3
1
  Skeleton loaders are to be used when pages or sections can be progressively populated with content,
4
2
  such as text and images, as they become available. Generally speaking the first batch of content
5
3
  will be the lightest to load and is followed by secondary and tertiary content batches. Each loading
@@ -1,14 +1,9 @@
1
- import { documentedStoriesOf } from '../../../../documentation/documented_stories';
2
1
  import { GlSkeletonLoader } from '../../../../index';
3
2
  import readme from './skeleton_loader.md';
4
3
 
5
- const components = {
6
- GlSkeletonLoader,
7
- };
8
-
9
- documentedStoriesOf('base/skeleton-loader', readme).add('default', () => ({
10
- props: {},
11
- components,
4
+ const Template = (args) => ({
5
+ components: { GlSkeletonLoader },
6
+ props: Object.keys(args),
12
7
  template: `
13
8
  <div style="background: #fff; border: 1px solid #dfdfdf; box-shadow: 0 1px 2px rgba(0,0,0,0.1); width: 359px; height: 135px; padding: 1rem; border-radius: 0.25rem;">
14
9
  <div style="width: 327px; height: 102px;">
@@ -24,4 +19,23 @@ documentedStoriesOf('base/skeleton-loader', readme).add('default', () => ({
24
19
  </gl-skeleton-loader>
25
20
  </div>
26
21
  </div>`,
27
- }));
22
+ });
23
+
24
+ export const Default = Template.bind({});
25
+ Default.args = {};
26
+
27
+ export default {
28
+ title: 'base/skeleton-loader',
29
+ component: GlSkeletonLoader,
30
+ parameters: {
31
+ knobs: { disable: true },
32
+ docs: {
33
+ description: {
34
+ component: readme,
35
+ },
36
+ },
37
+ controls: {
38
+ disable: true,
39
+ },
40
+ },
41
+ };
@@ -13,36 +13,60 @@ export default {
13
13
  name: 'GlSkeletonLoader',
14
14
  functional: true,
15
15
  props: {
16
+ /**
17
+ * It will be set in the viewbox attr in the <svg />.
18
+ * Defaults to 400 when skeleton is passed via the slot. Defaults to 235 when default skeleton is used
19
+ */
16
20
  width: {
17
21
  type: Number,
18
22
  default: null,
19
23
  required: false,
20
24
  },
25
+ /**
26
+ * It will be set in the viewbox attr in the <svg />. Defaults to 130 when skeleton is passed via the slot.
27
+ * Defaults to the combined height of the lines when default skeleton is used
28
+ */
21
29
  height: {
22
30
  type: Number,
23
31
  default: null,
24
32
  required: false,
25
33
  },
34
+ /**
35
+ * Aspect ratio option of <svg/>
36
+ */
26
37
  preserveAspectRatio: {
27
38
  type: String,
28
39
  default: 'xMidYMid meet',
29
40
  required: false,
30
41
  },
42
+ /**
43
+ * Required if you're using <base url="/" /> in your <head />. Defaults to an empty string.
44
+ * This prop is common used as: <gl-skeleton-loader :base-url="$route.fullPath" /> which will fill the SVG attribute with the relative path.
45
+ */
31
46
  baseUrl: {
32
47
  type: String,
33
48
  default: '',
34
49
  required: false,
35
50
  },
51
+ /**
52
+ * Defaults to unique id
53
+ */
36
54
  uniqueKey: {
37
55
  type: String,
38
56
  default: () => uid(),
39
57
  required: false,
40
58
  },
59
+ /**
60
+ * Number of lines to show when using the default skeleton
61
+ */
41
62
  lines: {
42
63
  type: Number,
43
64
  default: 3,
44
65
  required: false,
45
66
  },
67
+ /**
68
+ * If the default skeleton lines should all be the same width
69
+ */
46
70
  equalWidthLines: {
47
71
  type: Boolean,
48
72
  default: false,
@@ -2,6 +2,7 @@ import { shallowMount } from '@vue/test-utils';
2
2
  import * as echarts from 'echarts';
3
3
  import Chart from './chart.vue';
4
4
  import createTheme from '~/utils/charts/theme';
5
+ import { useMockResizeObserver } from '~helpers/mock_dom_observer';
5
6
 
6
7
  const defaultHeight = 400;
7
8
 
@@ -21,11 +22,12 @@ describe('chart component', () => {
21
22
  const themeName = 'gitlab';
22
23
  let wrapper;
23
24
 
24
- beforeEach(() => {
25
+ const { trigger: triggerResize } = useMockResizeObserver();
26
+
27
+ it('initializes chart using $refs.chart', async () => {
25
28
  wrapper = shallowMount(...mountArgs);
26
- });
29
+ await wrapper.vm.$nextTick();
27
30
 
28
- it('initializes chart using $refs.chart', () => {
29
31
  expect(echarts.init).toHaveBeenCalledWith(
30
32
  wrapper.findComponent({ ref: 'chart' }).element,
31
33
  themeName,
@@ -37,11 +39,34 @@ describe('chart component', () => {
37
39
  );
38
40
  });
39
41
 
40
- it('emits "created" after initializing chart', () => {
42
+ it('does not resize the chart when responsive = false', async () => {
43
+ wrapper = shallowMount(...mountArgs);
44
+ await wrapper.vm.$nextTick();
45
+ // initial call when chart gets created
46
+ expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(1);
47
+
48
+ triggerResize(wrapper.element);
49
+ expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(1);
50
+ });
51
+
52
+ it('resizes the chart when responsive = true', async () => {
53
+ wrapper = shallowMount(Chart, { propsData: { options: {}, responsive: true } });
54
+ await wrapper.vm.$nextTick();
55
+ expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(1);
56
+
57
+ triggerResize(wrapper.element);
58
+
59
+ expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(2);
60
+ });
61
+
62
+ it('emits "created" after initializing chart', async () => {
63
+ wrapper = shallowMount(...mountArgs);
64
+ await wrapper.vm.$nextTick();
41
65
  expect(wrapper.emitted('created')).toEqual([[wrapper.vm.chart]]);
42
66
  });
43
67
 
44
68
  it('uses GitLab theme', () => {
69
+ wrapper = shallowMount(...mountArgs);
45
70
  const [firstRegisterThemeCall] = echarts.registerTheme.mock.calls;
46
71
  expect(firstRegisterThemeCall[0]).toBe(themeName);
47
72
  expect(JSON.stringify(firstRegisterThemeCall[1])).toEqual(JSON.stringify(createTheme()));
@@ -87,6 +112,10 @@ describe('chart component', () => {
87
112
  });
88
113
 
89
114
  describe('methods', () => {
115
+ beforeEach(() => {
116
+ wrapper = shallowMount(...mountArgs);
117
+ });
118
+
90
119
  describe('draw method', () => {
91
120
  it('sets chart options', () => {
92
121
  wrapper.vm.draw();
@@ -2,8 +2,12 @@
2
2
  import * as echarts from 'echarts';
3
3
  import { defaultHeight, defaultWidth, validRenderers } from '../../../utils/charts/config';
4
4
  import createTheme, { themeName } from '../../../utils/charts/theme';
5
+ import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
5
6
 
6
7
  export default {
8
+ directives: {
9
+ resizeObserver: GlResizeObserverDirective,
10
+ },
7
11
  props: {
8
12
  options: {
9
13
  type: Object,
@@ -42,6 +46,11 @@ export default {
42
46
  return validRenderers.includes(renderer);
43
47
  },
44
48
  },
49
+ responsive: {
50
+ type: Boolean,
51
+ required: false,
52
+ default: false,
53
+ },
45
54
  },
46
55
  data() {
47
56
  return {
@@ -80,7 +89,7 @@ export default {
80
89
  echarts.connect(this.groupId);
81
90
  }
82
91
 
83
- this.chart.on('click', this.clickHandler);
92
+ this.chart.on('click', this.handleClick);
84
93
  /**
85
94
  * Emitted after calling `echarts.init`
86
95
  */
@@ -89,7 +98,7 @@ export default {
89
98
  this.setChartSize();
90
99
  },
91
100
  beforeDestroy() {
92
- this.chart.off('click', this.clickHandler);
101
+ this.chart.off('click', this.handleClick);
93
102
  },
94
103
  methods: {
95
104
  draw() {
@@ -105,7 +114,7 @@ export default {
105
114
  height: this.height || defaultHeight,
106
115
  });
107
116
  },
108
- clickHandler(params) {
117
+ handleClick(params) {
109
118
  /**
110
119
  * Emitted when clicked on a data item in the chart (e.g., a bar/column).
111
120
  *
@@ -114,10 +123,13 @@ export default {
114
123
  */
115
124
  this.$emit('chartItemClicked', { chart: this.chart, params });
116
125
  },
126
+ handleResize() {
127
+ if (this.responsive) this.chart.resize();
128
+ },
117
129
  },
118
130
  };
119
131
  </script>
120
132
 
121
133
  <template>
122
- <div ref="chart"></div>
134
+ <div ref="chart" v-resize-observer="handleResize"></div>
123
135
  </template>
@@ -1,8 +1,3 @@
1
- import description from './discrete_scatter.md';
2
- import examples from './examples';
3
-
4
1
  export default {
5
2
  followsDesignSystem: true,
6
- description,
7
- examples,
8
3
  };
@@ -1,13 +1,9 @@
1
- import { withKnobs, object, text } from '@storybook/addon-knobs';
2
1
  import { GlDiscreteScatterChart } from '../../../../charts';
3
- import { documentedStoriesOf } from '../../../../documentation/documented_stories';
4
- import readme from './discrete_scatter.md';
5
2
 
6
- const components = {
7
- GlDiscreteScatterChart,
8
- };
9
-
10
- const template = `
3
+ const Template = (args, { argTypes }) => ({
4
+ components: { GlDiscreteScatterChart },
5
+ props: Object.keys(argTypes),
6
+ template: `
11
7
  <gl-discrete-scatter-chart
12
8
  :data="data"
13
9
  :option="option"
@@ -15,9 +11,10 @@ const template = `
15
11
  :x-axis-title="xAxisTitle"
16
12
  data-testid="discrete-scatter-chart"
17
13
  />
18
- `;
14
+ `,
15
+ });
19
16
 
20
- function generateProps({
17
+ const generateProps = ({
21
18
  data = [
22
19
  {
23
20
  type: 'scatter',
@@ -35,41 +32,32 @@ function generateProps({
35
32
  option = {},
36
33
  yAxisTitle = 'Pushes per day',
37
34
  xAxisTitle = 'Date',
38
- } = {}) {
39
- return {
40
- data: {
41
- default: object('Chart Data', data),
42
- },
43
- option: {
44
- default: object('EChart Options', option),
45
- },
46
- yAxisTitle: {
47
- default: text('Y Axis Title', yAxisTitle),
48
- },
49
- xAxisTitle: {
50
- default: text('X Axis Title', xAxisTitle),
51
- },
52
- };
53
- }
35
+ } = {}) => ({
36
+ data,
37
+ option,
38
+ yAxisTitle,
39
+ xAxisTitle,
40
+ });
41
+
42
+ export const Default = Template.bind({});
43
+ Default.args = generateProps();
54
44
 
55
- documentedStoriesOf('charts/discrete-scatter-chart', readme)
56
- .addDecorator(withKnobs)
57
- .add('default', () => ({
58
- props: generateProps(),
59
- components,
60
- template,
61
- }))
62
- .add('with zoom and scroll', () => ({
63
- props: generateProps({
64
- option: {
65
- dataZoom: [
66
- {
67
- type: 'slider',
68
- startValue: 1,
69
- },
70
- ],
45
+ export const WithZoomAndScroll = Template.bind({});
46
+ WithZoomAndScroll.args = generateProps({
47
+ option: {
48
+ dataZoom: [
49
+ {
50
+ type: 'slider',
51
+ startValue: 1,
71
52
  },
72
- }),
73
- components,
74
- template,
75
- }));
53
+ ],
54
+ },
55
+ });
56
+
57
+ export default {
58
+ title: 'charts/discrete-scatter-chart',
59
+ component: GlDiscreteScatterChart,
60
+ parameters: {
61
+ knobs: { disable: true },
62
+ },
63
+ };
@@ -1,7 +1,6 @@
1
1
  <script>
2
2
  import merge from 'lodash/merge';
3
3
  import { white, gray100 } from '../../../../scss_to_js/scss_variables';
4
- import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
5
4
  import { getDefaultTooltipContent } from '../../../utils/charts/config';
6
5
  import { TOOLTIP_LEFT_OFFSET } from '../../../utils/charts/constants';
7
6
  import { heatmapHues } from '../../../utils/charts/theme';
@@ -49,9 +48,6 @@ export default {
49
48
  ChartTooltip,
50
49
  TooltipDefaultFormat,
51
50
  },
52
- directives: {
53
- resizeObserver: GlResizeObserverDirective,
54
- },
55
51
  mixins: [ToolboxMixin],
56
52
  props: {
57
53
  options: {
@@ -237,9 +233,6 @@ export default {
237
233
  this.chart = chart;
238
234
  this.$emit('created', chart);
239
235
  },
240
- handleResize() {
241
- return this.responsive && this.chart.resize();
242
- },
243
236
  showHideTooltip(mouseEvent) {
244
237
  this.tooltip.show = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
245
238
  },
@@ -262,8 +255,8 @@ export default {
262
255
  </script>
263
256
 
264
257
  <template>
265
- <div v-resize-observer="handleResize" class="gl-heatmap">
266
- <chart :options="computedOptions" @created="onCreated" />
258
+ <div class="gl-heatmap">
259
+ <chart v-bind="$attrs" :options="computedOptions" @created="onCreated" v-on="$listeners" />
267
260
  <chart-tooltip
268
261
  v-if="chart"
269
262
  :show="tooltip.show"
@@ -181,7 +181,13 @@ export default {
181
181
  >
182
182
  <slot name="default"></slot>
183
183
  <div class="gl-flex-grow-1 gl-relative">
184
- <chart :height="height" :options="options" @created="onChartCreated" />
184
+ <chart
185
+ v-bind="$attrs"
186
+ :height="height"
187
+ :options="options"
188
+ @created="onChartCreated"
189
+ v-on="$listeners"
190
+ />
185
191
  <chart-tooltip
186
192
  v-if="chartInstance"
187
193
  :show="tooltip.show"
@@ -1,8 +1,6 @@
1
- import examples from './examples';
2
1
  import description from './stacked_column.md';
3
2
 
4
3
  export default {
5
4
  followsDesignSystem: false,
6
5
  description,
7
- examples,
8
6
  };
@@ -1,5 +1,3 @@
1
- # Stacked Column Chart
2
-
3
1
  The `presentation` property allows you to change between a stacked and tiled presentation style. It
4
2
  is only setup to accept `stacked` or `tiled` as values, the default value is `tiled`.
5
3