@gitlab/ui 80.13.1 → 80.13.2
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 +6 -6
- package/package.json +16 -12
- package/src/components/experimental/experiment_badge/experiment_badge.vue +12 -11
- package/src/components/base/accordion/accordion.spec.js +0 -58
- package/src/components/base/accordion/accordion.stories.js +0 -59
- package/src/components/base/accordion/accordion_item.spec.js +0 -131
- package/src/components/base/accordion/accordion_item.stories.js +0 -57
- package/src/components/base/alert/alert.spec.js +0 -229
- package/src/components/base/alert/alert.stories.js +0 -166
- package/src/components/base/avatar/avatar.spec.js +0 -91
- package/src/components/base/avatar/avatar.stories.js +0 -160
- package/src/components/base/avatar_labeled/avatar_labeled.spec.js +0 -109
- package/src/components/base/avatar_labeled/avatar_labeled.stories.js +0 -187
- package/src/components/base/avatar_link/avatar_link.stories.js +0 -86
- package/src/components/base/avatars_inline/avatars_inline.spec.js +0 -124
- package/src/components/base/avatars_inline/avatars_inline.stories.js +0 -83
- package/src/components/base/badge/badge.spec.js +0 -83
- package/src/components/base/badge/badge.stories.js +0 -184
- package/src/components/base/banner/banner.spec.js +0 -112
- package/src/components/base/banner/banner.stories.js +0 -103
- package/src/components/base/breadcrumb/breadcrumb.spec.js +0 -240
- package/src/components/base/breadcrumb/breadcrumb.stories.js +0 -100
- package/src/components/base/breadcrumb/breadcrumb_item.spec.js +0 -45
- package/src/components/base/broadcast_message/broadcast_message.spec.js +0 -32
- package/src/components/base/broadcast_message/broadcast_message.stories.js +0 -112
- package/src/components/base/button/button.spec.js +0 -225
- package/src/components/base/button/button.stories.js +0 -529
- package/src/components/base/button_group/button_group.stories.js +0 -132
- package/src/components/base/card/card.spec.js +0 -139
- package/src/components/base/card/card.stories.js +0 -48
- package/src/components/base/carousel/carousel.spec.js +0 -24
- package/src/components/base/carousel/carousel.stories.js +0 -51
- package/src/components/base/collapse/collapse.spec.js +0 -24
- package/src/components/base/collapse/collapse.stories.js +0 -42
- package/src/components/base/datepicker/datepicker.spec.js +0 -431
- package/src/components/base/datepicker/datepicker.stories.js +0 -149
- package/src/components/base/daterange_picker/daterange_picker.spec.js +0 -307
- package/src/components/base/daterange_picker/daterange_picker.stories.js +0 -145
- package/src/components/base/drawer/drawer.spec.js +0 -136
- package/src/components/base/drawer/drawer.stories.js +0 -272
- package/src/components/base/dropdown/dropdown.spec.js +0 -457
- package/src/components/base/dropdown/dropdown.stories.js +0 -574
- package/src/components/base/dropdown/dropdown_form.spec.js +0 -9
- package/src/components/base/dropdown/dropdown_item.spec.js +0 -67
- package/src/components/base/dropdown/dropdown_item.stories.js +0 -113
- package/src/components/base/filtered_search/__snapshots__/filtered_search_term.spec.js.snap +0 -31
- package/src/components/base/filtered_search/filtered_search.spec.js +0 -908
- package/src/components/base/filtered_search/filtered_search.stories.js +0 -678
- package/src/components/base/filtered_search/filtered_search_suggestion.spec.js +0 -67
- package/src/components/base/filtered_search/filtered_search_suggestion.stories.js +0 -33
- package/src/components/base/filtered_search/filtered_search_suggestion_list.spec.js +0 -337
- package/src/components/base/filtered_search/filtered_search_suggestion_list.stories.js +0 -53
- package/src/components/base/filtered_search/filtered_search_term.spec.js +0 -212
- package/src/components/base/filtered_search/filtered_search_term.stories.js +0 -60
- package/src/components/base/filtered_search/filtered_search_token.spec.js +0 -461
- package/src/components/base/filtered_search/filtered_search_token.stories.js +0 -199
- package/src/components/base/filtered_search/filtered_search_token_segment.spec.js +0 -393
- package/src/components/base/filtered_search/filtered_search_token_segment.stories.js +0 -110
- package/src/components/base/filtered_search/filtered_search_utils.spec.js +0 -82
- package/src/components/base/form/form.stories.js +0 -101
- package/src/components/base/form/form_checkbox/form_checkbox.stories.js +0 -55
- package/src/components/base/form/form_checkbox_tree/form_checkbox_tree.spec.js +0 -265
- package/src/components/base/form/form_checkbox_tree/form_checkbox_tree.stories.js +0 -134
- package/src/components/base/form/form_combobox/form_combobox.spec.js +0 -301
- package/src/components/base/form/form_combobox/form_combobox.stories.js +0 -116
- package/src/components/base/form/form_date/form_date.spec.js +0 -85
- package/src/components/base/form/form_date/form_date.stories.js +0 -108
- package/src/components/base/form/form_fields/form_field_validator.spec.js +0 -51
- package/src/components/base/form/form_fields/form_fields.spec.js +0 -531
- package/src/components/base/form/form_fields/form_fields.stories.js +0 -150
- package/src/components/base/form/form_fields/mappers.spec.js +0 -17
- package/src/components/base/form/form_fields/validators.spec.js +0 -56
- package/src/components/base/form/form_group/form_group.spec.js +0 -110
- package/src/components/base/form/form_group/form_group.stories.js +0 -123
- package/src/components/base/form/form_input/form_input.spec.js +0 -130
- package/src/components/base/form/form_input/form_input.stories.js +0 -128
- package/src/components/base/form/form_input_group/form_input_group.spec.js +0 -121
- package/src/components/base/form/form_input_group/form_input_group.stories.js +0 -86
- package/src/components/base/form/form_radio/form_radio.spec.js +0 -116
- package/src/components/base/form/form_radio/form_radio.stories.js +0 -70
- package/src/components/base/form/form_radio_group/form_radio_group.spec.js +0 -86
- package/src/components/base/form/form_radio_group/form_radio_group.stories.js +0 -79
- package/src/components/base/form/form_select/form_select.spec.js +0 -69
- package/src/components/base/form/form_select/form_select.stories.js +0 -156
- package/src/components/base/form/form_text/form_text.stories.js +0 -27
- package/src/components/base/form/form_textarea/form_textarea.spec.js +0 -242
- package/src/components/base/form/form_textarea/form_textarea.stories.js +0 -68
- package/src/components/base/form/input_group_text/input_group_text.spec.js +0 -9
- package/src/components/base/form/input_group_text/input_group_text.stories.js +0 -30
- package/src/components/base/icon/__snapshots__/icon.spec.js.snap +0 -14
- package/src/components/base/icon/icon.spec.js +0 -92
- package/src/components/base/icon/icon.stories.js +0 -56
- package/src/components/base/infinite_scroll/infinite_scroll.spec.js +0 -182
- package/src/components/base/infinite_scroll/infinite_scroll.stories.js +0 -94
- package/src/components/base/keyset_pagination/keyset_pagination.spec.js +0 -313
- package/src/components/base/keyset_pagination/keyset_pagination.stories.js +0 -66
- package/src/components/base/label/label.spec.js +0 -257
- package/src/components/base/label/label.stories.js +0 -76
- package/src/components/base/link/link.spec.js +0 -88
- package/src/components/base/link/link.stories.js +0 -64
- package/src/components/base/loading_icon/loading_icon.spec.js +0 -109
- package/src/components/base/loading_icon/loading_icon.stories.js +0 -60
- package/src/components/base/markdown/markdown.spec.js +0 -24
- package/src/components/base/markdown/markdown.stories.js +0 -33
- package/src/components/base/modal/modal.spec.js +0 -265
- package/src/components/base/modal/modal.stories.js +0 -197
- package/src/components/base/nav/nav.spec.js +0 -19
- package/src/components/base/nav/nav.stories.js +0 -57
- package/src/components/base/nav/nav_item.spec.js +0 -16
- package/src/components/base/nav/nav_item_dropdown.spec.js +0 -58
- package/src/components/base/navbar/navbar.spec.js +0 -21
- package/src/components/base/navbar/navbar.stories.js +0 -28
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.spec.js +0 -566
- package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.spec.js +0 -452
- package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.stories.js +0 -345
- package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown_group.spec.js +0 -84
- package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown_item.spec.js +0 -200
- package/src/components/base/new_dropdowns/disclosure/utils.spec.js +0 -74
- package/src/components/base/new_dropdowns/listbox/listbox.spec.js +0 -950
- package/src/components/base/new_dropdowns/listbox/listbox.stories.js +0 -840
- package/src/components/base/new_dropdowns/listbox/listbox_group.spec.js +0 -61
- package/src/components/base/new_dropdowns/listbox/listbox_item.spec.js +0 -129
- package/src/components/base/new_dropdowns/listbox/listbox_search_input.spec.js +0 -62
- package/src/components/base/new_dropdowns/listbox/utils.spec.js +0 -58
- package/src/components/base/paginated_list/__snapshots__/paginated_list.spec.js.snap +0 -922
- package/src/components/base/paginated_list/paginated_list.spec.js +0 -212
- package/src/components/base/paginated_list/paginated_list.stories.js +0 -207
- package/src/components/base/pagination/pagination.spec.js +0 -401
- package/src/components/base/pagination/pagination.stories.js +0 -129
- package/src/components/base/path/__snapshots__/path.spec.js.snap +0 -586
- package/src/components/base/path/path.spec.js +0 -237
- package/src/components/base/path/path.stories.js +0 -84
- package/src/components/base/popover/popover.spec.js +0 -104
- package/src/components/base/popover/popover.stories.js +0 -109
- package/src/components/base/progress_bar/progress_bar.stories.js +0 -34
- package/src/components/base/search_box_by_click/search_box_by_click.spec.js +0 -209
- package/src/components/base/search_box_by_click/search_box_by_click.stories.js +0 -100
- package/src/components/base/search_box_by_type/search_box_by_type.spec.js +0 -164
- package/src/components/base/search_box_by_type/search_box_by_type.stories.js +0 -63
- package/src/components/base/segmented_control/segmented_control.spec.js +0 -135
- package/src/components/base/segmented_control/segmented_control.stories.js +0 -59
- package/src/components/base/skeleton_loader/skeleton_loader.spec.js +0 -151
- package/src/components/base/skeleton_loader/skeleton_loader.stories.js +0 -86
- package/src/components/base/sorting/sorting.spec.js +0 -170
- package/src/components/base/sorting/sorting.stories.js +0 -98
- package/src/components/base/table/table.spec.js +0 -192
- package/src/components/base/table/table.stories.js +0 -186
- package/src/components/base/table_lite/table_lite.spec.js +0 -40
- package/src/components/base/table_lite/table_lite.stories.js +0 -74
- package/src/components/base/tabs/tab/tab.spec.js +0 -34
- package/src/components/base/tabs/tabs/scrollable_tabs.spec.js +0 -260
- package/src/components/base/tabs/tabs/tabs.spec.js +0 -366
- package/src/components/base/tabs/tabs/tabs.stories.js +0 -209
- package/src/components/base/toast/toast.spec.js +0 -72
- package/src/components/base/toast/toast.stories.js +0 -88
- package/src/components/base/toggle/toggle.spec.js +0 -168
- package/src/components/base/toggle/toggle.stories.js +0 -106
- package/src/components/base/token/token.spec.js +0 -48
- package/src/components/base/token/token.stories.js +0 -58
- package/src/components/base/token_selector/helpers.spec.js +0 -40
- package/src/components/base/token_selector/token_container.spec.js +0 -306
- package/src/components/base/token_selector/token_selector.spec.js +0 -653
- package/src/components/base/token_selector/token_selector.stories.js +0 -114
- package/src/components/base/token_selector/token_selector_dropdown.spec.js +0 -347
- package/src/components/base/tooltip/tooltip.spec.js +0 -27
- package/src/components/base/tooltip/tooltip.stories.js +0 -70
- package/src/components/charts/area/area.spec.js +0 -286
- package/src/components/charts/area/area.stories.js +0 -208
- package/src/components/charts/bar/__snapshots__/bar.spec.js.snap +0 -82
- package/src/components/charts/bar/bar.spec.js +0 -92
- package/src/components/charts/bar/bar.stories.js +0 -72
- package/src/components/charts/chart/chart.spec.js +0 -167
- package/src/components/charts/chart/chart.stories.js +0 -111
- package/src/components/charts/column/__snapshots__/column_chart.spec.js.snap +0 -323
- package/src/components/charts/column/column.stories.js +0 -111
- package/src/components/charts/column/column_chart.spec.js +0 -223
- package/src/components/charts/discrete_scatter/discrete_scatter.spec.js +0 -173
- package/src/components/charts/discrete_scatter/discrete_scatter.stories.js +0 -64
- package/src/components/charts/gauge/gauge.spec.js +0 -280
- package/src/components/charts/gauge/gauge.stories.js +0 -97
- package/src/components/charts/heatmap/heatmap.spec.js +0 -103
- package/src/components/charts/heatmap/heatmap.stories.js +0 -78
- package/src/components/charts/legend/legend.spec.js +0 -274
- package/src/components/charts/legend/legend.stories.js +0 -174
- package/src/components/charts/line/line.spec.js +0 -278
- package/src/components/charts/line/line.stories.js +0 -238
- package/src/components/charts/series_label/series_label.stories.js +0 -78
- package/src/components/charts/single_stat/single_stat.spec.js +0 -217
- package/src/components/charts/single_stat/single_stat.stories.js +0 -103
- package/src/components/charts/sparkline/sparkline.spec.js +0 -220
- package/src/components/charts/sparkline/sparkline.stories.js +0 -85
- package/src/components/charts/stacked_column/__snapshots__/stacked_column.spec.js.snap +0 -905
- package/src/components/charts/stacked_column/stacked_column.spec.js +0 -194
- package/src/components/charts/stacked_column/stacked_column.stories.js +0 -130
- package/src/components/charts/tooltip/tooltip.spec.js +0 -282
- package/src/components/charts/tooltip/tooltip.stories.js +0 -90
- package/src/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.spec.js +0 -46
- package/src/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.stories.js +0 -62
- package/src/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.spec.js +0 -70
- package/src/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.stories.js +0 -31
- package/src/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.spec.js +0 -64
- package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.spec.js +0 -534
- package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.stories.js +0 -55
- package/src/components/experimental/duo/chat/components/duo_chat_message/utils.spec.js +0 -24
- package/src/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.spec.js +0 -93
- package/src/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.stories.js +0 -32
- package/src/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.spec.js +0 -35
- package/src/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.stories.js +0 -36
- package/src/components/experimental/duo/chat/duo_chat.spec.js +0 -828
- package/src/components/experimental/duo/chat/duo_chat.stories.js +0 -240
- package/src/components/experimental/duo/chat/markdown_renderer.spec.js +0 -55
- package/src/components/experimental/duo/user_feedback/user_feedback.spec.js +0 -100
- package/src/components/experimental/duo/user_feedback/user_feedback.stories.js +0 -107
- package/src/components/experimental/duo/user_feedback/user_feedback_modal.spec.js +0 -134
- package/src/components/experimental/experiment_badge/experiment_badge.spec.js +0 -77
- package/src/components/experimental/experiment_badge/experiment_badge.stories.js +0 -58
- package/src/components/regions/dashboard_skeleton/dashboard_skeleton.stories.js +0 -29
- package/src/components/regions/empty_state/empty_state.spec.js +0 -293
- package/src/components/regions/empty_state/empty_state.stories.js +0 -160
- package/src/components/shared_components/charts/tooltip_default_format.spec.js +0 -69
- package/src/components/shared_components/clear_icon_button/__snapshots__/clear_icon_button.spec.js.snap +0 -15
- package/src/components/shared_components/clear_icon_button/clear_icon_button.spec.js +0 -23
- package/src/components/shared_components/close_button/__snapshots__/close_button.spec.js.snap +0 -12
- package/src/components/shared_components/close_button/close_button.spec.js +0 -22
- package/src/components/utilities/animated_number/animated_number.spec.js +0 -133
- package/src/components/utilities/animated_number/animated_number.stories.js +0 -63
- package/src/components/utilities/friendly_wrap/friendly_wrap.spec.js +0 -123
- package/src/components/utilities/friendly_wrap/friendly_wrap.stories.js +0 -56
- package/src/components/utilities/intersection_observer/intersection_observer.spec.js +0 -116
- package/src/components/utilities/intersection_observer/intersection_observer.stories.js +0 -162
- package/src/components/utilities/intersperse/intersperse.spec.js +0 -115
- package/src/components/utilities/intersperse/intersperse.stories.js +0 -53
- package/src/components/utilities/sprintf/sprintf.spec.js +0 -337
- package/src/components/utilities/sprintf/sprintf.stories.js +0 -104
- package/src/components/utilities/truncate/truncate.spec.js +0 -125
- package/src/components/utilities/truncate/truncate.stories.js +0 -50
- package/src/components/utilities/truncate_text/truncate_text.spec.js +0 -150
- package/src/components/utilities/truncate_text/truncate_text.stories.js +0 -45
- package/src/directives/hover_load/hover_load.spec.js +0 -64
- package/src/directives/hover_load/hover_load.stories.js +0 -51
- package/src/directives/outside/outside.spec.js +0 -338
- package/src/directives/outside/outside.stories.js +0 -35
- package/src/directives/resize_observer/resize_observer.spec.js +0 -125
- package/src/directives/resize_observer/resize_observer.stories.js +0 -76
- package/src/directives/safe_html/safe_html.spec.js +0 -149
- package/src/directives/safe_html/safe_html.stories.js +0 -60
- package/src/directives/safe_link/safe_link.spec.js +0 -135
- package/src/directives/safe_link/safe_link.stories.js +0 -39
- package/src/internal/color_contrast/color_contrast.spec.js +0 -34
- package/src/internal/color_contrast/color_contrast.stories.js +0 -41
- package/src/scss/functions.spec.scss +0 -54
- package/src/scss/mixins.spec.scss +0 -93
- package/src/scss/run_scss_tests.spec.js +0 -26
- package/src/scss/typescale/typescale.stories.js +0 -61
- package/src/tokens/color.constant.tokens.stories.js +0 -19
- package/src/tokens/color.dark.tokens.stories.js +0 -26
- package/src/tokens/color.data_viz.dark.tokens.stories.js +0 -19
- package/src/tokens/color.data_viz.tokens.stories.js +0 -19
- package/src/tokens/color.theme.dark.tokens.stories.js +0 -21
- package/src/tokens/color.theme.tokens.stories.js +0 -21
- package/src/tokens/color.tokens.stories.js +0 -26
- package/src/tokens/color.transparency.tokens.stories.js +0 -14
- package/src/tokens/text.dark.tokens.stories.js +0 -18
- package/src/tokens/text.tokens.stories.js +0 -17
- package/src/tokens/tokens.stories.js +0 -16
- package/src/utils/breakpoints.spec.js +0 -26
- package/src/utils/charts/config.spec.js +0 -478
- package/src/utils/charts/utils.spec.js +0 -106
- package/src/utils/datetime_utility.spec.js +0 -98
- package/src/utils/is_slot_empty.spec.js +0 -73
- package/src/utils/number_utils.spec.js +0 -110
- package/src/utils/stories_utils.spec.js +0 -18
- package/src/utils/string_utils.spec.js +0 -56
- package/src/utils/utils.spec.js +0 -156
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import range from 'lodash/range';
|
|
2
|
-
import GlBadge from '../../badge/badge.vue';
|
|
3
|
-
import { badgeVariantOptions } from '../../../../utils/constants';
|
|
4
|
-
import GlTab from '../tab/tab.vue';
|
|
5
|
-
import GlScrollableTabs from './scrollable_tabs.vue';
|
|
6
|
-
import GlTabs from './tabs.vue';
|
|
7
|
-
import readme from './tabs.md';
|
|
8
|
-
|
|
9
|
-
const components = {
|
|
10
|
-
GlTabs,
|
|
11
|
-
GlTab,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const generateProps = ({ justified } = {}) => ({
|
|
15
|
-
justified,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const wrap = (template) => `
|
|
19
|
-
<gl-tabs
|
|
20
|
-
:justified="justified"
|
|
21
|
-
>
|
|
22
|
-
${template}
|
|
23
|
-
</gl-tabs>
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
const ScrollableTabsGenerator = {
|
|
27
|
-
components: {
|
|
28
|
-
GlTabs,
|
|
29
|
-
GlScrollableTabs,
|
|
30
|
-
GlTab,
|
|
31
|
-
},
|
|
32
|
-
props: {
|
|
33
|
-
count: {
|
|
34
|
-
type: Number,
|
|
35
|
-
required: true,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
computed: {
|
|
39
|
-
tabs() {
|
|
40
|
-
return range(this.count).map((i) => ({
|
|
41
|
-
title: `Tab ${i + 1}`,
|
|
42
|
-
content: `Tab panel ${i + 1} content...`,
|
|
43
|
-
}));
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
template: `
|
|
47
|
-
<gl-scrollable-tabs v-bind="$attrs">
|
|
48
|
-
<gl-tab v-for="tab in tabs" :key="tab.title" :title="tab.title">
|
|
49
|
-
{{ tab.content }}
|
|
50
|
-
</gl-tab>
|
|
51
|
-
</gl-scrollable-tabs>
|
|
52
|
-
`,
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const Default = (_args, { argTypes }) => ({
|
|
56
|
-
props: Object.keys(argTypes),
|
|
57
|
-
components,
|
|
58
|
-
template: wrap(`
|
|
59
|
-
<gl-tab title="Tab 1">
|
|
60
|
-
Tab panel 1
|
|
61
|
-
</gl-tab>
|
|
62
|
-
<gl-tab title="Tab 2">
|
|
63
|
-
Tab panel 2
|
|
64
|
-
</gl-tab>
|
|
65
|
-
<gl-tab title="Tab 3">
|
|
66
|
-
Tab panel 3
|
|
67
|
-
</gl-tab>
|
|
68
|
-
<gl-tab title="Tab 4">
|
|
69
|
-
Tab panel 4
|
|
70
|
-
</gl-tab>
|
|
71
|
-
<gl-tab title="Tab 5">
|
|
72
|
-
Tab panel 5
|
|
73
|
-
</gl-tab>
|
|
74
|
-
<gl-tab title="Tab 6">
|
|
75
|
-
Tab panel 6
|
|
76
|
-
</gl-tab>
|
|
77
|
-
<gl-tab title="Tab 7">
|
|
78
|
-
Tab panel 7
|
|
79
|
-
</gl-tab>
|
|
80
|
-
<gl-tab title="Tab 8">
|
|
81
|
-
Tab panel 8
|
|
82
|
-
</gl-tab>
|
|
83
|
-
<gl-tab title="Tab 9">
|
|
84
|
-
Tab panel 9
|
|
85
|
-
</gl-tab>
|
|
86
|
-
<gl-tab title="Tab 10">
|
|
87
|
-
Tab panel 10
|
|
88
|
-
</gl-tab>
|
|
89
|
-
<gl-tab title="Tab 11">
|
|
90
|
-
Tab panel 11
|
|
91
|
-
</gl-tab>
|
|
92
|
-
<gl-tab title="Tab 12">
|
|
93
|
-
Tab panel 12
|
|
94
|
-
</gl-tab>
|
|
95
|
-
<gl-tab title="Tab 13" query-param-value="thirteenth">
|
|
96
|
-
Tab panel 13
|
|
97
|
-
</gl-tab>
|
|
98
|
-
<gl-tab title="Tab 14">
|
|
99
|
-
Tab panel 14
|
|
100
|
-
</gl-tab>`),
|
|
101
|
-
});
|
|
102
|
-
Default.args = generateProps();
|
|
103
|
-
|
|
104
|
-
export const ContentlessTab = (_args, { argTypes }) => ({
|
|
105
|
-
props: Object.keys(argTypes),
|
|
106
|
-
components,
|
|
107
|
-
template: wrap(`
|
|
108
|
-
<gl-tab title="Regular tab">
|
|
109
|
-
<p>Regular tab content.</p>
|
|
110
|
-
<p>The contentless tab is not selectable, as it has no content. This is useful for displaying things that aren't really tabs after the list of tabs.</p>
|
|
111
|
-
</gl-tab>
|
|
112
|
-
<gl-tab title="Another tab">
|
|
113
|
-
<p>Another tab's content.</p>
|
|
114
|
-
</gl-tab>
|
|
115
|
-
<template #tabs-end>
|
|
116
|
-
<li class="gl-tab-nav-item">
|
|
117
|
-
Contentless tab
|
|
118
|
-
</li>
|
|
119
|
-
</template>`),
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
export const EmptyState = (_args, { argTypes }) => ({
|
|
123
|
-
props: Object.keys(argTypes),
|
|
124
|
-
components,
|
|
125
|
-
template: wrap(`
|
|
126
|
-
<template #empty>
|
|
127
|
-
This content is only displayed when there are no tabs. Useful for dynamically added/removed tabs.
|
|
128
|
-
</template>`),
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
export const JustifiedTabs = (_args, { argTypes }) => ({
|
|
132
|
-
props: Object.keys(argTypes),
|
|
133
|
-
components,
|
|
134
|
-
template: wrap(`
|
|
135
|
-
<gl-tab title="Tab 1">
|
|
136
|
-
<p>Tab panel 1</p>
|
|
137
|
-
</gl-tab>
|
|
138
|
-
<gl-tab title="Tab 2">
|
|
139
|
-
<p>Tab panel 2</p>
|
|
140
|
-
</gl-tab>`),
|
|
141
|
-
});
|
|
142
|
-
JustifiedTabs.args = generateProps({ justified: true });
|
|
143
|
-
|
|
144
|
-
export const WithCounterBadges = (_args, { argTypes }) => ({
|
|
145
|
-
props: Object.keys(argTypes),
|
|
146
|
-
components: { ...components, GlBadge },
|
|
147
|
-
template: wrap(`
|
|
148
|
-
<gl-tab
|
|
149
|
-
v-for="variant in $options.badgeVariantOptions"
|
|
150
|
-
:key="variant"
|
|
151
|
-
>
|
|
152
|
-
<template #title>
|
|
153
|
-
<span>Tab</span>
|
|
154
|
-
<gl-badge size="sm" class="gl-tab-counter-badge" :variant="variant">500</gl-badge>
|
|
155
|
-
<span class="sr-only">items</span>
|
|
156
|
-
</template>
|
|
157
|
-
Tab panel {{ variant }}
|
|
158
|
-
</gl-tab>`),
|
|
159
|
-
badgeVariantOptions,
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
export const WithScroll = (_args, { argTypes }) => ({
|
|
163
|
-
props: Object.keys(argTypes),
|
|
164
|
-
components: {
|
|
165
|
-
ScrollableTabsGenerator,
|
|
166
|
-
},
|
|
167
|
-
template: '<scrollable-tabs-generator :count="50" />',
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
export const WithScrollAndGrowing = (_args, { argTypes }) => ({
|
|
171
|
-
props: Object.keys(argTypes),
|
|
172
|
-
components: {
|
|
173
|
-
ScrollableTabsGenerator,
|
|
174
|
-
},
|
|
175
|
-
data() {
|
|
176
|
-
return {
|
|
177
|
-
count: 2,
|
|
178
|
-
intervalId: 0,
|
|
179
|
-
};
|
|
180
|
-
},
|
|
181
|
-
mounted() {
|
|
182
|
-
this.intervalId = setInterval(() => {
|
|
183
|
-
this.count += 1;
|
|
184
|
-
}, 2000);
|
|
185
|
-
},
|
|
186
|
-
template: '<scrollable-tabs-generator :count="count" />',
|
|
187
|
-
});
|
|
188
|
-
WithScrollAndGrowing.tags = ['skip-visual-test'];
|
|
189
|
-
|
|
190
|
-
export default {
|
|
191
|
-
title: 'base/tabs',
|
|
192
|
-
component: GlTabs,
|
|
193
|
-
subcomponents: { GlTab, GlScrollableTabs },
|
|
194
|
-
parameters: {
|
|
195
|
-
bootstrapComponent: 'b-tabs',
|
|
196
|
-
docs: {
|
|
197
|
-
description: {
|
|
198
|
-
component: readme,
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
argTypes: {
|
|
203
|
-
contentClass: { control: { disable: true } },
|
|
204
|
-
navClass: { control: { disable: true } },
|
|
205
|
-
syncActiveTabWithQueryParams: { control: { disable: true } },
|
|
206
|
-
queryParamName: { control: { disable: true } },
|
|
207
|
-
value: { control: { disable: true } },
|
|
208
|
-
},
|
|
209
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import Vue from 'vue';
|
|
2
|
-
import { mount } from '@vue/test-utils';
|
|
3
|
-
import GlToast from './toast';
|
|
4
|
-
|
|
5
|
-
Vue.use(GlToast);
|
|
6
|
-
const Component = {
|
|
7
|
-
template: `<div />`,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
describe('GlToast', () => {
|
|
11
|
-
let wrapper;
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
wrapper = mount(Component);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('attaches $toast propery', () => {
|
|
18
|
-
expect(wrapper.vm.$toast).toEqual({
|
|
19
|
-
show: expect.any(Function),
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('show returns a toast object', () => {
|
|
24
|
-
const toast = wrapper.vm.$toast.show('foo');
|
|
25
|
-
expect(toast).toEqual({
|
|
26
|
-
id: expect.any(String),
|
|
27
|
-
hide: expect.any(Function),
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe('onComplete callback', () => {
|
|
32
|
-
let onCompleteSpy;
|
|
33
|
-
let toast;
|
|
34
|
-
|
|
35
|
-
beforeEach(() => {
|
|
36
|
-
onCompleteSpy = jest.fn();
|
|
37
|
-
|
|
38
|
-
toast = wrapper.vm.$toast.show('foo', {
|
|
39
|
-
onComplete: onCompleteSpy,
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('calls onComplete callback only when matching toast hides', () => {
|
|
44
|
-
expect(onCompleteSpy).not.toHaveBeenCalled();
|
|
45
|
-
|
|
46
|
-
// Pretend some other toast was hidden.
|
|
47
|
-
wrapper.vm.$root.$emit('bv::toast:hidden', { componentId: 'some other toast' });
|
|
48
|
-
expect(onCompleteSpy).not.toHaveBeenCalled();
|
|
49
|
-
|
|
50
|
-
// Pretend our toast was hidden.
|
|
51
|
-
wrapper.vm.$root.$emit('bv::toast:hidden', { componentId: toast.id });
|
|
52
|
-
expect(onCompleteSpy).toHaveBeenCalledTimes(1);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('unregisters global listener when toast is hidden', () => {
|
|
56
|
-
expect(onCompleteSpy).not.toHaveBeenCalled();
|
|
57
|
-
|
|
58
|
-
// Pretend the toast was hidden. Can't seem to do this directly in jsdom,
|
|
59
|
-
// so fake it by emitting the event we listen for.
|
|
60
|
-
const event = { componentId: toast.id };
|
|
61
|
-
wrapper.vm.$root.$emit('bv::toast:hidden', event);
|
|
62
|
-
expect(onCompleteSpy).toHaveBeenCalledTimes(1);
|
|
63
|
-
|
|
64
|
-
// This event won't fire more than once in practice, as once the toast is
|
|
65
|
-
// hidden it'll be destroyed and won't show again. This is here to
|
|
66
|
-
// indirectly test that the listener was removed when the toast is
|
|
67
|
-
// hidden the first time.
|
|
68
|
-
wrapper.vm.$root.$emit('bv::toast:hidden', event);
|
|
69
|
-
expect(onCompleteSpy).toHaveBeenCalledTimes(1);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { userEvent, within, waitFor, expect } from '@storybook/test';
|
|
2
|
-
import Vue from 'vue';
|
|
3
|
-
import GlButton from '../button/button.vue';
|
|
4
|
-
import GlToast from './toast';
|
|
5
|
-
import readme from './toast.md';
|
|
6
|
-
|
|
7
|
-
Vue.use(GlToast);
|
|
8
|
-
|
|
9
|
-
const components = { GlToast, GlButton };
|
|
10
|
-
|
|
11
|
-
const play = async ({ canvasElement }) => {
|
|
12
|
-
const canvas = within(canvasElement);
|
|
13
|
-
const button = canvas.getByRole('button');
|
|
14
|
-
await userEvent.click(button);
|
|
15
|
-
await waitFor(() => expect(within(canvasElement).getByRole('button')).toHaveFocus());
|
|
16
|
-
await waitFor(() => expect(within(document).getByRole('status')).toBeVisible());
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const Template = (args, { argTypes }) => ({
|
|
20
|
-
props: Object.keys(argTypes),
|
|
21
|
-
components,
|
|
22
|
-
template: `
|
|
23
|
-
<gl-button @click="showToast()">
|
|
24
|
-
Show default toast
|
|
25
|
-
</gl-button>`,
|
|
26
|
-
methods: {
|
|
27
|
-
showToast() {
|
|
28
|
-
this.$toast.show('This is the default toast.');
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export const Default = Template.bind({});
|
|
34
|
-
Default.play = play;
|
|
35
|
-
|
|
36
|
-
export const WithActions = () => ({
|
|
37
|
-
components,
|
|
38
|
-
template: `
|
|
39
|
-
<gl-button @click="showToast()">
|
|
40
|
-
Show toast with actions
|
|
41
|
-
</gl-button>`,
|
|
42
|
-
methods: {
|
|
43
|
-
showToast() {
|
|
44
|
-
this.$toast.show('This is a toast with an action.', {
|
|
45
|
-
action: {
|
|
46
|
-
text: 'Undo',
|
|
47
|
-
onClick: () => {},
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
WithActions.play = play;
|
|
54
|
-
|
|
55
|
-
export const WithLongContent = () => ({
|
|
56
|
-
components,
|
|
57
|
-
template: `
|
|
58
|
-
<gl-button @click="showToast()">
|
|
59
|
-
Show toast with a long content
|
|
60
|
-
</gl-button>`,
|
|
61
|
-
methods: {
|
|
62
|
-
showToast() {
|
|
63
|
-
this.$toast.show(
|
|
64
|
-
'This is a toast with a long content and an action. Notice how the text wraps to multiple lines when the max-width is reached.',
|
|
65
|
-
{
|
|
66
|
-
action: {
|
|
67
|
-
text: 'Undo action',
|
|
68
|
-
onClick: () => {},
|
|
69
|
-
},
|
|
70
|
-
}
|
|
71
|
-
);
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
WithLongContent.play = play;
|
|
76
|
-
|
|
77
|
-
export default {
|
|
78
|
-
title: 'base/toast',
|
|
79
|
-
component: GlToast,
|
|
80
|
-
parameters: {
|
|
81
|
-
bootstrapComponent: 'toast',
|
|
82
|
-
docs: {
|
|
83
|
-
description: {
|
|
84
|
-
component: readme,
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
};
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils';
|
|
2
|
-
import { toggleLabelPosition } from '../../../utils/constants';
|
|
3
|
-
import Icon from '../icon/icon.vue';
|
|
4
|
-
import LoadingIcon from '../loading_icon/loading_icon.vue';
|
|
5
|
-
import Toggle from './toggle.vue';
|
|
6
|
-
|
|
7
|
-
describe('toggle', () => {
|
|
8
|
-
let wrapper;
|
|
9
|
-
|
|
10
|
-
const label = 'toggle label';
|
|
11
|
-
const descriptionText = 'description text';
|
|
12
|
-
const helpText = 'help text';
|
|
13
|
-
|
|
14
|
-
const createWrapper = (props = {}, options = {}) => {
|
|
15
|
-
wrapper = shallowMount(Toggle, {
|
|
16
|
-
propsData: {
|
|
17
|
-
label,
|
|
18
|
-
...props,
|
|
19
|
-
},
|
|
20
|
-
...options,
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const findButton = () => wrapper.find('button');
|
|
25
|
-
const findDescriptionElement = () => wrapper.find('[data-testid="toggle-description"]');
|
|
26
|
-
const findHelpElement = () => wrapper.find('[data-testid="toggle-help"]');
|
|
27
|
-
|
|
28
|
-
it('has role=switch', () => {
|
|
29
|
-
createWrapper();
|
|
30
|
-
|
|
31
|
-
expect(findButton().attributes('role')).toBe('switch');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
describe.each`
|
|
35
|
-
state | value | ariaCheckedExpected | checkedClassExpected
|
|
36
|
-
${'on'} | ${true} | ${'true'} | ${true}
|
|
37
|
-
${'off'} | ${false} | ${'false'} | ${false}
|
|
38
|
-
`('when $state', ({ value, ariaCheckedExpected, checkedClassExpected }) => {
|
|
39
|
-
beforeEach(() => {
|
|
40
|
-
createWrapper({ value });
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it(`${value ? 'has' : 'does not have'} aria-checked`, () => {
|
|
44
|
-
expect(findButton().attributes('aria-checked')).toBe(ariaCheckedExpected);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it(`${value ? 'has' : 'does not have'} checked class`, () => {
|
|
48
|
-
expect(findButton().classes('is-checked')).toBe(checkedClassExpected);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe.each`
|
|
53
|
-
state | disabled | disabledClassExpected | changeEventPayload | ariaDisabledValue
|
|
54
|
-
${'enabled'} | ${false} | ${false} | ${[[true]]} | ${undefined}
|
|
55
|
-
${'disabled'} | ${true} | ${true} | ${undefined} | ${'true'}
|
|
56
|
-
`('when $state', ({ disabled, disabledClassExpected, changeEventPayload, ariaDisabledValue }) => {
|
|
57
|
-
beforeEach(() => {
|
|
58
|
-
createWrapper({ disabled });
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it(`${disabled ? 'has' : 'does not have'} disabled class`, () => {
|
|
62
|
-
expect(findButton().classes('is-disabled')).toBe(disabledClassExpected);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it(`${disabled ? 'does not emit' : 'emits'} change event when clicked`, () => {
|
|
66
|
-
findButton().trigger('click');
|
|
67
|
-
|
|
68
|
-
expect(wrapper.emitted('change')).toEqual(changeEventPayload);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it(`sets aria-disabled attribute to ${ariaDisabledValue}`, () => {
|
|
72
|
-
expect(findButton().attributes('aria-disabled')).toBe(ariaDisabledValue);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
describe.each`
|
|
77
|
-
state | isLoading
|
|
78
|
-
${'loading'} | ${true}
|
|
79
|
-
${'not loading'} | ${false}
|
|
80
|
-
`('when $state', ({ isLoading }) => {
|
|
81
|
-
beforeEach(() => {
|
|
82
|
-
createWrapper({ isLoading });
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it(`${isLoading ? 'shows' : 'does not show'} loading spinner`, () => {
|
|
86
|
-
expect(wrapper.findComponent(LoadingIcon).exists()).toBe(isLoading);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it(`${isLoading ? 'does not show' : 'shows'} toggle icon`, () => {
|
|
90
|
-
expect(wrapper.findComponent(Icon).exists()).toBe(!isLoading);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
describe.each`
|
|
95
|
-
state | description | props | options
|
|
96
|
-
${'with description'} | ${descriptionText} | ${{ description: descriptionText }} | ${undefined}
|
|
97
|
-
${'with description in slot'} | ${descriptionText} | ${undefined} | ${{ slots: { description: descriptionText } }}
|
|
98
|
-
${'without description'} | ${undefined} | ${undefined} | ${undefined}
|
|
99
|
-
${'with description and labelPosition left'} | ${undefined} | ${{ desciption: descriptionText, labelPosition: toggleLabelPosition.left }} | ${undefined}
|
|
100
|
-
`('$state', ({ description, props, options }) => {
|
|
101
|
-
beforeEach(() => {
|
|
102
|
-
createWrapper(props, options);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
if (description) {
|
|
106
|
-
it('shows description', () => {
|
|
107
|
-
expect(findDescriptionElement().text()).toBe(description);
|
|
108
|
-
});
|
|
109
|
-
} else {
|
|
110
|
-
it('does not show description', () => {
|
|
111
|
-
expect(findDescriptionElement().exists()).toBe(false);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
describe.each`
|
|
117
|
-
state | help | props | options | getAriaDescribedBy
|
|
118
|
-
${'with help'} | ${helpText} | ${{ help: helpText }} | ${undefined} | ${() => findHelpElement().attributes('id')}
|
|
119
|
-
${'with help in slot'} | ${helpText} | ${undefined} | ${{ slots: { help: helpText } }} | ${() => findHelpElement().attributes('id')}
|
|
120
|
-
${'without help'} | ${undefined} | ${undefined} | ${undefined} | ${() => undefined}
|
|
121
|
-
${'with help and labelPosition left'} | ${undefined} | ${{ help: helpText, labelPosition: toggleLabelPosition.left }} | ${undefined} | ${() => undefined}
|
|
122
|
-
`('$state', ({ help, props, options, getAriaDescribedBy }) => {
|
|
123
|
-
beforeEach(() => {
|
|
124
|
-
createWrapper(props, options);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it(`${help ? 'shows' : 'does not show'} help`, () => {
|
|
128
|
-
expect(findHelpElement().exists()).toBe(Boolean(help));
|
|
129
|
-
if (help) {
|
|
130
|
-
expect(findHelpElement().text()).toBe(help);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it(`${help ? 'describes' : 'does not describe'} the toggle button`, () => {
|
|
135
|
-
expect(findButton().attributes('aria-describedby')).toBe(getAriaDescribedBy());
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
describe('label position', () => {
|
|
140
|
-
describe.each`
|
|
141
|
-
state | labelPosition | hasGlSrOnlyClass | flexDirection
|
|
142
|
-
${'top'} | ${toggleLabelPosition.top} | ${false} | ${'gl-flex-direction-column'}
|
|
143
|
-
${'left'} | ${toggleLabelPosition.left} | ${false} | ${'gl-toggle-label-inline'}
|
|
144
|
-
${'hidden'} | ${toggleLabelPosition.hidden} | ${true} | ${'gl-flex-direction-column'}
|
|
145
|
-
`('when $state', ({ labelPosition, hasGlSrOnlyClass, flexDirection }) => {
|
|
146
|
-
beforeEach(() => {
|
|
147
|
-
createWrapper({ labelPosition });
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it(`${flexDirection} class is added to the label`, () => {
|
|
151
|
-
const cssClasses = wrapper.find('[data-testid="toggle-wrapper"]').classes();
|
|
152
|
-
|
|
153
|
-
return expect(cssClasses).toContain(flexDirection);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it(`${hasGlSrOnlyClass ? 'adds' : 'does not add'} 'gl-sr-only' class to the label`, () => {
|
|
157
|
-
const cssClasses = wrapper.find('[data-testid="toggle-label"]').classes();
|
|
158
|
-
return hasGlSrOnlyClass
|
|
159
|
-
? expect(cssClasses).toContain('gl-sr-only')
|
|
160
|
-
: expect(cssClasses).not.toContain('gl-sr-only');
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('has accessible name for the button', () => {
|
|
164
|
-
expect(findButton().attributes('aria-labelledby')).toBeDefined();
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
});
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { toggleLabelPosition } from '../../../utils/constants';
|
|
2
|
-
import { disableControls } from '../../../utils/stories_utils';
|
|
3
|
-
import GlToggle from './toggle.vue';
|
|
4
|
-
import readme from './toggle.md';
|
|
5
|
-
|
|
6
|
-
const defaultValue = (prop) => GlToggle.props[prop].default;
|
|
7
|
-
|
|
8
|
-
const withDescription = 'A dark color theme that is easier on the eyes.';
|
|
9
|
-
|
|
10
|
-
const longHelp = `This is a toggle component with a long help message.
|
|
11
|
-
You can notice how the text wraps when the width of the container
|
|
12
|
-
is not enough to fix the entire text.`;
|
|
13
|
-
|
|
14
|
-
const generateProps = ({
|
|
15
|
-
value = true,
|
|
16
|
-
disabled = defaultValue('disabled'),
|
|
17
|
-
isLoading = defaultValue('isLoading'),
|
|
18
|
-
label = 'Dark mode',
|
|
19
|
-
labelId = 'dark-mode-toggle',
|
|
20
|
-
description = '',
|
|
21
|
-
help = 'Toggle dark mode for the website.',
|
|
22
|
-
labelPosition = defaultValue('labelPosition'),
|
|
23
|
-
} = {}) => ({
|
|
24
|
-
value,
|
|
25
|
-
disabled,
|
|
26
|
-
isLoading,
|
|
27
|
-
label,
|
|
28
|
-
labelId,
|
|
29
|
-
description,
|
|
30
|
-
help,
|
|
31
|
-
labelPosition,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const Template = (args, { argTypes }) => ({
|
|
35
|
-
components: { GlToggle },
|
|
36
|
-
props: Object.keys(argTypes),
|
|
37
|
-
data() {
|
|
38
|
-
return {
|
|
39
|
-
localValue: this.value,
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
watch: {
|
|
43
|
-
value(newValue) {
|
|
44
|
-
this.localValue = newValue;
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
template: `
|
|
48
|
-
<div class="gl-font-base">
|
|
49
|
-
<gl-toggle
|
|
50
|
-
v-model="localValue"
|
|
51
|
-
:disabled="disabled"
|
|
52
|
-
:description="description"
|
|
53
|
-
:help="help"
|
|
54
|
-
:label-id="labelId"
|
|
55
|
-
:is-loading="isLoading"
|
|
56
|
-
:label="label"
|
|
57
|
-
:label-position="labelPosition"
|
|
58
|
-
/>
|
|
59
|
-
</div>`,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
export const Default = Template.bind({});
|
|
63
|
-
Default.args = generateProps();
|
|
64
|
-
|
|
65
|
-
export const WithDescription = Template.bind({});
|
|
66
|
-
WithDescription.args = generateProps({
|
|
67
|
-
description: withDescription,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
export const WithLongHelp = Template.bind({});
|
|
71
|
-
WithLongHelp.args = generateProps({
|
|
72
|
-
help: longHelp,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
export const LabelPositionLeft = Template.bind({});
|
|
76
|
-
LabelPositionLeft.args = generateProps({
|
|
77
|
-
labelPosition: 'left',
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
export default {
|
|
81
|
-
title: 'base/toggle',
|
|
82
|
-
component: GlToggle,
|
|
83
|
-
parameters: {
|
|
84
|
-
docs: {
|
|
85
|
-
description: {
|
|
86
|
-
component: readme,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
argTypes: {
|
|
91
|
-
...disableControls(['name']),
|
|
92
|
-
labelPosition: {
|
|
93
|
-
options: Object.keys(toggleLabelPosition),
|
|
94
|
-
control: 'select',
|
|
95
|
-
},
|
|
96
|
-
label: {
|
|
97
|
-
control: 'text',
|
|
98
|
-
},
|
|
99
|
-
description: {
|
|
100
|
-
control: 'text',
|
|
101
|
-
},
|
|
102
|
-
help: {
|
|
103
|
-
control: 'text',
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils';
|
|
2
|
-
import CloseButton from '../../shared_components/close_button/close_button.vue';
|
|
3
|
-
import Token from './token.vue';
|
|
4
|
-
|
|
5
|
-
const findIcon = (wrapper) => wrapper.findComponent(CloseButton);
|
|
6
|
-
|
|
7
|
-
describe('Token component', () => {
|
|
8
|
-
let wrapper;
|
|
9
|
-
|
|
10
|
-
const viewOnlyClass = 'gl-token-view-only';
|
|
11
|
-
|
|
12
|
-
const createComponent = (propsData) =>
|
|
13
|
-
shallowMount(Token, {
|
|
14
|
-
propsData,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('emits close when "x" is clicked', () => {
|
|
18
|
-
wrapper = createComponent();
|
|
19
|
-
findIcon(wrapper).vm.$emit('click');
|
|
20
|
-
expect(wrapper.emitted('close')).toHaveLength(1);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('hides the icon when view-only', () => {
|
|
24
|
-
wrapper = createComponent({ viewOnly: true });
|
|
25
|
-
expect(findIcon(wrapper).exists()).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('includes view-only class when view-only', () => {
|
|
29
|
-
wrapper = createComponent({ viewOnly: true });
|
|
30
|
-
expect(wrapper.classes()).toContain(viewOnlyClass);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('does not include view-only class when not view-only', () => {
|
|
34
|
-
wrapper = createComponent({ viewOnly: false });
|
|
35
|
-
expect(wrapper.classes()).not.toContain(viewOnlyClass);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it.each`
|
|
39
|
-
variant | cssClass
|
|
40
|
-
${undefined} | ${'gl-token-default-variant'}
|
|
41
|
-
${'default'} | ${'gl-token-default-variant'}
|
|
42
|
-
${'search-type'} | ${'gl-token-search-type-variant'}
|
|
43
|
-
${'search-value'} | ${'gl-token-search-value-variant'}
|
|
44
|
-
`('sets class .$cssClass when variant is $variant', ({ variant, cssClass }) => {
|
|
45
|
-
wrapper = createComponent({ viewOnly: true, variant });
|
|
46
|
-
expect(wrapper.classes()).toContain(cssClass);
|
|
47
|
-
});
|
|
48
|
-
});
|