@gitlab/ui 40.7.0 → 41.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "40.7.0",
3
+ "version": "41.1.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -87,15 +87,15 @@
87
87
  "@rollup/plugin-commonjs": "^11.1.0",
88
88
  "@rollup/plugin-node-resolve": "^7.1.3",
89
89
  "@rollup/plugin-replace": "^2.3.2",
90
- "@storybook/addon-a11y": "6.5.5",
91
- "@storybook/addon-docs": "6.5.5",
92
- "@storybook/addon-essentials": "6.5.5",
90
+ "@storybook/addon-a11y": "6.5.6",
91
+ "@storybook/addon-docs": "6.5.6",
92
+ "@storybook/addon-essentials": "6.5.6",
93
93
  "@storybook/addon-knobs": "6.4.0",
94
- "@storybook/addon-storyshots": "6.5.5",
95
- "@storybook/addon-storyshots-puppeteer": "6.5.5",
96
- "@storybook/addon-viewport": "6.5.5",
97
- "@storybook/theming": "6.5.5",
98
- "@storybook/vue": "6.5.5",
94
+ "@storybook/addon-storyshots": "6.5.6",
95
+ "@storybook/addon-storyshots-puppeteer": "6.5.6",
96
+ "@storybook/addon-viewport": "6.5.6",
97
+ "@storybook/theming": "6.5.6",
98
+ "@storybook/vue": "6.5.6",
99
99
  "@vue/test-utils": "1.3.0",
100
100
  "autoprefixer": "^9.7.6",
101
101
  "babel-jest": "^26.6.3",
@@ -11,6 +11,12 @@ $gl-sidebar-width: 290px;
11
11
  @include gl-font-base;
12
12
  @include gl-line-height-normal;
13
13
 
14
+ .gl-drawer-header-sticky {
15
+ @include gl-bg-white;
16
+ @include gl-top-0;
17
+ @include gl-sticky;
18
+ }
19
+
14
20
  @include media-breakpoint-down(sm) {
15
21
  @include gl-w-full;
16
22
  }
@@ -34,8 +40,15 @@ $gl-sidebar-width: 290px;
34
40
  .gl-drawer-header,
35
41
  .gl-drawer-body > * {
36
42
  @include gl-py-5;
43
+ }
44
+
45
+ .gl-drawer-body > * {
37
46
  @include gl-mx-5;
38
47
  }
48
+
49
+ .gl-drawer-header {
50
+ @include gl-px-5;
51
+ }
39
52
  }
40
53
 
41
54
  .gl-drawer-header {
@@ -27,6 +27,16 @@ describe('drawer component', () => {
27
27
  });
28
28
  });
29
29
 
