@gitlab/ui 36.2.0 → 36.5.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/components/base/drawer/drawer.documentation.js +2 -5
  3. package/dist/components/charts/single_stat/single_stat.documentation.js +1 -4
  4. package/dist/components/regions/empty_state/empty_state.js +3 -2
  5. package/dist/utility_classes.css +1 -1
  6. package/dist/utility_classes.css.map +1 -1
  7. package/documentation/documented_stories.js +2 -0
  8. package/package.json +2 -2
  9. package/src/components/base/breadcrumb/breadcrumb.stories.js +8 -8
  10. package/src/components/base/drawer/drawer.documentation.js +0 -2
  11. package/src/components/base/drawer/drawer.md +0 -6
  12. package/src/components/base/drawer/drawer.stories.js +66 -34
  13. package/src/components/charts/single_stat/single_stat.documentation.js +0 -2
  14. package/src/components/charts/single_stat/single_stat.md +0 -2
  15. package/src/components/charts/single_stat/single_stat.stories.js +73 -80
  16. package/src/components/regions/empty_state/empty_state.spec.js +49 -0
  17. package/src/components/regions/empty_state/empty_state.vue +11 -8
  18. package/src/scss/utilities.scss +20 -0
  19. package/src/scss/utility-mixins/grid.scss +4 -0
  20. package/src/scss/utility-mixins/spacing.scss +6 -0
  21. package/dist/components/base/drawer/examples/drawer.basic.example.js +0 -58
  22. package/dist/components/base/drawer/examples/index.js +0 -13
  23. package/dist/components/charts/single_stat/examples/index.js +0 -32
  24. package/dist/components/charts/single_stat/examples/single_stat.badge.example.js +0 -38
  25. package/dist/components/charts/single_stat/examples/single_stat.hover.example.js +0 -38
  26. package/dist/components/charts/single_stat/examples/single_stat.meta_icon.example.js +0 -38
  27. package/dist/components/charts/single_stat/examples/single_stat.simple.example.js +0 -38
  28. package/dist/components/charts/single_stat/examples/single_stat.title_icon.example.js +0 -38
  29. package/src/components/base/drawer/examples/drawer.basic.example.vue +0 -29
  30. package/src/components/base/drawer/examples/index.js +0 -15
  31. package/src/components/charts/single_stat/examples/index.js +0 -38
  32. package/src/components/charts/single_stat/examples/single_stat.badge.example.vue +0 -31
  33. package/src/components/charts/single_stat/examples/single_stat.hover.example.vue +0 -7
  34. package/src/components/charts/single_stat/examples/single_stat.meta_icon.example.vue +0 -10
  35. package/src/components/charts/single_stat/examples/single_stat.simple.example.vue +0 -7
  36. package/src/components/charts/single_stat/examples/single_stat.title_icon.example.vue +0 -7
@@ -127,6 +127,8 @@ export const setupStorybookReadme = () =>
127
127
  'GlNavItem',
128
128
  'GlNavItemDropdown',
129
129
  'GlPopover',
130
+ 'GlSingleStat',
131
+ 'GlDrawer',
130
132
  ],
