@gitlab/ui 36.7.0 → 37.1.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 (103) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/components/base/alert/alert.js +1 -11
  3. package/dist/components/base/card/card.js +1 -1
  4. package/dist/components/base/drawer/drawer.documentation.js +1 -1
  5. package/dist/components/base/pagination/pagination.js +1 -0
  6. package/dist/components/base/path/data.js +2 -1
  7. package/dist/components/base/path/path.js +5 -4
  8. package/dist/components/base/tabs/tab/tab.js +4 -0
  9. package/dist/components/base/tabs/tabs/tabs.documentation.js +2 -14
  10. package/dist/components/base/tabs/tabs/tabs.js +8 -0
  11. package/dist/components/charts/area/area.documentation.js +1 -7
  12. package/dist/components/charts/legend/legend.js +12 -0
  13. package/dist/components/charts/line/line.documentation.js +2 -5
  14. package/dist/index.css +2 -2
  15. package/dist/index.css.map +1 -1
  16. package/dist/utils/stories_utils.js +13 -1
  17. package/documentation/components_documentation.js +0 -2
  18. package/documentation/documented_stories.js +5 -0
  19. package/package.json +3 -3
  20. package/src/components/base/accordion/accordion.stories.js +2 -1
  21. package/src/components/base/alert/alert.scss +0 -38
  22. package/src/components/base/alert/alert.spec.js +0 -1
  23. package/src/components/base/alert/alert.stories.js +0 -8
  24. package/src/components/base/alert/alert.vue +30 -41
  25. package/src/components/base/badge/badge.stories.js +4 -24
  26. package/src/components/base/card/card.vue +2 -2
  27. package/src/components/base/daterange_picker/daterange_picker.stories.js +10 -35
  28. package/src/components/base/drawer/drawer.documentation.js +1 -1
  29. package/src/components/base/icon/icon.stories.js +2 -5
  30. package/src/components/base/pagination/pagination.spec.js +3 -0
  31. package/src/components/base/pagination/pagination.vue +1 -0
  32. package/src/components/base/path/__snapshots__/path.spec.js.snap +6 -0
  33. package/src/components/base/path/data.js +1 -0
  34. package/src/components/base/path/path.scss +6 -1
  35. package/src/components/base/path/path.spec.js +8 -0
  36. package/src/components/base/path/path.vue +10 -4
  37. package/src/components/base/tabs/tab/tab.vue +4 -0
  38. package/src/components/base/tabs/tabs/tabs.documentation.js +0 -12
  39. package/src/components/base/tabs/tabs/tabs.md +2 -7
  40. package/src/components/base/tabs/tabs/tabs.stories.js +221 -161
  41. package/src/components/base/tabs/tabs/tabs.vue +6 -0
  42. package/src/components/base/toggle/toggle.stories.js +2 -3
  43. package/src/components/charts/area/area.documentation.js +0 -5
  44. package/src/components/charts/area/area.stories.js +127 -127
  45. package/src/components/charts/bar/bar.stories.js +8 -5
  46. package/src/components/charts/heatmap/heatmap.stories.js +13 -16
  47. package/src/components/charts/legend/legend.stories.js +22 -15
  48. package/src/components/charts/legend/legend.vue +9 -0
  49. package/src/components/charts/line/line.documentation.js +0 -2
  50. package/src/components/charts/line/line.md +0 -2
  51. package/src/components/charts/line/line.stories.js +124 -113
  52. package/src/utils/stories_utils.js +6 -0
  53. package/src/utils/stories_utils.spec.js +18 -0
  54. package/dist/components/base/tabs/tab/examples/index.js +0 -13
  55. package/dist/components/base/tabs/tab/examples/tab.basic.example.js +0 -38
  56. package/dist/components/base/tabs/tab/tab.documentation.js +0 -18
  57. package/dist/components/base/tabs/tabs/examples/index.js +0 -60
  58. package/dist/components/base/tabs/tabs/examples/tabs.basic.example.js +0 -38
  59. package/dist/components/base/tabs/tabs/examples/tabs.contentless_tab.example.js +0 -38
  60. package/dist/components/base/tabs/tabs/examples/tabs.counterbadges.example.js +0 -38
  61. package/dist/components/base/tabs/tabs/examples/tabs.custom_title.example.js +0 -38
  62. package/dist/components/base/tabs/tabs/examples/tabs.disabled.example.js +0 -38
  63. package/dist/components/base/tabs/tabs/examples/tabs.justified.example.js +0 -38
  64. package/dist/components/base/tabs/tabs/examples/tabs.no_tabs.example.js +0 -38
  65. package/dist/components/base/tabs/tabs/examples/tabs.scrollable.example.js +0 -47
  66. package/dist/components/base/tabs/tabs/examples/tabs.styles_only.example.js +0 -38
  67. package/dist/components/charts/area/examples/area.basic.example.js +0 -45
  68. package/dist/components/charts/area/examples/area.basic_plus.example.js +0 -53
  69. package/dist/components/charts/area/examples/index.js +0 -19
  70. package/dist/components/charts/legend/examples/index.js +0 -22
  71. package/dist/components/charts/legend/examples/legend.basic.example.js +0 -93
  72. package/dist/components/charts/legend/examples/legend.toggled.example.js +0 -100
  73. package/dist/components/charts/legend/legend.documentation.js +0 -21
  74. package/dist/components/charts/line/examples/index.js +0 -19
  75. package/dist/components/charts/line/examples/line.basic.example.js +0 -45
  76. package/dist/components/charts/line/examples/line.series.example.js +0 -53
  77. package/src/components/base/tabs/tab/examples/index.js +0 -15
  78. package/src/components/base/tabs/tab/examples/tab.basic.example.vue +0 -5
  79. package/src/components/base/tabs/tab/tab.documentation.js +0 -16
  80. package/src/components/base/tabs/tab/tab.md +0 -3
  81. package/src/components/base/tabs/tab/tab.stories.js +0 -12
  82. package/src/components/base/tabs/tabs/examples/index.js +0 -72
  83. package/src/components/base/tabs/tabs/examples/tabs.basic.example.vue +0 -6
  84. package/src/components/base/tabs/tabs/examples/tabs.contentless_tab.example.vue +0 -17
  85. package/src/components/base/tabs/tabs/examples/tabs.counterbadges.example.vue +0 -28
  86. package/src/components/base/tabs/tabs/examples/tabs.custom_title.example.vue +0 -9
  87. package/src/components/base/tabs/tabs/examples/tabs.disabled.example.vue +0 -7
  88. package/src/components/base/tabs/tabs/examples/tabs.justified.example.vue +0 -6
  89. package/src/components/base/tabs/tabs/examples/tabs.no_tabs.example.vue +0 -8
  90. package/src/components/base/tabs/tabs/examples/tabs.scrollable.example.vue +0 -20
  91. package/src/components/base/tabs/tabs/examples/tabs.styles_only.example.vue +0 -22
  92. package/src/components/charts/area/area.md +0 -1
  93. package/src/components/charts/area/examples/area.basic.example.vue +0 -14
  94. package/src/components/charts/area/examples/area.basic_plus.example.vue +0 -25
  95. package/src/components/charts/area/examples/index.js +0 -22
  96. package/src/components/charts/legend/examples/index.js +0 -27
  97. package/src/components/charts/legend/examples/legend.basic.example.vue +0 -55
  98. package/src/components/charts/legend/examples/legend.toggled.example.vue +0 -60
  99. package/src/components/charts/legend/legend.documentation.js +0 -19
  100. package/src/components/charts/legend/legend.md +0 -0
  101. package/src/components/charts/line/examples/index.js +0 -22
  102. package/src/components/charts/line/examples/line.basic.example.vue +0 -14
  103. package/src/components/charts/line/examples/line.series.example.vue +0 -25