30
+ describe('when sticky header is true', () => {
31
+ it('renders drawer header with sticky position', () => {
32
+ mountWithOpts({ props: { open: true, headerSticky: true } });
33
+ const header = wrapper.find('.gl-drawer-header');
34
+
35
+ expect(header.classes()).toContain('gl-drawer-header-sticky');
36
+ expect(header.attributes('style')).toBe('z-index: 10;');
37
+ });
38
+ });
39
+
30
40
  describe('when open is false', () => {
31
41
  it('cannot find aside html element', () => {
32
42
  mountWithOpts({ props: { open: false } });
@@ -1,4 +1,5 @@
1
1
  import { GlDrawer, GlButton } from '../../../index';
2
+ import { drawerVariants } from '../../../utils/constants';
2
3
  import readme from './drawer.md';
3
4
 
4
5
  const components = { GlDrawer, GlButton };
@@ -14,6 +15,10 @@ const drawerContent = [
14
15
  'Eight',
15
16
  'Nine',
16
17
  'Ten',
18
+ 'Eleven',
19
+ 'Twelve',
20
+ 'Thirteen',
21
+ 'Fourteen',
17
22
  ]
18
23
  .map(
19
24
  (str) => `
@@ -25,7 +30,32 @@ const drawerContent = [
25
30
  )
26
31
  .join('');
27
32
 
28
- export const Default = (_args, { viewMode }) => ({
33
+ const createSidebarTemplate = (content) => `
34
+ <gl-drawer
35
+ :open="open"
36
+ :header-height="headerHeight"
37
+ :header-sticky="headerSticky"
38
+ :z-index="zIndex"
39
+ :variant="variant"
40
+ @close="close">${content}</gl-drawer>
41
+ `;
42
+
43
+ const defaultValue = (prop) => GlDrawer.props[prop].default;
44
+
45
+ const generateProps = ({
46
+ headerHeight = defaultValue('headerHeight'),
47
+ headerSticky = defaultValue('headerSticky'),
48
+ zIndex = defaultValue('zIndex'),
49
+ variant = defaultValue('variant'),
50
+ } = {}) => ({
51
+ headerHeight,
52
+ headerSticky,
53
+ zIndex,
54
+ variant,
55
+ });
56
+
57
+ const storyOptions = (viewMode) => ({
58
+ props: Object.keys(generateProps()),
29
59
  components,
30
60
  methods: {
31
61
  toggle() {
@@ -40,35 +70,27 @@ export const Default = (_args, { viewMode }) => ({
40
70
  open: viewMode !== 'docs',
41
71
  };
42
72
  },
73
+ });
74
+
75
+ export const Default = (_args, { viewMode }) => ({
76
+ ...storyOptions(viewMode),
43
77
  template: `
44
78
  <div>
45
79
  <gl-button @click="toggle">Toggle Drawer</gl-button>
46
- <gl-drawer :open="open" @close="close">
80
+ ${createSidebarTemplate(`
47
81
  <template #title>List Settings</template>
48
82
  ${drawerContent}
49
- </gl-drawer>
83
+ `)}
50
84
  </div>`,
51
85
  });
86
+ Default.args = generateProps();
52
87
 
53
88
  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
- },
89
+ ...storyOptions(viewMode),
68
90
  template: `
69
91
  <div>
70
92
  <gl-button @click="toggle">Toggle Drawer</gl-button>
71
- <gl-drawer :open="open" @close="close">
93
+ ${createSidebarTemplate(`
72
94
  <template #title>
73
95
  <h3>custom-network-policy</h3>
74
96
  </template>
@@ -79,29 +101,17 @@ export const WithActions = (_args, { viewMode }) => ({
79
101
  </div>
80
102
  </template>
81
103
  ${drawerContent}
82
- </gl-drawer>
104
+ `)}
83
105
  </div>`,
84
106
  });
107
+ WithActions.args = generateProps();
85
108
 
86
109
  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
- },
110
+ ...storyOptions(viewMode),
101
111
  template: `
102
112
  <div>
103
113
  <gl-button @click="toggle">Toggle Drawer</gl-button>
104
- <gl-drawer :open="open" @close="close" variant="sidebar">
114
+ ${createSidebarTemplate(`
105
115
  <template #title>
106
116
  <h3>Sidebar</h3>
107
117
  </template>
@@ -111,16 +121,42 @@ export const SidebarVariant = (_args, { viewMode }) => ({
111
121
  </div>
112
122
  </template>
113
123
  ${drawerContent}
114
- </gl-drawer>
124
+ `)}
115
125
  </div>`,
116
126
  });
127
+ SidebarVariant.args = generateProps({
128
+ variant: drawerVariants.sidebar,
129
+ });
130
+
131
+ export const StickyHeader = (_args, { viewMode }) => ({
132
+ ...storyOptions(viewMode),
133
+ template: `
134
+ <div>
135
+ <gl-button @click="toggle">Toggle Drawer</gl-button>
136
+ ${createSidebarTemplate(`
137
+ <template #title>List Settings</template>
138
+ ${drawerContent}
139
+ `)}
140
+ </div>`,
141
+ });
142
+ StickyHeader.args = generateProps({
143
+ headerSticky: true,
144
+ });
117
145
 
118
146
  export default {
119
147
  title: 'base/drawer',
120
148
  component: GlDrawer,
149
+ argTypes: {
150
+ open: {
151
+ control: false,
152
+ },
153
+ variant: {
154
+ options: Object.keys(drawerVariants),
155
+ control: 'select',
156
+ },
157
+ },
121
158
  parameters: {
122
159
  knobs: { disabled: true },
123
- controls: { disable: true },
124
160
  docs: {
125
161
  description: {
126
162
  component: readme,
@@ -18,6 +18,11 @@ export default {
18
18
  required: false,
19
19
  default: '',
20
20
  },
21
+ headerSticky: {
22
+ type: Boolean,
23
+ required: false,
24
+ default: false,
25
+ },
21
26
  zIndex: {
22
27
  type: Number,
23
28
  required: false,
@@ -46,6 +51,11 @@ export default {
46
51
 
47
52
  return styles;
48
53
  },
54
+ drawerHeaderStyles() {
55
+ return {
56
+ zIndex: this.headerSticky ? maxZIndex : null,
57
+ };
58
+ },
49
59
  variantClass() {
50
60
  return `gl-drawer-${this.variant}`;
51
61
  },
@@ -79,7 +89,11 @@ export default {
79
89
  <template>
80
90
  <transition name="gl-drawer">
81
91
  <aside v-if="open" :style="drawerStyles" class="gl-drawer" :class="variantClass">
82
- <div class="gl-drawer-header">
92
+ <div
93
+ class="gl-drawer-header"
94
+ :style="drawerHeaderStyles"
95
+ :class="{ 'gl-drawer-header-sticky': headerSticky }"
96
+ >
83
97
  <span class="gl-drawer-title">
84
98
  <slot name="title"></slot>
85
99
  <gl-button
@@ -7,11 +7,7 @@ should serve a single purpose dedicated to completing the user’s task.
7
7
  You can use the `v-model` directive to control the modal’s visibility. The `v-model`
8
8
  directive interfaces with the `visible` property and the `@change` event.
9
9
 
10
- ## Deprecation Warning
11
-
12
- We are deprecating the `modal-ok` and `modal-cancel` slots. We are also changing the way the
13
- `modal-footer` slot content is populated. This is in order to align this component with the design
14
- system.
10
+ ## Modal footer
15
11
 
16
12
  The `modal-footer` slot should only be populated via props: `action-primary`, `action-secondary` and
17
13
  `action-cancel`. These props allow you to handle how a primary, secondary and cancel button will
@@ -86,22 +86,6 @@ export default {
86
86
  default: '',
87
87
  },
88
88
  },
89
- computed: {
90
- shouldRenderModalOk() {
91
- return Boolean(this.$slots['modal-ok']);
92
- },
93
- shouldRenderModalCancel() {
94
- return Boolean(this.$slots['modal-cancel']);
95
- },
96
- shouldRenderModalFooter() {
97
- return Boolean(
98
- this.actionCancel ||
99
- this.actionSecondary ||
100
- this.actionPrimary ||
101
- this.$slots['modal-footer']
102
- );
103
- },
104
- },
105
89
  mounted() {
106
90
  if (!this.ariaLabel && !this.title) {
107
91
  logWarning(
@@ -168,7 +152,7 @@ export default {
168
152
  </script>
169
153
 
170
154
  <template>
171
- <!--
155
+ <!--
172
156
  Emitted when the modal visibility changes
173
157
  @event change
174
158
  -->
@@ -202,14 +186,8 @@ export default {
202
186
  <!-- @slot Content of Modal header close button. If modal-header slot is used, this slot will not be shown. -->
203
187
  <close-button ref="close-button" :label="dismissLabel" @click="close" />
204
188
  </template>
205
- <template v-if="shouldRenderModalOk" #modal-ok>
206
- <slot name="modal-ok"></slot>
207
- </template>
208
- <template v-if="shouldRenderModalCancel" #modal-cancel>
209
- <slot name="modal-cancel"></slot>
210
- </template>
211
189
  <!-- @slot Populated via props: modal-action-primary, modal-action-cancel and modal-action-secondary. -->
212
- <template v-if="shouldRenderModalFooter" #modal-footer>
190
+ <template #modal-footer>
213
191
  <slot name="modal-footer">
214
192
  <!--
215
193
  Emitted when clicked on modal-action-cancel
@@ -5,6 +5,10 @@ import readme from './toggle.md';
5
5
 
6
6
  const defaultValue = (prop) => GlToggle.props[prop].default;
7
7
 
8
+ const longHelp = `This is a toggle component with a long help message.
9
+ You can notice how the text wraps when the width of the container
10
+ is not enough to fix the entire text.`;
11
+
8
12
  const generateProps = ({
9
13
  value = true,
10
14
  disabled = defaultValue('disabled'),
@@ -43,6 +47,11 @@ const Template = (args, { argTypes }) => ({
43
47
  export const Default = Template.bind({});
44
48
  Default.args = generateProps();
45
49
 
50
+ export const WithLongHelp = Template.bind({});
51
+ WithLongHelp.args = generateProps({
52
+ help: longHelp,
53
+ });
54
+
46
55
  export default {
47
56
  title: 'base/toggle',
48
57
  component: GlToggle,
@@ -118,7 +118,7 @@ export default {
118
118
 
119
119
  <template>
120
120
  <div
121
- class="gl-toggle-wrapper gl-display-flex gl-mb-0 gl-w-max-content"
121
+ class="gl-toggle-wrapper gl-display-flex gl-mb-0"
122
122
  :class="{
123
123
  'gl-flex-direction-column': labelPosition === 'top' || labelPosition === 'hidden',
124
124
  'gl-toggle-label-inline': labelPosition === 'left',
@@ -129,7 +129,7 @@ export default {
129
129
  <span
130
130
  :id="labelId"
131
131
  :class="{ 'gl-sr-only': labelPosition === 'hidden' }"
132
- class="gl-toggle-label"
132
+ class="gl-toggle-label gl-flex-shrink-0"
133
133
  data-testid="toggle-label"
134
134
  >
135
135
  <!-- @slot The toggle's label. -->
@@ -146,6 +146,7 @@ export default {
146
146
  'is-checked': value,
147
147
  'is-disabled': disabled,
148
148
  }"
149
+ class="gl-flex-shrink-0"
149
150
  type="button"
150
151
  @click.prevent="toggleFeature"
151
152
  >