@gitlab/ui 40.7.1 → 41.2.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.
@@ -86,7 +86,7 @@ const axes = {
86
86
  },
87
87
  nameGap: 30,
88
88
  nameTextStyle: {
89
- fontStyle: 'bold'
89
+ fontWeight: 'bold'
90
90
  },
91
91
  splitLine: {
92
92
  lineStyle: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "40.7.1",
3
+ "version": "41.2.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -58,7 +58,7 @@
58
58
  "@popperjs/core": "^2.11.2",
59
59
  "bootstrap-vue": "2.20.1",
60
60
  "dompurify": "^2.3.8",
61
- "echarts": "^5.2.1",
61
+ "echarts": "^5.3.2",
62
62
  "iframe-resizer": "^4.3.2",
63
63
  "lodash": "^4.17.20",
64
64
  "portal-vue": "^2.1.6",
@@ -83,7 +83,7 @@
83
83
  "@babel/preset-env": "^7.10.2",
84
84
  "@gitlab/eslint-plugin": "12.3.0",
85
85
  "@gitlab/stylelint-config": "4.0.0",
86
- "@gitlab/svgs": "2.14.0",
86
+ "@gitlab/svgs": "2.15.0",
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",
@@ -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
@@ -128,7 +128,7 @@ const axes = {
128
128
  },
129
129
  nameGap: 30,
130
130
  nameTextStyle: {
131
- fontStyle: 'bold',
131
+ fontWeight: 'bold',
132
132
  },
133
133
  splitLine: {
134
134
  lineStyle: {