@@ -1,16 +1,11 @@
1
- import { withKnobs, object, array, boolean } from '@storybook/addon-knobs';
2
1
  import { times } from 'lodash';
3
2
  import { GlAreaChart } from '../../../charts';
4
- import { documentedStoriesOf } from '../../../../documentation/documented_stories';
5
3
  import { mockAnnotationsSeries, mockAnnotationsConfigs } from '../../../utils/charts/mock_data';
6
4
  import { toolbox } from '../../../utils/charts/story_config';
7
5
  import { timeSeriesDateFormatter } from '../../../utils/charts/utils';
8
6
  import { generateTimeSeries } from '../../../utils/data_utils';
9
- import readme from './area.md';
7
+ import { disableControls } from '../../../utils/stories_utils';
10
8
 
11
- const components = {
12
- GlAreaChart,
13
- };
14
9
  const defaultData = [
15
10
  {
16
11
  name: 'First Series',
@@ -32,6 +27,7 @@ const defaultOptions = {
32
27
  type: 'category',
33
28
  },
34
29
  };
30
+
35
31
  const template = `<gl-area-chart
36
32
  :data="data"
37
33
  :option="option"
@@ -40,136 +36,140 @@ const template = `<gl-area-chart
40
36
  :includeLegendAvgMax="includeLegendAvgMax"
41
37
  />`;
42
38
 
43
- function generateProps({
39
+ const generateProps = ({
44
40
  data = defaultData,
45
41
  option = defaultOptions,
46
42
  thresholds = [],
47
43
  annotations = [],
48
44
  includeLegendAvgMax = true,
49
- } = {}) {
50
- return {
51
- option: {
52
- default: object('EChart Options', option),
53
- },
54
- thresholds: {
55
- default: array('Thresholds', thresholds),
45
+ } = {}) => ({
46
+ data,
47
+ option,
48
+ thresholds,
49
+ annotations,
50
+ includeLegendAvgMax,
51
+ });
52
+
53
+ const Template = (args, { argTypes }) => ({
54
+ components: {
55
+ GlAreaChart,
56
+ },
57
+ props: Object.keys(argTypes),
58
+ template,
59
+ });
60
+
61
+ export const Default = Template.bind({});
62
+ Default.args = generateProps();
63
+
64
+ export const WithThreshold = Template.bind({});
65
+ WithThreshold.args = generateProps({
66
+ thresholds: [{ threshold: 1200, operator: '>' }],
67
+ });
68
+
69
+ export const WithAnnotationsAsProps = Template.bind({});
70
+ WithAnnotationsAsProps.storyName = 'With annotations as props (recommended)';
71
+ WithAnnotationsAsProps.args = generateProps({
72
+ ...mockAnnotationsConfigs,
73
+ data: [
74
+ {
75
+ name: 'Time Series',
76
+ data: generateTimeSeries(),
56
77
  },
57
- annotations: {
58
- default: object('Annotations', annotations),
78
+ ],
79
+ option: {
80
+ xAxis: {
81
+ type: 'time',
82
+ name: 'Time',
83
+ axisLabel: {
84
+ formatter: timeSeriesDateFormatter,
85
+ },
59
86
  },
60
- data: {
61
- default: object('Chart Data', data),
87
+ },
88
+ });
89
+
90
+ export const WithAnnotationsAsOptionSeries = Template.bind({});
91
+ WithAnnotationsAsOptionSeries.args = generateProps({
92
+ data: [
93
+ {
94
+ name: 'Time Series',
95
+ data: generateTimeSeries(),
62
96
  },
63
- includeLegendAvgMax: {
64
- default: boolean('Include Legend Avg Max', includeLegendAvgMax),
97
+ ],
98
+ option: {
99
+ ...mockAnnotationsSeries,
100
+ xAxis: {
101
+ type: 'time',
102
+ name: 'Time',
103
+ axisLabel: {
104
+ formatter: timeSeriesDateFormatter,
105
+ },
65
106
  },
66
- };
67
- }
107
+ },
108
+ });
68
109
 
69
- documentedStoriesOf('charts/area-chart', readme)
70
- .addDecorator(withKnobs)
71
- .add('default', () => ({
72
- props: generateProps(),
73
- components,
74
- template,
75
- }))
76
- .add('with threshold', () => ({
77
- props: generateProps({
78
- thresholds: [{ threshold: 1200, operator: '>' }],
79
- }),
80
- components,
81
- template,
82
- }))
83
- .add('with annotations as props (recommended)', () => ({
84
- props: generateProps({
85
- ...mockAnnotationsConfigs,
86
- data: [
87
- {
88
- name: 'Time Series',
89
- data: generateTimeSeries(),
90
- },
91
- ],
92
- option: {
93
- xAxis: {
94
- type: 'time',
95
- name: 'Time',
96
- axisLabel: {
97
- formatter: timeSeriesDateFormatter,
98
- },
99
- },
100
- },
101
- }),
102
- components,
103
- template,
104
- }))
105
- .add('with annotations as option series', () => ({
106
- props: generateProps({
107
- data: [
108
- {
109
- name: 'Time Series',
110
- data: generateTimeSeries(),
111
- },
112
- ],
113
- option: {
114
- ...mockAnnotationsSeries,
115
- xAxis: {
116
- type: 'time',
117
- name: 'Time',
118
- axisLabel: {
119
- formatter: timeSeriesDateFormatter,
120
- },
121
- },
122
- },
123
- }),
124
- components,
125
- template,
126
- }))
127
- .add('with zoom and scroll', () => ({
128
- props: generateProps({
129
- data: [
130
- {
131
- name: 'Time Series',
132
- data: generateTimeSeries(),
133
- },
134
- ],
135
- option: {
136
- xAxis: {
137
- type: 'time',
138
- name: 'Time',
139
- axisLabel: {
140
- formatter: timeSeriesDateFormatter,
141
- },
142
- },
143
- dataZoom: [
144
- {
145
- startValue: '2018-03-01T00:00:00.000',
146
- },
147
- ],
110
+ export const WithZoomAndScroll = Template.bind({});
111
+ WithZoomAndScroll.args = generateProps({
112
+ data: [
113
+ {
114
+ name: 'Time Series',
115
+ data: generateTimeSeries(),
116
+ },
117
+ ],
118
+ option: {
119
+ xAxis: {
120
+ type: 'time',
121
+ name: 'Time',
122
+ axisLabel: {
123
+ formatter: timeSeriesDateFormatter,
148
124
  },
149
- }),
150
- components,
151
- template,
152
- }))
153
- .add('with toolbox', () => ({
154
- props: generateProps({
155
- option: {
156
- xAxis: {
157
- name: 'Time',
158
- type: 'category',
159
- },
160
- toolbox,
125
+ },
126
+ dataZoom: [
127
+ {
128
+ startValue: '2018-03-01T00:00:00.000',
161
129
  },
162
- }),
163
- components,
164
- template,
165
- }))
166
- .add('mult-series', () => ({
167
- props: generateProps({
168
- data: times(10, (index) => ({
169
- name: index,
170
- data: defaultData[0].data.map(([label, value]) => [label, value * index]),
171
- })),
172
- }),
173
- components,
174
- template,
175
- }));
130
+ ],
131
+ },
132
+ });
133
+
134
+ export const WithToolbox = Template.bind({});
135
+ WithToolbox.args = generateProps({
136
+ option: {
137
+ xAxis: {
138
+ name: 'Time',
139
+ type: 'category',
140
+ },
141
+ toolbox,
142
+ },
143
+ });
144
+
145
+ export const MultSeries = Template.bind({});
146
+ MultSeries.args = generateProps({
147
+ data: times(10, (index) => ({
148
+ name: index,
149
+ data: defaultData[0].data.map(([label, value]) => [label, value * index]),
150
+ })),
151
+ });
152
+
153
+ export default {
154
+ title: 'charts/area-chart',
155
+ component: GlAreaChart,
156
+ parameters: {
157
+ knobs: { disable: true },
158
+ },
159
+ argTypes: {
160
+ ...disableControls([
161
+ 'showToolbox',
162
+ 'toolboxZoomIconPath',
163
+ 'toolboxBackIconPath',
164
+ 'toolboxRestoreIconPath',
165
+ 'toolboxSaveAsImageIconPath',
166
+ 'dataSeries',
167
+ 'formatTooltipText',
168
+ 'legendAverageText',
169
+ 'legendMaxText',
170
+ 'legendMinText',
171
+ 'legendCurrentText',
172
+ 'legendLayout',
173
+ ]),
174
+ },
175
+ };
@@ -1,4 +1,5 @@
1
1
  import { GlBarChart } from '../../../charts';
2
+ import { disableControls } from '../../../utils/stories_utils';
2
3
  import readme from './bar.md';
3
4
 
4
5
  const Template = (args, { argTypes }) => ({
@@ -49,11 +50,13 @@ export default {
49
50
  title: 'charts/bar-chart',
50
51
  component: GlBarChart,
51
52
  argTypes: {
52
- showToolbox: { control: { disable: true } },
53
- toolboxZoomIconPath: { control: { disable: true } },
54
- toolboxBackIconPath: { control: { disable: true } },
55
- toolboxRestoreIconPath: { control: { disable: true } },
56
- toolboxSaveAsImageIconPath: { control: { disable: true } },
53
+ ...disableControls([
54
+ 'showToolbox',
55
+ 'toolboxZoomIconPath',
56
+ 'toolboxBackIconPath',
57
+ 'toolboxRestoreIconPath',
58
+ 'toolboxSaveAsImageIconPath',
59
+ ]),
57
60
  },
58
61
  parameters: {
59
62
  knobs: { disable: true },
@@ -1,6 +1,6 @@
1
1
  import { GlHeatmap } from '../../../charts';
2
2
  import { toolbox } from '../../../utils/charts/story_config';
3
- import readme from '../area/area.md';
3
+ import { disableControls } from '../../../utils/stories_utils';
4
4
 
5
5
  function generateData() {
6
6
  let data = [
@@ -62,22 +62,19 @@ export default {
62
62
  component: GlHeatmap,
63
63
  parameters: {
64
64
  knobs: { disable: true },
65
- docs: {
66
- description: {
67
- component: readme,
68
- },
69
- },
70
65
  },
71
66
  argTypes: {
72
- showToolbox: { control: { disable: true } },
73
- toolboxZoomIconPath: { control: { disable: true } },
74
- toolboxBackIconPath: { control: { disable: true } },
75
- toolboxRestoreIconPath: { control: { disable: true } },
76
- toolboxSaveAsImageIconPath: { control: { disable: true } },
77
- dataSeries: { control: { disable: true } },
78
- formatTooltipText: { control: { disable: true } },
79
- legendAverageText: { control: { disable: true } },
80
- legendMaxText: { control: { disable: true } },
81
- responsive: { control: { disable: true } },
67
+ ...disableControls([
68
+ 'showToolbox',
69
+ 'toolboxZoomIconPath',
70
+ 'toolboxBackIconPath',
71
+ 'toolboxRestoreIconPath',
72
+ 'toolboxSaveAsImageIconPath',
73
+ 'dataSeries',
74
+ 'formatTooltipText',
75
+ 'legendAverageText',
76
+ 'legendMaxText',
77
+ 'responsive',
78
+ ]),
82
79
  },
83
80
  };
@@ -1,5 +1,4 @@
1
1
  import { GlChart, GlChartLegend } from '../../../charts';
2
- import { documentedStoriesOf } from '../../../../documentation/documented_stories';
3
2
  import { LEGEND_LAYOUT_TABLE } from '../../../utils/charts/constants';
4
3
  import { generateSeriesData } from '../../../utils/charts/story_config';
5
4
  import {
@@ -7,7 +6,6 @@ import {
7
6
  SERIES_NAME_LONG,
8
7
  SERIES_NAME_LONG_WITHOUT_SPACES,
9
8
  } from '../../../utils/stories_utils';
10
- import readme from './legend.md';
11
9
 
12
10
  const generateOptions = (seriesLength, seriesNameType) => {
13
11
  return {
@@ -89,16 +87,25 @@ const getStoryOptions = (seriesLength, seriesNameType, legendLayoutType) => {
89
87
  };
90
88
  };
91
89
 
92
- documentedStoriesOf('charts/chart-legend', readme)
93
- .add('default', () => getStoryOptions(10, SERIES_NAME_SHORT))
94
- .add('default with long series names', () => getStoryOptions(10, SERIES_NAME_LONG))
95
- .add('default with long series names and no spaces', () =>
96
- getStoryOptions(10, SERIES_NAME_LONG_WITHOUT_SPACES)
97
- )
98
- .add('with tabular layout', () => getStoryOptions(10, SERIES_NAME_SHORT, LEGEND_LAYOUT_TABLE))
99
- .add('with tabular layout and long series names', () =>
100
- getStoryOptions(10, SERIES_NAME_LONG, LEGEND_LAYOUT_TABLE)
101
- )
102
- .add('with tabular layout and long series names with no spaces', () =>
103
- getStoryOptions(10, SERIES_NAME_LONG_WITHOUT_SPACES, LEGEND_LAYOUT_TABLE)
104
- );
90
+ export const Default = () => getStoryOptions(10, SERIES_NAME_SHORT);
91
+
92
+ export const DefaultWithLongSeriesNames = () => getStoryOptions(10, SERIES_NAME_LONG);
93
+
94
+ export const DefaultWithLongSeriesNamesAndNoSpaces = () =>
95
+ getStoryOptions(10, SERIES_NAME_LONG_WITHOUT_SPACES);
96
+
97
+ export const WithTabularLayout = () => getStoryOptions(10, SERIES_NAME_SHORT, LEGEND_LAYOUT_TABLE);
98
+ export const WithTabularLayoutAndLongSeriesNames = () =>
99
+ getStoryOptions(10, SERIES_NAME_LONG, LEGEND_LAYOUT_TABLE);
100
+
101
+ export const WithTabularLayoutAndLongSeriesNamesWithNoSpaces = () =>
102
+ getStoryOptions(10, SERIES_NAME_LONG_WITHOUT_SPACES, LEGEND_LAYOUT_TABLE);
103
+
104
+ export default {
105
+ title: 'charts/chart-legend',
106
+ component: GlChartLegend,
107
+ parameters: {
108
+ controls: { disable: true },
109
+ knobs: { disable: true },
110
+ },
111
+ };
@@ -39,6 +39,9 @@ export default {
39
39
  required: false,
40
40
  default: () => ({}),
41
41
  },
42
+ /**
43
+ * Text for data average (overridden by prop if needed for internationalization)
44
+ */
42
45
  averageText: {
43
46
  type: String,
44
47
  required: false,
@@ -54,11 +57,17 @@ export default {
54
57
  required: false,
55
58
  default: LEGEND_MIN_TEXT,
56
59
  },
60
+ /**
61
+ * Text for max amount (overridden by prop if needed for internationalization)
62
+ */
57
63
  maxText: {
58
64
  type: String,
59
65
  required: false,
60
66
  default: LEGEND_MAX_TEXT,
61
67
  },
68
+ /**
69
+ * Sets the display layout
70
+ */
62
71
  layout: {
63
72
  type: String,
64
73
  required: false,
@@ -1,8 +1,6 @@
1
- import examples from './examples';
2
1
  import description from './line.md';
3
2
 
4
3
  export default {
5
4
  followsDesignSystem: false,
6
5
  description,
7
- examples,
8
6
  };
@@ -1,5 +1,3 @@
1
- ### Line Chart
2
-
3
1
  This is a basic line chart.
4
2
 
5
3
  ### Implementation Details