@gitlab/ui 52.11.0 → 52.12.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/CHANGELOG.md +7 -0
- package/dist/components/regions/empty_state/empty_state.js +12 -1
- package/package.json +2 -2
- package/src/components/regions/empty_state/empty_state.spec.js +35 -0
- package/src/components/regions/empty_state/empty_state.stories.js +5 -0
- package/src/components/regions/empty_state/empty_state.vue +15 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [52.12.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v52.11.0...v52.12.0) (2023-01-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **GlEmptyState:** Add content-class prop ([7f850d7](https://gitlab.com/gitlab-org/gitlab-ui/commit/7f850d7661ffcb6a2db1cccfaca87cd7d794e01b))
|
|
7
|
+
|
|
1
8
|
# [52.11.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v52.10.0...v52.11.0) (2023-01-16)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -82,6 +82,14 @@ var script = {
|
|
|
82
82
|
type: Boolean,
|
|
83
83
|
required: false,
|
|
84
84
|
default: true
|
|
85
|
+
},
|
|
86
|
+
/**
|
|
87
|
+
* CSS classes to add to the content container
|
|
88
|
+
*/
|
|
89
|
+
contentClass: {
|
|
90
|
+
type: [Array, String, Object],
|
|
91
|
+
required: false,
|
|
92
|
+
default: () => []
|
|
85
93
|
}
|
|
86
94
|
},
|
|
87
95
|
computed: {
|
|
@@ -96,6 +104,9 @@ var script = {
|
|
|
96
104
|
},
|
|
97
105
|
shouldRenderSecondaryButton() {
|
|
98
106
|
return Boolean(this.secondaryButtonLink && this.secondaryButtonText);
|
|
107
|
+
},
|
|
108
|
+
contentClasses() {
|
|
109
|
+
return [this.compact ? 'gl-flex-grow-1 gl-flex-basis-0 gl-px-4' : 'gl-max-w-full gl-m-auto', this.contentClass];
|
|
99
110
|
}
|
|
100
111
|
}
|
|
101
112
|
};
|
|
@@ -107,7 +118,7 @@ const __vue_script__ = script;
|
|
|
107
118
|
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('section',{staticClass:"gl-display-flex",class:{
|
|
108
119
|
'empty-state gl-text-center gl-flex-direction-column': !_vm.compact,
|
|
109
120
|
'gl-flex-direction-row': _vm.compact,
|
|
110
|
-
}},[_c('div',{class:{ 'gl-display-none gl-sm-display-block gl-px-4': _vm.compact, 'gl-max-w-full': !_vm.compact }},[(_vm.svgPath)?_c('div',{staticClass:"svg-250",class:{ 'svg-content': !_vm.compact }},[_c('img',{staticClass:"gl-max-w-full",class:{ 'gl-dark-invert-keep-hue': _vm.invertInDarkMode },attrs:{"src":_vm.svgPath,"alt":"","role":"img","height":_vm.height}})]):_vm._e()]),_vm._v(" "),_c('div',{class:_vm.
|
|
121
|
+
}},[_c('div',{class:{ 'gl-display-none gl-sm-display-block gl-px-4': _vm.compact, 'gl-max-w-full': !_vm.compact }},[(_vm.svgPath)?_c('div',{staticClass:"svg-250",class:{ 'svg-content': !_vm.compact }},[_c('img',{staticClass:"gl-max-w-full",class:{ 'gl-dark-invert-keep-hue': _vm.invertInDarkMode },attrs:{"src":_vm.svgPath,"alt":"","role":"img","height":_vm.height}})]):_vm._e()]),_vm._v(" "),_c('div',{class:_vm.contentClasses,attrs:{"data-testid":"gl-empty-state-content"}},[_c('div',{staticClass:"gl-mx-auto gl-my-0",class:{ 'gl-p-5': !_vm.compact }},[_vm._t("title",function(){return [_c('h1',{staticClass:"gl-font-size-h-display gl-line-height-36",class:_vm.compact ? 'h5' : 'h4'},[_vm._v("\n "+_vm._s(_vm.title)+"\n ")])]}),_vm._v(" "),(_vm.description || _vm.$scopedSlots.description)?_c('p',{ref:"description",staticClass:"gl-mt-3"},[_vm._t("description",function(){return [_vm._v("\n "+_vm._s(_vm.description)+"\n ")]})],2):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-display-flex gl-flex-wrap",class:{ 'gl-justify-content-center': !_vm.compact }},[_vm._t("actions",function(){return [(_vm.shouldRenderPrimaryButton)?_c('gl-button',{staticClass:"gl-mb-3",class:_vm.compact ? 'gl-mr-3' : 'gl-mx-2',attrs:{"variant":"confirm","href":_vm.primaryButtonLink}},[_vm._v(_vm._s(_vm.primaryButtonText))]):_vm._e(),_vm._v(" "),(_vm.shouldRenderSecondaryButton)?_c('gl-button',{staticClass:"gl-mb-3 gl-mr-3",class:{ 'gl-mx-2!': !_vm.compact },attrs:{"href":_vm.secondaryButtonLink}},[_vm._v(_vm._s(_vm.secondaryButtonText)+"\n ")]):_vm._e()]})],2)],2)])])};
|
|
111
122
|
var __vue_staticRenderFns__ = [];
|
|
112
123
|
|
|
113
124
|
/* style */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "52.
|
|
3
|
+
"version": "52.12.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"@babel/core": "^7.20.12",
|
|
86
86
|
"@babel/preset-env": "^7.20.2",
|
|
87
87
|
"@gitlab/eslint-plugin": "18.1.0",
|
|
88
|
-
"@gitlab/fonts": "^1.0
|
|
88
|
+
"@gitlab/fonts": "^1.1.0",
|
|
89
89
|
"@gitlab/stylelint-config": "4.1.0",
|
|
90
90
|
"@gitlab/svgs": "3.16.0",
|
|
91
91
|
"@rollup/plugin-commonjs": "^11.1.0",
|
|
@@ -245,4 +245,39 @@ describe('empty state component', () => {
|
|
|
245
245
|
expect(p.text()).not.toBe(props.description);
|
|
246
246
|
});
|
|
247
247
|
});
|
|
248
|
+
|
|
249
|
+
describe('with custom content class', () => {
|
|
250
|
+
const findContentContainer = () => component.find('[data-testid="gl-empty-state-content"]');
|
|
251
|
+
const customContentClass = 'gl-p-0';
|
|
252
|
+
const expectedDefaultContentClasses = ['gl-max-w-full', 'gl-m-auto', customContentClass];
|
|
253
|
+
const expectedCompactContentClasses = [
|
|
254
|
+
'gl-flex-grow-1',
|
|
255
|
+
'gl-flex-basis-0',
|
|
256
|
+
'gl-px-4',
|
|
257
|
+
customContentClass,
|
|
258
|
+
];
|
|
259
|
+
|
|
260
|
+
it.each`
|
|
261
|
+
contentClass | compact | expectedClasses
|
|
262
|
+
${customContentClass} | ${false} | ${expectedDefaultContentClasses}
|
|
263
|
+
${[customContentClass]} | ${false} | ${expectedDefaultContentClasses}
|
|
264
|
+
${{ [customContentClass]: true }} | ${false} | ${expectedDefaultContentClasses}
|
|
265
|
+
${customContentClass} | ${true} | ${expectedCompactContentClasses}
|
|
266
|
+
${[customContentClass]} | ${true} | ${expectedCompactContentClasses}
|
|
267
|
+
${{ [customContentClass]: true }} | ${true} | ${expectedCompactContentClasses}
|
|
268
|
+
`(
|
|
269
|
+
'applies $contentClass class when compact is $compact',
|
|
270
|
+
({ contentClass, compact, expectedClasses }) => {
|
|
271
|
+
component = shallowMount(EmptyState, {
|
|
272
|
+
propsData: {
|
|
273
|
+
...props,
|
|
274
|
+
compact,
|
|
275
|
+
contentClass,
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
expect(findContentContainer().classes()).toEqual(expectedClasses);
|
|
280
|
+
}
|
|
281
|
+
);
|
|
282
|
+
});
|
|
248
283
|
});
|
|
@@ -14,6 +14,7 @@ const template = `
|
|
|
14
14
|
:compact="compact"
|
|
15
15
|
:primary-button-link="primaryButtonLink"
|
|
16
16
|
:secondary-button-link="secondaryButtonLink"
|
|
17
|
+
:contentClass="contentClass"
|
|
17
18
|
/>`;
|
|
18
19
|
|
|
19
20
|
const Template = (args) => ({
|
|
@@ -34,6 +35,7 @@ const generateProps = ({
|
|
|
34
35
|
primaryButtonLink = '#',
|
|
35
36
|
secondaryButtonLink = '#',
|
|
36
37
|
compact = false,
|
|
38
|
+
contentClass = [],
|
|
37
39
|
} = {}) => ({
|
|
38
40
|
title,
|
|
39
41
|
svgPath,
|
|
@@ -44,6 +46,7 @@ const generateProps = ({
|
|
|
44
46
|
primaryButtonLink,
|
|
45
47
|
secondaryButtonLink,
|
|
46
48
|
compact,
|
|
49
|
+
contentClass,
|
|
47
50
|
});
|
|
48
51
|
|
|
49
52
|
export const Default = Template.bind({});
|
|
@@ -82,6 +85,7 @@ export const CustomActions = (args) => ({
|
|
|
82
85
|
:compact="compact"
|
|
83
86
|
:primary-button-link="primaryButtonLink"
|
|
84
87
|
:secondary-button-link="secondaryButtonLink"
|
|
88
|
+
:contentClass="contentClass"
|
|
85
89
|
>
|
|
86
90
|
<template #actions>
|
|
87
91
|
<gl-button
|
|
@@ -125,6 +129,7 @@ export const SlottedDescription = (args) => ({
|
|
|
125
129
|
:compact="compact"
|
|
126
130
|
:primary-button-link="primaryButtonLink"
|
|
127
131
|
:secondary-button-link="secondaryButtonLink"
|
|
132
|
+
:contentClass="contentClass"
|
|
128
133
|
>
|
|
129
134
|
<template #description>
|
|
130
135
|
<p>A slotted description allows you to use more custom HTML such as <a href="#">links</a>.</p>
|
|
@@ -83,6 +83,14 @@ export default {
|
|
|
83
83
|
required: false,
|
|
84
84
|
default: true,
|
|
85
85
|
},
|
|
86
|
+
/**
|
|
87
|
+
* CSS classes to add to the content container
|
|
88
|
+
*/
|
|
89
|
+
contentClass: {
|
|
90
|
+
type: [Array, String, Object],
|
|
91
|
+
required: false,
|
|
92
|
+
default: () => [],
|
|
93
|
+
},
|
|
86
94
|
},
|
|
87
95
|
computed: {
|
|
88
96
|
height() {
|
|
@@ -97,6 +105,12 @@ export default {
|
|
|
97
105
|
shouldRenderSecondaryButton() {
|
|
98
106
|
return Boolean(this.secondaryButtonLink && this.secondaryButtonText);
|
|
99
107
|
},
|
|
108
|
+
contentClasses() {
|
|
109
|
+
return [
|
|
110
|
+
this.compact ? 'gl-flex-grow-1 gl-flex-basis-0 gl-px-4' : 'gl-max-w-full gl-m-auto',
|
|
111
|
+
this.contentClass,
|
|
112
|
+
];
|
|
113
|
+
},
|
|
100
114
|
},
|
|
101
115
|
};
|
|
102
116
|
</script>
|
|
@@ -123,7 +137,7 @@ export default {
|
|
|
123
137
|
/>
|
|
124
138
|
</div>
|
|
125
139
|
</div>
|
|
126
|
-
<div :class="
|
|
140
|
+
<div :class="contentClasses" data-testid="gl-empty-state-content">
|
|
127
141
|
<div class="gl-mx-auto gl-my-0" :class="{ 'gl-p-5': !compact }">
|
|
128
142
|
<!--
|
|
129
143
|
@slot Use this slot to customize the empty state's title area.
|