@gitlab/ui 66.13.1 → 66.14.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/experimental/experiment_badge/experiment_badge.js +83 -0
- package/dist/index.js +1 -0
- package/dist/tokens/css/tokens.css +1 -1
- package/dist/tokens/css/tokens.dark.css +1 -1
- package/dist/tokens/js/tokens.dark.js +1 -1
- package/dist/tokens/js/tokens.js +1 -1
- package/dist/tokens/scss/_tokens.dark.scss +1 -1
- package/dist/tokens/scss/_tokens.scss +1 -1
- package/package.json +1 -1
- package/src/components/experimental/experiment_badge/experiment_badge.md +9 -0
- package/src/components/experimental/experiment_badge/experiment_badge.spec.js +66 -0
- package/src/components/experimental/experiment_badge/experiment_badge.stories.js +56 -0
- package/src/components/experimental/experiment_badge/experiment_badge.vue +84 -0
- package/src/index.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [66.14.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v66.13.1...v66.14.0) (2023-09-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **GlExperimentBadge:** Implement component ([de360ee](https://gitlab.com/gitlab-org/gitlab-ui/commit/de360eec00fb772cb3c10258f246975832d68f34))
|
|
7
|
+
|
|
1
8
|
## [66.13.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v66.13.0...v66.13.1) (2023-09-25)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import uniqueId from 'lodash/uniqueId';
|
|
2
|
+
import { GlBadge, GlPopover, GlLink } from '../../../index';
|
|
3
|
+
import GlSprintf from '../../utilities/sprintf/sprintf';
|
|
4
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
5
|
+
|
|
6
|
+
const i18n = {
|
|
7
|
+
EXPERIMENT_BADGE: 'Experiment',
|
|
8
|
+
EXPERIMENT_POPOVER_TITLE: "What's an Experiment?",
|
|
9
|
+
EXPERIMENT_POPOVER_CONTENT: "An %{linkStart}Experiment%{linkEnd} is a feature that's in the process of being developed. It's not production-ready. We encourage users to try Experimental features and provide feedback. An Experiment: %{bullets}",
|
|
10
|
+
EXPERIMENT_POPOVER_BULLETS: ['May be unstable', 'Has no support and might not be documented', 'Can be removed at any time']
|
|
11
|
+
};
|
|
12
|
+
var script = {
|
|
13
|
+
name: 'GlExperimentBadge',
|
|
14
|
+
i18n,
|
|
15
|
+
components: {
|
|
16
|
+
GlBadge,
|
|
17
|
+
GlPopover,
|
|
18
|
+
GlSprintf,
|
|
19
|
+
GlLink
|
|
20
|
+
},
|
|
21
|
+
props: {
|
|
22
|
+
/**
|
|
23
|
+
* The URL of a page to provide more explanations on the experiment.
|
|
24
|
+
*/
|
|
25
|
+
experimentHelpPageUrl: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: false,
|
|
28
|
+
default: ''
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* The placement of the popover in relation to the button.
|
|
32
|
+
*/
|
|
33
|
+
popoverPlacement: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: false,
|
|
36
|
+
default: 'bottom'
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
created() {
|
|
40
|
+
this.triggerId = uniqueId('experiment-badge-');
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/* script */
|
|
45
|
+
const __vue_script__ = script;
|
|
46
|
+
|
|
47
|
+
/* template */
|
|
48
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-badge',{staticClass:"gl-mx-4 gl-hover-cursor-pointer",attrs:{"id":_vm.triggerId,"variant":"neutral","size":"md"}},[_c('span',[_vm._v(_vm._s(_vm.$options.i18n.EXPERIMENT_BADGE))]),_vm._v(" "),_c('gl-popover',{attrs:{"triggers":"click","show-close-button":"","placement":_vm.popoverPlacement,"target":_vm.triggerId,"css-classes":['gl-z-index-9999!'],"title":_vm.$options.i18n.EXPERIMENT_POPOVER_TITLE}},[_c('gl-sprintf',{attrs:{"message":_vm.$options.i18n.EXPERIMENT_POPOVER_CONTENT},scopedSlots:_vm._u([{key:"link",fn:function(ref){
|
|
49
|
+
var content = ref.content;
|
|
50
|
+
return [(_vm.experimentHelpPageUrl)?_c('gl-link',{staticClass:"gl-font-sm!",attrs:{"href":_vm.experimentHelpPageUrl,"target":"_blank"}},[_vm._v("\n "+_vm._s(content)+"\n ")]):_c('span',[_vm._v(_vm._s(content))])]}},{key:"bullets",fn:function(){return [_c('ul',{staticClass:"gl-mb-0 gl-pl-5"},_vm._l((_vm.$options.i18n.EXPERIMENT_POPOVER_BULLETS),function(item,i){return _c('li',{key:("li-" + i)},[_vm._v("\n "+_vm._s(item)+"\n ")])}),0)]},proxy:true}])})],1)],1)};
|
|
51
|
+
var __vue_staticRenderFns__ = [];
|
|
52
|
+
|
|
53
|
+
/* style */
|
|
54
|
+
const __vue_inject_styles__ = undefined;
|
|
55
|
+
/* scoped */
|
|
56
|
+
const __vue_scope_id__ = undefined;
|
|
57
|
+
/* module identifier */
|
|
58
|
+
const __vue_module_identifier__ = undefined;
|
|
59
|
+
/* functional template */
|
|
60
|
+
const __vue_is_functional_template__ = false;
|
|
61
|
+
/* style inject */
|
|
62
|
+
|
|
63
|
+
/* style inject SSR */
|
|
64
|
+
|
|
65
|
+
/* style inject shadow dom */
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
const __vue_component__ = __vue_normalize__(
|
|
70
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
71
|
+
__vue_inject_styles__,
|
|
72
|
+
__vue_script__,
|
|
73
|
+
__vue_scope_id__,
|
|
74
|
+
__vue_is_functional_template__,
|
|
75
|
+
__vue_module_identifier__,
|
|
76
|
+
false,
|
|
77
|
+
undefined,
|
|
78
|
+
undefined,
|
|
79
|
+
undefined
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
export default __vue_component__;
|
|
83
|
+
export { i18n };
|
package/dist/index.js
CHANGED
|
@@ -86,6 +86,7 @@ export { default as GlAccordion } from './components/base/accordion/accordion';
|
|
|
86
86
|
export { default as GlAccordionItem } from './components/base/accordion/accordion_item';
|
|
87
87
|
export { default as GlCarousel } from './components/base/carousel/carousel';
|
|
88
88
|
export { default as GlCarouselSlide } from './components/base/carousel/carousel_slide';
|
|
89
|
+
export { default as GlExperimentBadge } from './components/experimental/experiment_badge/experiment_badge';
|
|
89
90
|
export { default as GlAnimatedNumber } from './components/utilities/animated_number/animated_number';
|
|
90
91
|
export { default as GlFriendlyWrap } from './components/utilities/friendly_wrap/friendly_wrap';
|
|
91
92
|
export { default as GlIntersperse } from './components/utilities/intersperse/intersperse';
|
package/dist/tokens/js/tokens.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The component is representing a badge, marking the experimental features.
|
|
2
|
+
It is supposed to be used with the AI experiments, and comes with a popover explaining
|
|
3
|
+
what experiment means.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<gl-experiment-badge experiment-help-page-url="https://gitlab.com" popover-placement="bottom" />
|
|
9
|
+
```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import GlBadge from '../../base/badge/badge.vue';
|
|
3
|
+
import GlPopover from '../../base/popover/popover.vue';
|
|
4
|
+
import GlLink from '../../base/link/link.vue';
|
|
5
|
+
import GlSprintf from '../../utilities/sprintf/sprintf.vue';
|
|
6
|
+
import GlExperimentBadge, { i18n } from './experiment_badge.vue';
|
|
7
|
+
|
|
8
|
+
jest.mock('lodash/uniqueId', () => () => 'fakeUniqueId');
|
|
9
|
+
|
|
10
|
+
describe('GlExperimentBadge', () => {
|
|
11
|
+
let wrapper;
|
|
12
|
+
|
|
13
|
+
const findBadge = () => wrapper.findComponent(GlBadge);
|
|
14
|
+
const findPopover = () => wrapper.findComponent(GlPopover);
|
|
15
|
+
const findHelpLink = () => wrapper.findComponent(GlLink);
|
|
16
|
+
|
|
17
|
+
const createComponent = (props = {}) => {
|
|
18
|
+
wrapper = shallowMount(GlExperimentBadge, {
|
|
19
|
+
propsData: {
|
|
20
|
+
...props,
|
|
21
|
+
},
|
|
22
|
+
stubs: {
|
|
23
|
+
GlSprintf,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
createComponent();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('renders main components', () => {
|
|
33
|
+
expect(findBadge().exists()).toBe(true);
|
|
34
|
+
expect(findPopover().exists()).toBe(true);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('sets correct props on the badge', () => {
|
|
38
|
+
const badgeType = 'neutral';
|
|
39
|
+
const badgeSize = 'md';
|
|
40
|
+
expect(findBadge().props('variant')).toBe(badgeType);
|
|
41
|
+
expect(findBadge().props('size')).toBe(badgeSize);
|
|
42
|
+
expect(findBadge().find('span').text()).toBe(i18n.EXPERIMENT_BADGE);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('sets correct props on the popover', () => {
|
|
46
|
+
expect(findPopover().props('triggers')).toBe('click');
|
|
47
|
+
expect(findPopover().props('title')).toBe(i18n.EXPERIMENT_POPOVER_TITLE);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('correctly sets the placement of the popover', () => {
|
|
51
|
+
const popoverPlacement = 'right';
|
|
52
|
+
createComponent({ popoverPlacement });
|
|
53
|
+
expect(findPopover().props('placement')).toBe(popoverPlacement);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('sets the link to the help page if passed', () => {
|
|
57
|
+
const experimentHelpPageUrl = 'https://gitlab.com';
|
|
58
|
+
createComponent({ experimentHelpPageUrl });
|
|
59
|
+
expect(findHelpLink().attributes('href')).toBe(experimentHelpPageUrl);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('generates the unique ID to connect the button and the popover', () => {
|
|
63
|
+
expect(findBadge().attributes('id')).toBe('fakeUniqueId');
|
|
64
|
+
expect(findPopover().attributes('target')).toBe('fakeUniqueId');
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import GlExperimentBadge from './experiment_badge.vue';
|
|
2
|
+
import readme from './experiment_badge.md';
|
|
3
|
+
|
|
4
|
+
const defaultValue = (prop) => GlExperimentBadge.props[prop].default;
|
|
5
|
+
|
|
6
|
+
const generateProps = ({
|
|
7
|
+
experimentHelpPageUrl = defaultValue('experimentHelpPageUrl'),
|
|
8
|
+
popoverPlacement = defaultValue('popoverPlacement'),
|
|
9
|
+
} = {}) => ({
|
|
10
|
+
experimentHelpPageUrl,
|
|
11
|
+
popoverPlacement,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const Template = (args, { argTypes }) => ({
|
|
15
|
+
components: { GlExperimentBadge },
|
|
16
|
+
props: Object.keys(argTypes),
|
|
17
|
+
template: `
|
|
18
|
+
<div class='gl-h-13'>
|
|
19
|
+
<gl-experiment-badge
|
|
20
|
+
:experiment-help-page-url='experimentHelpPageUrl'
|
|
21
|
+
:popover-placement='popoverPlacement' />
|
|
22
|
+
</div>
|
|
23
|
+
`,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const Default = Template.bind({});
|
|
27
|
+
Default.args = generateProps();
|
|
28
|
+
|
|
29
|
+
export const WithHelpPageUrl = Template.bind({});
|
|
30
|
+
WithHelpPageUrl.args = {
|
|
31
|
+
...generateProps({
|
|
32
|
+
experimentHelpPageUrl:
|
|
33
|
+
'https://docs.gitlab.com/ee/policy/experiment-beta-support.html#experiment',
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const CustomPlacement = Template.bind({});
|
|
38
|
+
CustomPlacement.args = {
|
|
39
|
+
...generateProps({
|
|
40
|
+
popoverPlacement: 'right',
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default {
|
|
45
|
+
title: 'experimental/experiment_badge',
|
|
46
|
+
component: GlExperimentBadge,
|
|
47
|
+
parameters: {
|
|
48
|
+
storyshots: { disable: true },
|
|
49
|
+
docs: {
|
|
50
|
+
description: {
|
|
51
|
+
component: readme,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
argTypes: {},
|
|
56
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import uniqueId from 'lodash/uniqueId';
|
|
3
|
+
import { GlBadge, GlLink, GlPopover } from '../../../index';
|
|
4
|
+
import GlSprintf from '../../utilities/sprintf/sprintf.vue';
|
|
5
|
+
|
|
6
|
+
export const i18n = {
|
|
7
|
+
EXPERIMENT_BADGE: 'Experiment',
|
|
8
|
+
EXPERIMENT_POPOVER_TITLE: "What's an Experiment?",
|
|
9
|
+
EXPERIMENT_POPOVER_CONTENT:
|
|
10
|
+
"An %{linkStart}Experiment%{linkEnd} is a feature that's in the process of being developed. It's not production-ready. We encourage users to try Experimental features and provide feedback. An Experiment: %{bullets}",
|
|
11
|
+
EXPERIMENT_POPOVER_BULLETS: [
|
|
12
|
+
'May be unstable',
|
|
13
|
+
'Has no support and might not be documented',
|
|
14
|
+
'Can be removed at any time',
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
name: 'GlExperimentBadge',
|
|
20
|
+
i18n,
|
|
21
|
+
components: {
|
|
22
|
+
GlBadge,
|
|
23
|
+
GlPopover,
|
|
24
|
+
GlSprintf,
|
|
25
|
+
GlLink,
|
|
26
|
+
},
|
|
27
|
+
props: {
|
|
28
|
+
/**
|
|
29
|
+
* The URL of a page to provide more explanations on the experiment.
|
|
30
|
+
*/
|
|
31
|
+
experimentHelpPageUrl: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: false,
|
|
34
|
+
default: '',
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* The placement of the popover in relation to the button.
|
|
38
|
+
*/
|
|
39
|
+
popoverPlacement: {
|
|
40
|
+
type: String,
|
|
41
|
+
required: false,
|
|
42
|
+
default: 'bottom',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
created() {
|
|
46
|
+
this.triggerId = uniqueId('experiment-badge-');
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<template>
|
|
52
|
+
<gl-badge :id="triggerId" class="gl-mx-4 gl-hover-cursor-pointer" variant="neutral" size="md">
|
|
53
|
+
<span>{{ $options.i18n.EXPERIMENT_BADGE }}</span>
|
|
54
|
+
<gl-popover
|
|
55
|
+
triggers="click"
|
|
56
|
+
show-close-button
|
|
57
|
+
:placement="popoverPlacement"
|
|
58
|
+
:target="triggerId"
|
|
59
|
+
:css-classes="['gl-z-index-9999!']"
|
|
60
|
+
:title="$options.i18n.EXPERIMENT_POPOVER_TITLE"
|
|
61
|
+
>
|
|
62
|
+
<gl-sprintf :message="$options.i18n.EXPERIMENT_POPOVER_CONTENT">
|
|
63
|
+
<template #link="{ content }">
|
|
64
|
+
<gl-link
|
|
65
|
+
v-if="experimentHelpPageUrl"
|
|
66
|
+
:href="experimentHelpPageUrl"
|
|
67
|
+
target="_blank"
|
|
68
|
+
class="gl-font-sm!"
|
|
69
|
+
>
|
|
70
|
+
{{ content }}
|
|
71
|
+
</gl-link>
|
|
72
|
+
<span v-else>{{ content }}</span>
|
|
73
|
+
</template>
|
|
74
|
+
<template #bullets>
|
|
75
|
+
<ul class="gl-mb-0 gl-pl-5">
|
|
76
|
+
<li v-for="(item, i) in $options.i18n.EXPERIMENT_POPOVER_BULLETS" :key="`li-${i}`">
|
|
77
|
+
{{ item }}
|
|
78
|
+
</li>
|
|
79
|
+
</ul>
|
|
80
|
+
</template>
|
|
81
|
+
</gl-sprintf>
|
|
82
|
+
</gl-popover>
|
|
83
|
+
</gl-badge>
|
|
84
|
+
</template>
|
package/src/index.js
CHANGED
|
@@ -96,6 +96,9 @@ export { default as GlAccordionItem } from './components/base/accordion/accordio
|
|
|
96
96
|
export { default as GlCarousel } from './components/base/carousel/carousel.vue';
|
|
97
97
|
export { default as GlCarouselSlide } from './components/base/carousel/carousel_slide.vue';
|
|
98
98
|
|
|
99
|
+
// Experimental
|
|
100
|
+
export { default as GlExperimentBadge } from './components/experimental/experiment_badge/experiment_badge.vue';
|
|
101
|
+
|
|
99
102
|
// Utilities
|
|
100
103
|
export { default as GlAnimatedNumber } from './components/utilities/animated_number/animated_number.vue';
|
|
101
104
|
export { default as GlFriendlyWrap } from './components/utilities/friendly_wrap/friendly_wrap.vue';
|