@gitlab/ui 32.43.3 → 32.46.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 +29 -0
- package/config.js +15 -3
- package/dist/components/base/avatar/avatar.documentation.js +2 -5
- package/dist/components/base/avatar_link/avatar_link.documentation.js +2 -5
- package/dist/components/base/form/form_group/form_group.js +11 -1
- package/dist/components/base/form/form_input/form_input.documentation.js +2 -27
- package/dist/components/base/form/form_input/form_input.js +23 -6
- package/dist/components/base/form/form_text/form_text.documentation.js +1 -4
- package/dist/components/base/label/label.documentation.js +2 -9
- package/dist/components/base/label/label.js +23 -1
- package/dist/components/base/pagination/pagination.documentation.js +2 -85
- package/dist/components/base/pagination/pagination.js +76 -0
- package/dist/components/base/segmented_control/segmented_control.documentation.js +2 -14
- package/dist/components/base/segmented_control/segmented_control.js +6 -0
- package/dist/components/base/skeleton_loader/skeleton_loader.documentation.js +2 -28
- package/dist/components/base/skeleton_loader/skeleton_loader.js +30 -0
- package/dist/components/charts/chart/chart.js +17 -4
- package/dist/components/charts/discrete_scatter/discrete_scatter.documentation.js +1 -7
- package/dist/components/charts/heatmap/heatmap.js +1 -9
- package/dist/components/charts/sparkline/sparkline.js +1 -1
- package/dist/components/charts/stacked_column/stacked_column.documentation.js +2 -5
- package/dist/config.js +15 -3
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/documentation/documented_stories.js +9 -0
- package/package.json +11 -10
- package/src/components/base/alert/alert.spec.js +2 -2
- package/src/components/base/avatar/avatar.documentation.js +0 -2
- package/src/components/base/avatar/avatar.md +0 -2
- package/src/components/base/avatar/avatar.spec.js +1 -2
- package/src/components/base/avatar/avatar.stories.js +88 -101
- package/src/components/base/avatar_link/avatar_link.documentation.js +0 -2
- package/src/components/base/avatar_link/avatar_link.md +4 -7
- package/src/components/base/avatar_link/avatar_link.stories.js +66 -54
- package/src/components/base/filtered_search/filtered_search.spec.js +35 -35
- package/src/components/base/filtered_search/filtered_search_term.spec.js +1 -1
- package/src/components/base/form/form_group/form_group.scss +4 -0
- package/src/components/base/form/form_group/form_group.spec.js +66 -64
- package/src/components/base/form/form_group/form_group.stories.js +36 -13
- package/src/components/base/form/form_group/form_group.vue +15 -2
- package/src/components/base/form/form_input/form_input.documentation.js +0 -31
- package/src/components/base/form/form_input/form_input.md +0 -2
- package/src/components/base/form/form_input/form_input.stories.js +50 -42
- package/src/components/base/form/form_input/form_input.vue +23 -6
- package/src/components/base/form/form_input_group/form_input_group.spec.js +1 -3
- package/src/components/base/form/form_text/form_text.documentation.js +0 -2
- package/src/components/base/form/form_text/form_text.md +1 -3
- package/src/components/base/form/form_text/form_text.stories.js +20 -8
- package/src/components/base/icon/icon.spec.js +1 -4
- package/src/components/base/infinite_scroll/infinite_scroll.spec.js +1 -4
- package/src/components/base/label/label.documentation.js +2 -12
- package/src/components/base/label/label.md +2 -7
- package/src/components/base/label/label.stories.js +66 -92
- package/src/components/base/label/label.vue +22 -2
- package/src/components/base/modal/modal.spec.js +19 -23
- package/src/components/base/paginated_list/__snapshots__/paginated_list.spec.js.snap +10 -10
- package/src/components/base/pagination/pagination.documentation.js +0 -100
- package/src/components/base/pagination/pagination.md +5 -9
- package/src/components/base/pagination/pagination.spec.js +1 -4
- package/src/components/base/pagination/pagination.stories.js +109 -117
- package/src/components/base/pagination/pagination.vue +85 -0
- package/src/components/base/search_box_by_click/search_box_by_click.spec.js +1 -5
- package/src/components/base/segmented_control/segmented_control.documentation.js +0 -15
- package/src/components/base/segmented_control/segmented_control.md +0 -2
- package/src/components/base/segmented_control/segmented_control.stories.js +46 -36
- package/src/components/base/segmented_control/segmented_control.vue +5 -0
- package/src/components/base/skeleton_loader/skeleton_loader.documentation.js +0 -27
- package/src/components/base/skeleton_loader/skeleton_loader.md +0 -2
- package/src/components/base/skeleton_loader/skeleton_loader.stories.js +23 -9
- package/src/components/base/skeleton_loader/skeleton_loader.vue +24 -0
- package/src/components/base/sorting/sorting.spec.js +1 -4
- package/src/components/base/toast/toast.spec.js +4 -6
- package/src/components/base/token/token.spec.js +1 -4
- package/src/components/base/token_selector/token_container.spec.js +2 -3
- package/src/components/charts/chart/chart.spec.js +33 -4
- package/src/components/charts/chart/chart.vue +16 -4
- package/src/components/charts/discrete_scatter/discrete_scatter.documentation.js +0 -5
- package/src/components/charts/discrete_scatter/discrete_scatter.stories.js +34 -46
- package/src/components/charts/gauge/gauge.spec.js +7 -7
- package/src/components/charts/heatmap/heatmap.vue +2 -9
- package/src/components/charts/sparkline/sparkline.spec.js +1 -4
- package/src/components/charts/sparkline/sparkline.vue +7 -1
- package/src/components/charts/stacked_column/stacked_column.documentation.js +0 -2
- package/src/components/charts/stacked_column/stacked_column.md +0 -2
- package/src/components/charts/stacked_column/stacked_column.stories.js +74 -99
- package/src/components/utilities/friendly_wrap/friendly_wrap.spec.js +1 -4
- package/src/components/utilities/intersperse/intersperse.spec.js +1 -4
- package/src/directives/hover_load/hover_load.spec.js +2 -13
- package/src/directives/outside/outside.spec.js +1 -6
- package/src/directives/resize_observer/resize_observer.spec.js +4 -10
- package/src/scss/storybook.scss +8 -0
- package/src/scss/utilities.scss +8 -0
- package/src/scss/utility-mixins/transform.scss +4 -0
- package/dist/components/base/avatar/examples/avatar.fallback.example.js +0 -38
- package/dist/components/base/avatar/examples/avatar.image.example.js +0 -38
- package/dist/components/base/avatar/examples/avatar.rect.example.js +0 -38
- package/dist/components/base/avatar/examples/avatar.tooltip.example.js +0 -38
- package/dist/components/base/avatar/examples/index.js +0 -31
- package/dist/components/base/avatar_link/examples/avatar.link.example.js +0 -38
- package/dist/components/base/avatar_link/examples/index.js +0 -13
- package/dist/components/base/form/form_input/examples/form_input/form_input.text.example.js +0 -38
- package/dist/components/base/form/form_input/examples/form_input/form_input.text_disabled.example.js +0 -38
- package/dist/components/base/form/form_input/examples/form_input/form_input.text_reactive.example.js +0 -57
- package/dist/components/base/form/form_input/examples/form_input/index.js +0 -22
- package/dist/components/base/form/form_text/examples/form_text.basic.example.js +0 -38
- package/dist/components/base/form/form_text/examples/index.js +0 -13
- package/dist/components/base/label/examples/index.js +0 -19
- package/dist/components/base/label/examples/label.basic.example.js +0 -38
- package/dist/components/base/label/examples/label.scoped.example.js +0 -38
- package/dist/components/base/pagination/examples/index.js +0 -37
- package/dist/components/base/pagination/examples/pagination.basic.example.js +0 -45
- package/dist/components/base/pagination/examples/pagination.compact.example.js +0 -58
- package/dist/components/base/pagination/examples/pagination.double_truncation.example.js +0 -45
- package/dist/components/base/pagination/examples/pagination.event.example.js +0 -51
- package/dist/components/base/pagination/examples/pagination.links.example.js +0 -45
- package/dist/components/base/segmented_control/examples/index.js +0 -19
- package/dist/components/base/segmented_control/examples/segmented_control.basic.example.js +0 -65
- package/dist/components/base/segmented_control/examples/segmented_control.whitespace.example.js +0 -55
- package/dist/components/base/skeleton_loader/examples/ci_header_skeleton.basic.example.js +0 -38
- package/dist/components/base/skeleton_loader/examples/default_skeleton.basic.example.js +0 -38
- package/dist/components/base/skeleton_loader/examples/default_skeleton_custom_props.basic.example.js +0 -38
- package/dist/components/base/skeleton_loader/examples/index.js +0 -37
- package/dist/components/base/skeleton_loader/examples/issue_card_skeleton.basic.example.js +0 -38
- package/dist/components/base/skeleton_loader/examples/job_log_skeleton.basic.example.js +0 -38
- package/dist/components/charts/discrete_scatter/examples/discrete_scatter.basic.example.js +0 -51
- package/dist/components/charts/discrete_scatter/examples/index.js +0 -13
- package/dist/components/charts/stacked_column/examples/index.js +0 -13
- package/dist/components/charts/stacked_column/examples/stacked_column.basic.example.js +0 -46
- package/src/components/base/avatar/examples/avatar.fallback.example.vue +0 -3
- package/src/components/base/avatar/examples/avatar.image.example.vue +0 -3
- package/src/components/base/avatar/examples/avatar.rect.example.vue +0 -6
- package/src/components/base/avatar/examples/avatar.tooltip.example.vue +0 -3
- package/src/components/base/avatar/examples/index.js +0 -36
- package/src/components/base/avatar_link/examples/avatar.link.example.vue +0 -5
- package/src/components/base/avatar_link/examples/index.js +0 -15
- package/src/components/base/form/form_input/examples/form_input/form_input.text.example.vue +0 -3
- package/src/components/base/form/form_input/examples/form_input/form_input.text_disabled.example.vue +0 -3
- package/src/components/base/form/form_input/examples/form_input/form_input.text_reactive.example.vue +0 -24
- package/src/components/base/form/form_input/examples/form_input/index.js +0 -26
- package/src/components/base/form/form_text/examples/form_text.basic.example.vue +0 -5
- package/src/components/base/form/form_text/examples/index.js +0 -15
- package/src/components/base/label/examples/index.js +0 -22
- package/src/components/base/label/examples/label.basic.example.vue +0 -3
- package/src/components/base/label/examples/label.scoped.example.vue +0 -3
- package/src/components/base/pagination/examples/index.js +0 -43
- package/src/components/base/pagination/examples/pagination.basic.example.vue +0 -17
- package/src/components/base/pagination/examples/pagination.compact.example.vue +0 -33
- package/src/components/base/pagination/examples/pagination.double_truncation.example.vue +0 -11
- package/src/components/base/pagination/examples/pagination.event.example.vue +0 -26
- package/src/components/base/pagination/examples/pagination.links.example.vue +0 -18
- package/src/components/base/segmented_control/examples/index.js +0 -22
- package/src/components/base/segmented_control/examples/segmented_control.basic.example.vue +0 -19
- package/src/components/base/segmented_control/examples/segmented_control.whitespace.example.vue +0 -18
- package/src/components/base/skeleton_loader/examples/ci_header_skeleton.basic.example.vue +0 -10
- package/src/components/base/skeleton_loader/examples/default_skeleton.basic.example.vue +0 -3
- package/src/components/base/skeleton_loader/examples/default_skeleton_custom_props.basic.example.vue +0 -9
- package/src/components/base/skeleton_loader/examples/index.js +0 -44
- package/src/components/base/skeleton_loader/examples/issue_card_skeleton.basic.example.vue +0 -26
- package/src/components/base/skeleton_loader/examples/job_log_skeleton.basic.example.vue +0 -13
- package/src/components/charts/discrete_scatter/discrete_scatter.md +0 -1
- package/src/components/charts/discrete_scatter/examples/discrete_scatter.basic.example.vue +0 -31
- package/src/components/charts/discrete_scatter/examples/index.js +0 -15
- package/src/components/charts/stacked_column/examples/index.js +0 -15
- package/src/components/charts/stacked_column/examples/stacked_column.basic.example.vue +0 -18
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { withKnobs, boolean, select, text } from '@storybook/addon-knobs';
|
|
2
|
-
import { documentedStoriesOf } from '../../../../../documentation/documented_stories';
|
|
3
1
|
import { GlFormInput } from '../../../../../index';
|
|
4
2
|
import { formInputSizes } from '../../../../utils/constants';
|
|
5
3
|
import readme from './form_input.md';
|
|
6
4
|
|
|
7
|
-
const components = {
|
|
8
|
-
GlFormInput,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
5
|
const template = `
|
|
12
6
|
<gl-form-input
|
|
13
7
|
type="text"
|
|
@@ -16,51 +10,65 @@ const template = `
|
|
|
16
10
|
:size="size"
|
|
17
11
|
/>`;
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
const generateProps = ({
|
|
20
14
|
size = GlFormInput.props.size.default,
|
|
21
15
|
value = '',
|
|
22
16
|
disabled = false,
|
|
23
|
-
} = {}) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
type: Boolean,
|
|
35
|
-
default: boolean('disabled', disabled),
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
17
|
+
} = {}) => ({
|
|
18
|
+
size,
|
|
19
|
+
value,
|
|
20
|
+
disabled,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const Template = (args) => ({
|
|
24
|
+
components: { GlFormInput },
|
|
25
|
+
props: Object.keys(args),
|
|
26
|
+
template,
|
|
27
|
+
});
|
|
39
28
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
components,
|
|
54
|
-
data: () => ({
|
|
55
|
-
formInputSizes,
|
|
56
|
-
}),
|
|
57
|
-
template: `
|
|
29
|
+
export const Default = Template.bind({});
|
|
30
|
+
Default.args = generateProps();
|
|
31
|
+
|
|
32
|
+
export const Disabled = Template.bind({});
|
|
33
|
+
Disabled.args = generateProps({ value: 'some text', disabled: true });
|
|
34
|
+
|
|
35
|
+
export const Sizes = (args, { argTypes }) => ({
|
|
36
|
+
components: { GlFormInput },
|
|
37
|
+
props: Object.keys(argTypes),
|
|
38
|
+
data: () => ({
|
|
39
|
+
formInputSizes,
|
|
40
|
+
}),
|
|
41
|
+
template: `
|
|
58
42
|
<div>
|
|
59
43
|
<gl-form-input
|
|
60
44
|
v-for="(size, name) in formInputSizes"
|
|
45
|
+
:key="size"
|
|
61
46
|
:size="size"
|
|
62
47
|
:value="name"
|
|
63
48
|
/>
|
|
64
49
|
</div>
|
|
65
50
|
`,
|
|
66
|
-
|
|
51
|
+
});
|
|
52
|
+
Sizes.args = {};
|
|
53
|
+
|
|
54
|
+
export default {
|
|
55
|
+
title: 'base/form/form-input',
|
|
56
|
+
component: GlFormInput,
|
|
57
|
+
parameters: {
|
|
58
|
+
bootstrapComponent: 'b-form-input',
|
|
59
|
+
knobs: { disable: true },
|
|
60
|
+
docs: {
|
|
61
|
+
description: {
|
|
62
|
+
component: readme,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
argTypes: {
|
|
67
|
+
size: {
|
|
68
|
+
options: formInputSizes,
|
|
69
|
+
control: {
|
|
70
|
+
type: 'select',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
import { BFormInput } from 'bootstrap-vue';
|
|
3
3
|
import { formInputSizes } from '../../../../utils/constants';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
event: 'input',
|
|
8
|
-
};
|
|
5
|
+
const MODEL_PROP = 'value';
|
|
6
|
+
const MODEL_EVENT = 'input';
|
|
9
7
|
|
|
10
8
|
export default {
|
|
11
9
|
components: {
|
|
12
10
|
BFormInput,
|
|
13
11
|
},
|
|
14
12
|
inheritAttrs: false,
|
|
15
|
-
model
|
|
13
|
+
model: {
|
|
14
|
+
prop: MODEL_PROP,
|
|
15
|
+
event: MODEL_EVENT,
|
|
16
|
+
},
|
|
16
17
|
props: {
|
|
18
|
+
/**
|
|
19
|
+
* Maximum width of the input
|
|
20
|
+
*/
|
|
17
21
|
size: {
|
|
18
22
|
type: String,
|
|
19
23
|
required: false,
|
|
@@ -33,10 +37,23 @@ export default {
|
|
|
33
37
|
// Swap purpose of input and update events from underlying BFormInput.
|
|
34
38
|
// See https://gitlab.com/gitlab-org/gitlab-ui/-/issues/631.
|
|
35
39
|
input: (...args) => {
|
|
40
|
+
/**
|
|
41
|
+
* Emitted to update the v-model
|
|
42
|
+
*
|
|
43
|
+
* @event update
|
|
44
|
+
* @property {string} value new value
|
|
45
|
+
*/
|
|
36
46
|
this.$emit('update', ...args);
|
|
37
47
|
},
|
|
38
48
|
update: (...args) => {
|
|
39
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Triggered by user interaction. Emitted after any formatting (not including 'trim' or 'number' props).
|
|
51
|
+
* Useful for getting the currently entered value when the 'debounce' or 'lazy' props are set.
|
|
52
|
+
*
|
|
53
|
+
* @event input
|
|
54
|
+
* @property {string} value new value
|
|
55
|
+
*/
|
|
56
|
+
this.$emit(MODEL_EVENT, ...args);
|
|
40
57
|
},
|
|
41
58
|
};
|
|
42
59
|
},
|
|
@@ -15,7 +15,7 @@ describe('Input Group', () => {
|
|
|
15
15
|
it('renders without errors', () => {
|
|
16
16
|
createWrapper();
|
|
17
17
|
expect(wrapper.findComponent(BInputGroup).exists()).toBe(true);
|
|
18
|
-
expect(
|
|
18
|
+
expect(wrapper).not.toHaveLoggedVueErrors();
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
it('renders prepend and append texts properly in the slots', () => {
|
|
@@ -87,8 +87,6 @@ describe('Input Group', () => {
|
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
expect(global.console).toHaveLoggedVueErrors();
|
|
90
|
-
|
|
91
|
-
global.console.error.mockReset();
|
|
92
90
|
});
|
|
93
91
|
|
|
94
92
|
it('are rendered when supplied', () => {
|
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import { documentedStoriesOf } from '../../../../../documentation/documented_stories';
|
|
2
1
|
import readme from './form_text.md';
|
|
3
2
|
import GlFormText from './form_text.vue';
|
|
4
3
|
|
|
5
|
-
const
|
|
6
|
-
GlFormText,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
documentedStoriesOf('base/form/form-text', readme).add('default', () => ({
|
|
10
|
-
components,
|
|
4
|
+
const Template = (args) => ({
|
|
5
|
+
components: { GlFormText },
|
|
6
|
+
props: Object.keys(args),
|
|
11
7
|
template: `
|
|
12
8
|
<div class="gl-form-group">
|
|
13
9
|
<gl-form-text>Some form text</gl-form-text>
|
|
14
10
|
</div>
|
|
15
11
|
`,
|
|
16
|
-
})
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const Default = Template.bind({});
|
|
15
|
+
Default.args = {};
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
title: 'base/form/form-text',
|
|
19
|
+
component: GlFormText,
|
|
20
|
+
parameters: {
|
|
21
|
+
knobs: { disable: true },
|
|
22
|
+
docs: {
|
|
23
|
+
description: {
|
|
24
|
+
component: readme,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { shallowMount
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
2
|
import Icon from './icon.vue';
|
|
3
3
|
import { iconSizeOptions } from '~/utils/constants';
|
|
4
4
|
|
|
@@ -6,8 +6,6 @@ const ICONS_PATH = '/path/to/icons.svg';
|
|
|
6
6
|
const TEST_SIZE = 8;
|
|
7
7
|
const TEST_NAME = 'check-circle';
|
|
8
8
|
|
|
9
|
-
const localVue = createLocalVue();
|
|
10
|
-
|
|
11
9
|
jest.mock('@gitlab/svgs/dist/icons.svg', () => '/path/to/icons.svg');
|
|
12
10
|
|
|
13
11
|
describe('Icon component', () => {
|
|
@@ -21,7 +19,6 @@ describe('Icon component', () => {
|
|
|
21
19
|
name: TEST_NAME,
|
|
22
20
|
...props,
|
|
23
21
|
},
|
|
24
|
-
localVue,
|
|
25
22
|
});
|
|
26
23
|
};
|
|
27
24
|
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { shallowMount
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
2
|
import throttle from 'lodash/throttle';
|
|
3
3
|
import InfiniteScroll, { adjustScrollGap } from './infinite_scroll.vue';
|
|
4
4
|
|
|
5
5
|
jest.mock('lodash/throttle', () => jest.fn((fn) => fn));
|
|
6
6
|
|
|
7
|
-
const localVue = createLocalVue();
|
|
8
|
-
|
|
9
7
|
const INITIAL_HEIGHT = 500;
|
|
10
8
|
const INITIAL_SCROLL_TOP = 0;
|
|
11
9
|
const ADJUST_SCROLL_GAP = adjustScrollGap;
|
|
@@ -25,7 +23,6 @@ describe('Infinite Scroll component', () => {
|
|
|
25
23
|
|
|
26
24
|
const createComponent = ({ propsData = props, listeners = {} } = {}) => {
|
|
27
25
|
wrapper = shallowMount(InfiniteScroll, {
|
|
28
|
-
localVue,
|
|
29
26
|
propsData,
|
|
30
27
|
listeners,
|
|
31
28
|
attachTo: document.body,
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import description from './label.vue';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
followsDesignSystem: true,
|
|
5
|
-
|
|
6
|
-
events: [
|
|
7
|
-
{
|
|
8
|
-
event: 'click',
|
|
9
|
-
description: 'Emitted when label is clicked',
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
event: 'close',
|
|
13
|
-
description: 'Emitted when x is clicked',
|
|
14
|
-
},
|
|
15
|
-
],
|
|
5
|
+
description,
|
|
16
6
|
};
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
# Label
|
|
2
|
-
|
|
3
|
-
<!-- STORY -->
|
|
4
|
-
## Usage
|
|
5
|
-
|
|
6
1
|
Labels are editable objects that allow users to manually categorize other objects, like issues,
|
|
7
2
|
merge requests, and epics. They have a name, description, and a customizable background color.
|
|
8
3
|
They provide a quick way to recognize which categories the labeled object belongs to.
|
|
9
4
|
|
|
10
5
|
## Using the component
|
|
11
6
|
|
|
12
|
-
|
|
7
|
+
```js
|
|
13
8
|
<gl-label
|
|
14
9
|
background-color="#D9C2EE"
|
|
15
10
|
title="Label content"
|
|
@@ -18,4 +13,4 @@ They provide a quick way to recognize which categories the labeled object belong
|
|
|
18
13
|
tooltipPlacement="top"
|
|
19
14
|
target="http://some.url"
|
|
20
15
|
/>
|
|
21
|
-
|
|
16
|
+
```
|
|
@@ -1,110 +1,84 @@
|
|
|
1
|
-
import { withKnobs, text, color, select, boolean } from '@storybook/addon-knobs';
|
|
2
|
-
import { documentedStoriesOf } from '../../../../documentation/documented_stories';
|
|
3
1
|
import { GlLabel } from '../../../../index';
|
|
4
2
|
import { labelSizeOptions, tooltipPlacements } from '../../../utils/constants';
|
|
5
3
|
import readme from './label.md';
|
|
6
4
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const template = `
|
|
6
|
+
<div class="gl-display-flex">
|
|
7
|
+
<gl-label
|
|
8
|
+
:background-color="backgroundColor"
|
|
9
|
+
:size="size"
|
|
10
|
+
:title="title"
|
|
11
|
+
:description="description"
|
|
12
|
+
:tooltip-placement="tooltipPlacement"
|
|
13
|
+
:target="target"
|
|
14
|
+
:scoped="scoped"
|
|
15
|
+
:show-close-button="showCloseButton"
|
|
16
|
+
:disabled="disabled"
|
|
17
|
+
/>
|
|
18
|
+
</div>`;
|
|
19
|
+
|
|
20
|
+
const Template = (args, { argTypes }) => ({
|
|
21
|
+
components: { GlLabel },
|
|
22
|
+
props: Object.keys(argTypes),
|
|
23
|
+
template,
|
|
24
|
+
});
|
|
10
25
|
|
|
11
26
|
const generateProps = ({
|
|
12
27
|
title = 'Label title',
|
|
13
28
|
size = labelSizeOptions.default,
|
|
14
29
|
tooltipPlacement = tooltipPlacements.top,
|
|
15
30
|
scoped = false,
|
|
31
|
+
description = '',
|
|
32
|
+
target = '#',
|
|
33
|
+
backgroundColor = '#D9C2EE',
|
|
16
34
|
showCloseButton = false,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
35
|
+
disabled = false,
|
|
36
|
+
} = {}) => ({
|
|
37
|
+
backgroundColor,
|
|
38
|
+
title,
|
|
39
|
+
description,
|
|
40
|
+
size,
|
|
41
|
+
tooltipPlacement,
|
|
42
|
+
target,
|
|
43
|
+
scoped,
|
|
44
|
+
showCloseButton,
|
|
45
|
+
disabled,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export const Default = Template.bind({});
|
|
49
|
+
Default.args = generateProps();
|
|
50
|
+
|
|
51
|
+
export const Scoped = Template.bind({});
|
|
52
|
+
Scoped.args = generateProps({ title: 'scoped::label', scoped: true });
|
|
53
|
+
|
|
54
|
+
export const WithCloseButton = Template.bind({});
|
|
55
|
+
WithCloseButton.args = generateProps({ showCloseButton: true });
|
|
56
|
+
|
|
57
|
+
export default {
|
|
58
|
+
title: 'base/label',
|
|
59
|
+
component: GlLabel,
|
|
60
|
+
parameters: {
|
|
61
|
+
knobs: { disable: true },
|
|
62
|
+
docs: {
|
|
63
|
+
description: {
|
|
64
|
+
component: readme,
|
|
65
|
+
},
|
|
24
66
|
},
|
|
25
|
-
|
|
26
|
-
|
|
67
|
+
},
|
|
68
|
+
argTypes: {
|
|
69
|
+
backgroundColor: {
|
|
70
|
+
control: {
|
|
71
|
+
type: 'color',
|
|
72
|
+
},
|
|
27
73
|
},
|
|
28
74
|
size: {
|
|
29
|
-
|
|
30
|
-
default: select('Size', labelSizeOptions, size),
|
|
75
|
+
options: labelSizeOptions,
|
|
31
76
|
},
|
|
32
77
|
tooltipPlacement: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
default: text('Link to label target', '#'),
|
|
38
|
-
},
|
|
39
|
-
scoped: {
|
|
40
|
-
default: boolean('Label is scoped', scoped),
|
|
41
|
-
},
|
|
42
|
-
showCloseButton: {
|
|
43
|
-
default: boolean('Show close button', showCloseButton),
|
|
78
|
+
options: tooltipPlacements,
|
|
79
|
+
control: {
|
|
80
|
+
type: 'select',
|
|
81
|
+
},
|
|
44
82
|
},
|
|
45
|
-
|
|
46
|
-
default: boolean('Close button disabled', false),
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return props;
|
|
83
|
+
},
|
|
51
84
|
};
|
|
52
|
-
|
|
53
|
-
documentedStoriesOf('base/label', readme)
|
|
54
|
-
.addDecorator(withKnobs)
|
|
55
|
-
.add('default', () => ({
|
|
56
|
-
props: generateProps(),
|
|
57
|
-
components,
|
|
58
|
-
template: `
|
|
59
|
-
<div class="gl-display-flex">
|
|
60
|
-
<gl-label
|
|
61
|
-
:background-color="backgroundColor"
|
|
62
|
-
:size="size"
|
|
63
|
-
:title="title"
|
|
64
|
-
:description="description"
|
|
65
|
-
:tooltip-placement="tooltipPlacement"
|
|
66
|
-
:target="target"
|
|
67
|
-
:scoped="scoped"
|
|
68
|
-
:show-close-button="showCloseButton"
|
|
69
|
-
:disabled="disabled"
|
|
70
|
-
/>
|
|
71
|
-
</div>`,
|
|
72
|
-
}))
|
|
73
|
-
.add('scoped', () => ({
|
|
74
|
-
props: generateProps({ title: 'scoped::label', scoped: true }),
|
|
75
|
-
components,
|
|
76
|
-
template: `
|
|
77
|
-
<div class="gl-display-flex">
|
|
78
|
-
<gl-label
|
|
79
|
-
:background-color="backgroundColor"
|
|
80
|
-
:size="size"
|
|
81
|
-
:title="title"
|
|
82
|
-
:description="description"
|
|
83
|
-
:tooltip-placement="tooltipPlacement"
|
|
84
|
-
:target="target"
|
|
85
|
-
:scoped="scoped"
|
|
86
|
-
:show-close-button="showCloseButton"
|
|
87
|
-
:disabled="disabled"
|
|
88
|
-
/>
|
|
89
|
-
</div>
|
|
90
|
-
`,
|
|
91
|
-
}))
|
|
92
|
-
.add('with close button', () => ({
|
|
93
|
-
props: generateProps({ showCloseButton: true }),
|
|
94
|
-
components,
|
|
95
|
-
template: `
|
|
96
|
-
<div class="gl-display-flex">
|
|
97
|
-
<gl-label
|
|
98
|
-
:background-color="backgroundColor"
|
|
99
|
-
:size="size"
|
|
100
|
-
:title="title"
|
|
101
|
-
:description="description"
|
|
102
|
-
:tooltip-placement="tooltipPlacement"
|
|
103
|
-
:target="target"
|
|
104
|
-
:scoped="scoped"
|
|
105
|
-
:show-close-button="showCloseButton"
|
|
106
|
-
:disabled="disabled"
|
|
107
|
-
/>
|
|
108
|
-
</div>
|
|
109
|
-
`,
|
|
110
|
-
}));
|
|
@@ -96,6 +96,26 @@ export default {
|
|
|
96
96
|
this.splitScopedLabelIndex = this.title.lastIndexOf('::');
|
|
97
97
|
},
|
|
98
98
|
},
|
|
99
|
+
methods: {
|
|
100
|
+
onClick(e) {
|
|
101
|
+
/**
|
|
102
|
+
* Emitted when label is clicked
|
|
103
|
+
*
|
|
104
|
+
* @event click
|
|
105
|
+
* @type {object}
|
|
106
|
+
*/
|
|
107
|
+
this.$emit('click', e);
|
|
108
|
+
},
|
|
109
|
+
onClose(e) {
|
|
110
|
+
/**
|
|
111
|
+
* Emitted when x is clicked
|
|
112
|
+
*
|
|
113
|
+
* @event close
|
|
114
|
+
* @type {object}
|
|
115
|
+
*/
|
|
116
|
+
this.$emit('close', e);
|
|
117
|
+
},
|
|
118
|
+
},
|
|
99
119
|
};
|
|
100
120
|
</script>
|
|
101
121
|
|
|
@@ -106,7 +126,7 @@ export default {
|
|
|
106
126
|
:class="cssClasses"
|
|
107
127
|
:style="cssVariables"
|
|
108
128
|
v-bind="$attrs"
|
|
109
|
-
@click="
|
|
129
|
+
@click="onClick"
|
|
110
130
|
>
|
|
111
131
|
<gl-link :href="target" class="gl-label-link">
|
|
112
132
|
<span class="gl-label-text">
|
|
@@ -122,7 +142,7 @@ export default {
|
|
|
122
142
|
label="Remove label"
|
|
123
143
|
variant="reset"
|
|
124
144
|
:disabled="disabled"
|
|
125
|
-
@click="
|
|
145
|
+
@click="onClose"
|
|
126
146
|
/>
|
|
127
147
|
<gl-tooltip
|
|
128
148
|
v-if="description"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { shallowMount
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
2
|
import { BModal } from 'bootstrap-vue';
|
|
3
3
|
import { merge } from 'lodash';
|
|
4
4
|
import CloseButton from '../../shared_components/close_button/close_button.vue';
|
|
@@ -6,23 +6,20 @@ import Button from '../button/button.vue';
|
|
|
6
6
|
import Modal from './modal.vue';
|
|
7
7
|
import { modalButtonDefaults } from '~/utils/constants';
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
})
|
|
25
|
-
);
|
|
9
|
+
const BModalStub = merge({}, BModal.options, {
|
|
10
|
+
methods: {
|
|
11
|
+
onCancel: jest.fn(function cancel() {
|
|
12
|
+
this.$emit('cancel');
|
|
13
|
+
}),
|
|
14
|
+
onClose: jest.fn(),
|
|
15
|
+
onOk: jest.fn(function ok() {
|
|
16
|
+
this.$emit('ok');
|
|
17
|
+
}),
|
|
18
|
+
},
|
|
19
|
+
render(h) {
|
|
20
|
+
return h('div', Object.values(this.$slots));
|
|
21
|
+
},
|
|
22
|
+
});
|
|
26
23
|
|
|
27
24
|
describe('Modal component', () => {
|
|
28
25
|
let wrapperListeners;
|
|
@@ -45,7 +42,6 @@ describe('Modal component', () => {
|
|
|
45
42
|
};
|
|
46
43
|
|
|
47
44
|
wrapper = shallowMount(Modal, {
|
|
48
|
-
localVue,
|
|
49
45
|
propsData: {
|
|
50
46
|
modalId: 'modal-id',
|
|
51
47
|
...props,
|
|
@@ -158,7 +154,7 @@ describe('Modal component', () => {
|
|
|
158
154
|
});
|
|
159
155
|
|
|
160
156
|
it('should emit canceled event', () => {
|
|
161
|
-
expect(BModalStub.
|
|
157
|
+
expect(BModalStub.methods.onCancel).toHaveBeenCalledTimes(1);
|
|
162
158
|
expect(wrapperListeners.canceled).toHaveBeenCalledTimes(1);
|
|
163
159
|
});
|
|
164
160
|
});
|
|
@@ -169,7 +165,7 @@ describe('Modal component', () => {
|
|
|
169
165
|
});
|
|
170
166
|
|
|
171
167
|
it('should emit primary event', () => {
|
|
172
|
-
expect(BModalStub.
|
|
168
|
+
expect(BModalStub.methods.onOk).toHaveBeenCalledTimes(1);
|
|
173
169
|
expect(wrapperListeners.primary).toHaveBeenCalledTimes(1);
|
|
174
170
|
});
|
|
175
171
|
});
|
|
@@ -184,7 +180,7 @@ describe('Modal component', () => {
|
|
|
184
180
|
});
|
|
185
181
|
|
|
186
182
|
it('should close modal', () => {
|
|
187
|
-
expect(BModalStub.
|
|
183
|
+
expect(BModalStub.methods.onClose).toHaveBeenCalledTimes(1);
|
|
188
184
|
});
|
|
189
185
|
});
|
|
190
186
|
|
|
@@ -198,7 +194,7 @@ describe('Modal component', () => {
|
|
|
198
194
|
});
|
|
199
195
|
|
|
200
196
|
it('should close modal', () => {
|
|
201
|
-
expect(BModalStub.
|
|
197
|
+
expect(BModalStub.methods.onClose).not.toHaveBeenCalled();
|
|
202
198
|
});
|
|
203
199
|
});
|
|
204
200
|
});
|