131
133
  components: {
132
134
  GlComponentDocumentation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "36.2.0",
3
+ "version": "36.5.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -84,7 +84,7 @@
84
84
  "@babel/preset-env": "^7.10.2",
85
85
  "@gitlab/eslint-plugin": "10.0.2",
86
86
  "@gitlab/stylelint-config": "4.0.0",
87
- "@gitlab/svgs": "2.2.0",
87
+ "@gitlab/svgs": "2.5.0",
88
88
  "@rollup/plugin-commonjs": "^11.1.0",
89
89
  "@rollup/plugin-node-resolve": "^7.1.3",
90
90
  "@rollup/plugin-replace": "^2.3.2",
@@ -16,19 +16,19 @@ const template = `
16
16
 
17
17
  const defaultItems = [
18
18
  {
19
- text: 'First Item',
19
+ text: 'First item',
20
20
  href: '#',
21
21
  },
22
22
  {
23
- text: 'Second Item',
23
+ text: 'Second item',
24
24
  href: '#',
25
25
  },
26
26
  {
27
- text: 'Third Item',
27
+ text: 'Third item',
28
28
  href: '#',
29
29
  },
30
30
  {
31
- text: 'Fourth Item',
31
+ text: 'Fourth item',
32
32
  to: { name: 'fourth-item' },
33
33
  },
34
34
  ];
@@ -63,19 +63,19 @@ export default {
63
63
 
64
64
  const extraItems = [
65
65
  {
66
- text: 'Fifth Item',
66
+ text: 'Fifth item',
67
67
  href: '#',
68
68
  },
69
69
  {
70
- text: 'Sixth Item',
70
+ text: 'Sixth item',
71
71
  href: '#',
72
72
  },
73
73
  {
74
- text: 'Seventh Item',
74
+ text: 'Seventh item',
75
75
  href: '#',
76
76
  },
77
77
  {
78
- text: 'Eighth Item',
78
+ text: 'Eighth item',
79
79
  href: '#',
80
80
  },
81
81
  ];
@@ -1,8 +1,6 @@
1
1
  import description from './drawer.md';
2
- import examples from './examples';
3
2
 
4
3
  export default {
5
4
  followsDesignSystem: false,
6
5
  description,
7
- examples,
8
6
  };
@@ -1,9 +1,3 @@
1
- # Drawer
2
-
3
- <!-- STORY -->
4
-
5
- ## Usage
6
-
7
1
  The drawer is used to show more information about a certain resource in the UI and potentially
8
2
  handle actions on the information.
9
3
 
@@ -1,13 +1,7 @@
1
- import { withKnobs } from '@storybook/addon-knobs';
2
- import { documentedStoriesOf } from '../../../../documentation/documented_stories';
3
- import { GlButton } from '../../../index';
1
+ import { GlDrawer, GlButton } from '../../../index';
4
2
  import readme from './drawer.md';
5
- import GlDrawer from './drawer.vue';
6
3
 
7
- const components = {
8
- GlDrawer,
9
- GlButton,
10
- };
4
+ const components = { GlDrawer, GlButton };
11
5
 
12
6
  const drawerContent = [
13
7
  'One',
@@ -31,7 +25,8 @@ const drawerContent = [
31
25
  )
32
26
  .join('');
33
27
 
34
- const getStory = (template) => ({
28
+ export const Default = (_args, { viewMode }) => ({
29
+ components,
35
30
  methods: {
36
31
  toggle() {
37
32
  this.open = !this.open;
@@ -42,45 +37,68 @@ const getStory = (template) => ({
42
37
  },
43
38
  data() {
44
39
  return {
45
- open: true,
40
+ open: viewMode !== 'docs',
46
41
  };
47
42
  },
48
- components,
49
- template,
50
- });
51
-
52
- documentedStoriesOf('base/drawer', readme)
53
- .addDecorator(withKnobs)
54
- .add('default', () =>
55
- getStory(`
43
+ template: `
56
44
  <div>
57
45
  <gl-button @click="toggle">Toggle Drawer</gl-button>
58
46
  <gl-drawer :open="open" @close="close">
59
47
  <template #title>List Settings</template>
60
48
  ${drawerContent}
61
49
  </gl-drawer>
62
- </div>`)
63
- )
64
- .add('with actions', () =>
65
- getStory(`
50
+ </div>`,
51
+ });
52
+
53
+ export const WithActions = (_args, { viewMode }) => ({
54
+ components,
55
+ methods: {
56
+ toggle() {
57
+ this.open = !this.open;
58
+ },
59
+ close() {
60
+ this.open = false;
61
+ },
62
+ },
63
+ data() {
64
+ return {
65
+ open: viewMode !== 'docs',
66
+ };
67
+ },
68
+ template: `
66
69
  <div>
67
70
  <gl-button @click="toggle">Toggle Drawer</gl-button>
68
71
  <gl-drawer :open="open" @close="close">
69
- <template #title>
72
+ <template #title>
70
73
  <h3>custom-network-policy</h3>
71
74
  </template>
72
75
  <template #header>
73
- <div class="gl-mt-5">
74
- <gl-button variant="confirm">Save</gl-button>
75
- <gl-button class="gl-ml-3" @click="toggle">Cancel</gl-button>
76
- </div>
76
+ <div class="gl-mt-5">
77
+ <gl-button variant="confirm">Save</gl-button>
78
+ <gl-button class="gl-ml-3" @click="toggle">Cancel</gl-button>
79
+ </div>
77
80
  </template>
78
- ${drawerContent}
81
+ ${drawerContent}
79
82
  </gl-drawer>
80
- </div>`)
81
- )
82
- .add('sidebar variant', () =>
83
- getStory(`
83
+ </div>`,
84
+ });
85
+
86
+ export const SidebarVariant = (_args, { viewMode }) => ({
87
+ components,
88
+ methods: {
89
+ toggle() {
90
+ this.open = !this.open;
91
+ },
92
+ close() {
93
+ this.open = false;
94
+ },
95
+ },
96
+ data() {
97
+ return {
98
+ open: viewMode !== 'docs',
99
+ };
100
+ },
101
+ template: `
84
102
  <div>
85
103
  <gl-button @click="toggle">Toggle Drawer</gl-button>
86
104
  <gl-drawer :open="open" @close="close" variant="sidebar">
@@ -94,5 +112,19 @@ documentedStoriesOf('base/drawer', readme)
94
112
  </template>
95
113
  ${drawerContent}
96
114
  </gl-drawer>
97
- </div>`)
98
- );
115
+ </div>`,
116
+ });
117
+
118
+ export default {
119
+ title: 'base/drawer',
120
+ component: GlDrawer,
121
+ parameters: {
122
+ knobs: { disabled: true },
123
+ controls: { disable: true },
124
+ docs: {
125
+ description: {
126
+ component: readme,
127
+ },
128
+ },
129
+ },
130
+ };
@@ -1,7 +1,5 @@
1
- import examples from './examples';
2
1
  import description from './single_stat.md';
3
2
 
4
3
  export default {
5
- examples,
6
4
  description,
7
5
  };
@@ -1,5 +1,3 @@
1
- ### Single Stat
2
-
3
1
  The single stat component is used to show a single value. The color of the meta icon / badge is
4
2
  determined by the **variant** prop, which can be one of "success", "warning", "danger", "info",
5
3
  "neutral" or "muted" (default).
@@ -1,100 +1,93 @@
1
1
  import iconSpriteInfo from '@gitlab/svgs/dist/icons.json';
2
- import { withKnobs, text, select, boolean, number } from '@storybook/addon-knobs';
3
2
  import { GlSingleStat } from '../../../charts';
4
- import { documentedStoriesOf } from '../../../../documentation/documented_stories';
5
3
  import { badgeVariantOptions } from '../../../utils/constants';
6
4
  import readme from './single_stat.md';
7
5
 
8
- const components = {
9
- GlSingleStat,
10
- };
11
-
12
- const template = `
13
- <gl-single-stat
14
- :title="title"
15
- :value="value"
16
- :unit="unit"
17
- :variant="variant"
18
- :meta-text="metaText"
19
- :meta-icon="metaIcon"
20
- :title-icon="titleIcon"
21
- :should-animate="shouldAnimate"
22
- :animation-decimal-places="animationDecimalPlaces"
23
- />
24
- `;
25
-
26
6
  const generateProps = ({
27
7
  variant = GlSingleStat.props.variant.default,
28
8
  title = 'Single stat',
29
9
  value = '100',
30
- unit = null,
31
- metaText = null,
10
+ unit = '',
11
+ metaText = '',
32
12
  metaIcon = null,
33
13
  titleIcon = null,
34
14
  shouldAnimate = false,
35
15
  animationDecimalPlaces = 0,
36
16
  } = {}) => ({
37
- variant: {
38
- type: String,
39
- default: select('variant', Object.values(badgeVariantOptions), variant),
40
- },
41
- title: {
42
- type: String,
43
- default: text('title', title),
44
- },
45
- value: {
46
- type: String,
47
- default: text('value', value),
48
- },
49
- unit: {
50
- type: [String, Number],
51
- default: text('unit', unit),
52
- },
53
- metaText: {
54
- type: String,
55
- default: text('metaText', metaText),
56
- },
57
- metaIcon: {
58
- type: String,
59
- default: select('metaIcon', ['', ...iconSpriteInfo.icons], metaIcon),
60
- },
61
- titleIcon: {
62
- type: String,
63
- default: select('titleIcon', ['', ...iconSpriteInfo.icons], titleIcon),
64
- },
65
- shouldAnimate: {
66
- type: Boolean,
67
- default: boolean('shouldAnimate', shouldAnimate),
68
- },
69
- animationDecimalPlaces: {
70
- type: Number,
71
- default: number('animationDecimalPlaces', animationDecimalPlaces),
72
- },
17
+ variant,
18
+ title,
19
+ value,
20
+ unit,
21
+ metaText,
22
+ metaIcon,
23
+ titleIcon,
24
+ shouldAnimate,
25
+ animationDecimalPlaces,
73
26
  });
74
27
 
75
28
  const metaText = 'Super fast';
76
29
  const metaIcon = 'check-circle';
77
30
  const titleIcon = 'hourglass';
78
31
 
79
- documentedStoriesOf('charts/single-stat', readme)
80
- .addDecorator(withKnobs)
81
- .add('default', () => ({
82
- components,
83
- props: generateProps(),
84
- template,
85
- }))
86
- .add('with badge', () => ({
87
- components,
88
- props: generateProps({ metaText, metaIcon }),
89
- template,
90
- }))
91
- .add('with meta icon', () => ({
92
- components,
93
- props: generateProps({ metaIcon }),
94
- template,
95
- }))
96
- .add('with title icon', () => ({
97
- components,
98
- props: generateProps({ titleIcon }),
99
- template,
100
- }));
32
+ const Template = (args, { argTypes }) => ({
33
+ components: {
34
+ GlSingleStat,
35
+ },
36
+ props: Object.keys(argTypes),
37
+ template: `
38
+ <gl-single-stat
39
+ :title="title"
40
+ :value="value"
41
+ :unit="unit"
42
+ :variant="variant"
43
+ :meta-text="metaText"
44
+ :meta-icon="metaIcon"
45
+ :title-icon="titleIcon"
46
+ :should-animate="shouldAnimate"
47
+ :animation-decimal-places="animationDecimalPlaces"
48
+ />`,
49
+ });
50
+
51
+ export const Default = Template.bind({});
52
+ Default.args = generateProps();
53
+
54
+ export const WithBadge = Template.bind({});
55
+ WithBadge.args = generateProps({ metaText, metaIcon });
56
+
57
+ export const WithMetaIcon = Template.bind({});
58
+ WithMetaIcon.args = generateProps({ metaIcon });
59
+
60
+ export const WithTitleIcon = Template.bind({});
61
+ WithTitleIcon.args = generateProps({ titleIcon });
62
+
63
+ export default {
64
+ title: 'charts/single-stat',
65
+ component: GlSingleStat,
66
+ parameters: {
67
+ knobs: { disable: true },
68
+ docs: {
69
+ description: {
70
+ component: readme,
71
+ },
72
+ },
73
+ },
74
+ argTypes: {
75
+ variant: {
76
+ options: Object.values(badgeVariantOptions),
77
+ control: {
78
+ type: 'select',
79
+ },
80
+ },
81
+ metaIcon: {
82
+ options: iconSpriteInfo.icons,
83
+ control: 'select',
84
+ },
85
+ titleIcon: {
86
+ options: iconSpriteInfo.icons,
87
+ control: 'select',
88
+ },
89
+ unit: {
90
+ control: 'text',
91
+ },
92
+ },
93
+ };
@@ -148,6 +148,55 @@ describe('empty state component', () => {
148
148
  });
149
149
  });
150
150
 
151
+ describe('with different titles', () => {
152
+ it('should render title from prop', () => {
153
+ component = shallowMount(EmptyState, {
154
+ propsData: {
155
+ ...props,
156
+ },
157
+ });
158
+
159
+ const title = component.find('h1');
160
+ expect(title.text()).toBe(props.title);
161
+ });
162
+
163
+ it('should render title from slot', () => {
164
+ const slotTitle = 'Slotted title';
165
+
166
+ component = shallowMount(EmptyState, {
167
+ propsData: {
168
+ ...props,
169
+ title: null,
170
+ },
171
+ slots: {
172
+ title: `<strong id="slotted">${slotTitle}</strong>`,
173
+ },
174
+ });
175
+
176
+ const title = component.find('#slotted');
177
+ expect(title.text()).toBe(slotTitle);
178
+ });
179
+
180
+ it('should render a slotted title over a props title', () => {
181
+ const slotTitle = 'Slotted title';
182
+
183
+ component = shallowMount(EmptyState, {
184
+ propsData: {
185
+ ...props,
186
+ },
187
+ slots: {
188
+ title: `<strong id="slotted">${slotTitle}</strong>`,
189
+ },
190
+ });
191
+
192
+ const title = component.find('#slotted');
193
+ const propTitle = component.find('h1');
194
+
195
+ expect(title.text()).toBe(slotTitle);
196
+ expect(propTitle.exists()).toBe(false);
197
+ });
198
+ });
199
+
151
200
  describe('with different descriptions', () => {
152
201
  it('should render description from prop', () => {
153
202
  component = shallowMount(EmptyState, {
@@ -11,7 +11,8 @@ export default {
11
11
  */
12
12
  title: {
13
13
  type: String,
14
- required: true,
14
+ required: false,
15
+ default: null,
15
16
  },
16
17
  /**
17
18
  * The illustration's URL.
@@ -112,13 +113,15 @@ export default {
112
113
  </div>
113
114
  <div :class="compact ? 'gl-flex-grow-1 gl-flex-basis-0 gl-px-4' : 'gl-max-w-full gl-m-auto'">
114
115
  <div class="gl-mx-auto gl-my-0" :class="{ 'gl-p-5': !compact }">
115
- <h1
116
- ref="title"
117
- class="gl-font-size-h-display gl-line-height-36"
118
- :class="compact ? 'h5' : 'h4'"
119
- >
120
- {{ title }}
121
- </h1>
116
+ <!--
117
+ @slot Use this slot to customize the empty state's title area.
118
+ Overrides the `title` prop.
119
+ -->
120
+ <slot ref="title" name="title">
121
+ <h1 class="gl-font-size-h-display gl-line-height-36" :class="compact ? 'h5' : 'h4'">
122
+ {{ title }}
123
+ </h1>
124
+ </slot>
122
125
  <p v-if="description || $scopedSlots.description" ref="description" class="gl-mt-3">
123
126
  <!--
124
127
  @slot Use this slot to customize the empty state's description
@@ -3295,6 +3295,14 @@
3295
3295
  grid-column-start: 1 !important
3296
3296
  }
3297
3297
 
3298
+ .gl-grid-template-columns-2 {
3299
+ grid-template-columns: 1fr 1fr
3300
+ }
3301
+
3302
+ .gl-grid-template-columns-2\! {
3303
+ grid-template-columns: 1fr 1fr !important
3304
+ }
3305
+
3298
3306
  .gl-list-style-none {
3299
3307
  list-style-type: none
3300
3308
  }
@@ -6400,6 +6408,18 @@
6400
6408
  padding-left: $gl-spacing-scale-7 !important;
6401
6409
  }
6402
6410
  }
6411
+ .gl-md-px-7 {
6412
+ @include gl-media-breakpoint-up(md) {
6413
+ padding-left: $gl-spacing-scale-7;
6414
+ padding-right: $gl-spacing-scale-7;
6415
+ }
6416
+ }
6417
+ .gl-md-px-7\! {
6418
+ @include gl-media-breakpoint-up(md) {
6419
+ padding-left: $gl-spacing-scale-7 !important;
6420
+ padding-right: $gl-spacing-scale-7 !important;
6421
+ }
6422
+ }
6403
6423
  .gl-lg-pt-0 {
6404
6424
  @include gl-media-breakpoint-up(lg) {
6405
6425
  padding-top: 0;
@@ -10,3 +10,7 @@
10
10
  @mixin gl-grid-col-start-1 {
11
11
  grid-column-start: 1;
12
12
  }
13
+
14
+ @mixin gl-grid-template-columns-2 {
15
+ grid-template-columns: 1fr 1fr;
16
+ }
@@ -1209,6 +1209,12 @@
1209
1209
  }
1210
1210
  }
1211
1211
 
1212
+ @mixin gl-md-px-7 {
1213
+ @include gl-media-breakpoint-up(md) {
1214
+ @include gl-px-7;
1215
+ }
1216
+ }
1217
+
1212
1218
  @mixin gl-lg-pt-0 {
1213
1219
  @include gl-media-breakpoint-up(lg) {
1214
1220
  @include gl-pt-0;
@@ -1,58 +0,0 @@
1
- import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
2
-
3
- var script = {
4
- data() {
5
- return {
6
- drawerOpened: false
7
- };
8
- },
9
-
10
- methods: {
11
- toggle() {
12
- this.drawerOpened = !this.drawerOpened;
13
- },
14
-
15
- close() {
16
- this.drawerOpened = false;
17
- }
18
-
19
- }
20
- };
21
-
22
- /* script */
23
- const __vue_script__ = script;
24
-
25
- /* template */
26
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('gl-button',{on:{"click":_vm.toggle}},[_vm._v("Toggle drawer")]),_vm._v(" "),_c('gl-drawer',{attrs:{"open":_vm.drawerOpened},on:{"close":_vm.close},scopedSlots:_vm._u([{key:"header",fn:function(){return [_vm._v("Your Title")]},proxy:true}])},[_vm._v(" "),_c('div',[_c('p',[_vm._v("First Body Item")])])])],1)};
27
- var __vue_staticRenderFns__ = [];
28
-
29
- /* style */
30
- const __vue_inject_styles__ = undefined;
31
- /* scoped */
32
- const __vue_scope_id__ = undefined;
33
- /* module identifier */
34
- const __vue_module_identifier__ = undefined;
35
- /* functional template */
36
- const __vue_is_functional_template__ = false;
37
- /* style inject */
38
-
39
- /* style inject SSR */
40
-
41
- /* style inject shadow dom */
42
-
43
-
44
-
45
- const __vue_component__ = __vue_normalize__(
46
- { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
47
- __vue_inject_styles__,
48
- __vue_script__,
49
- __vue_scope_id__,
50
- __vue_is_functional_template__,
51
- __vue_module_identifier__,
52
- false,
53
- undefined,
54
- undefined,
55
- undefined
56
- );
57
-
58
- export default __vue_component__;
@@ -1,13 +0,0 @@
1
- import Drawer from './drawer.basic.example';
2
-
3
- var index = [{
4
- name: 'Basic',
5
- items: [{
6
- id: 'drawer',
7
- name: 'Default Drawer',
8
- description: 'Drawer',
9
- component: Drawer
10
- }]
11
- }];
12
-
13
- export default index;
@@ -1,32 +0,0 @@
1
- import SingleStatBadgeExample from './single_stat.badge.example';
2
- import SingleStatHoverExample from './single_stat.hover.example';
3
- import SingleStatIconExample from './single_stat.meta_icon.example';
4
- import SingleStatSimpleExample from './single_stat.simple.example';
5
- import SingleStatTitleIconExample from './single_stat.title_icon.example';
6
-
7
- var index = [{
8
- name: 'Basic',
9
- items: [{
10
- id: 'simple',
11
- name: 'Simple',
12
- component: SingleStatSimpleExample
13
- }, {
14
- id: 'metaIcon',
15
- name: 'Meta Icon',
16
- component: SingleStatIconExample
17
- }, {
18
- id: 'badge',
19
- name: 'Badge',
20
- component: SingleStatBadgeExample
21
- }, {
22
- id: 'titleIcon',
23
- name: 'Title Icon',
24
- component: SingleStatTitleIconExample
25
- }, {
26
- id: 'hover',
27
- name: 'Hover',
28
- component: SingleStatHoverExample
29
- }]
30
- }];
31
-
32
- export default index;