@mozaic-ds/vue 1.0.0-beta.3 → 1.0.0-beta.5
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/LICENSE +51 -0
- package/README.md +224 -82
- package/dist/mozaic-vue.css +1 -1
- package/dist/mozaic-vue.d.ts +1202 -0
- package/dist/mozaic-vue.js +1220 -0
- package/dist/mozaic-vue.js.map +1 -0
- package/dist/mozaic-vue.umd.cjs +2 -0
- package/dist/mozaic-vue.umd.cjs.map +1 -0
- package/env.d.ts +1 -0
- package/package.json +81 -50
- package/src/components/Contributing.mdx +118 -0
- package/src/components/GettingStarted.mdx +50 -0
- package/src/components/Introduction.mdx +54 -0
- package/src/components/Support.mdx +18 -0
- package/src/components/badge/MBadge.spec.ts +16 -0
- package/src/components/badge/MBadge.stories.ts +50 -0
- package/src/components/badge/MBadge.vue +36 -34
- package/src/components/breadcrumb/MBreadcrumb.spec.ts +105 -0
- package/src/components/breadcrumb/MBreadcrumb.stories.ts +57 -0
- package/src/components/breadcrumb/MBreadcrumb.vue +52 -55
- package/src/components/button/MButton.spec.ts +191 -0
- package/src/components/button/MButton.stories.ts +66 -0
- package/src/components/button/MButton.vue +98 -154
- package/src/components/checkbox/MCheckbox.spec.ts +104 -0
- package/src/components/checkbox/MCheckbox.stories.ts +83 -0
- package/src/components/checkbox/MCheckbox.vue +60 -101
- package/src/components/checkboxgroup/MCheckboxGroup.spec.ts +78 -0
- package/src/components/checkboxgroup/MCheckboxGroup.stories.ts +61 -0
- package/src/components/checkboxgroup/MCheckboxGroup.vue +97 -0
- package/src/components/field/MField.spec.ts +166 -0
- package/src/components/field/MField.stories.ts +376 -0
- package/src/components/field/MField.vue +78 -61
- package/src/components/fieldgroup/MFieldGroup.spec.ts +165 -0
- package/src/components/fieldgroup/MFieldGroup.stories.ts +423 -0
- package/src/components/fieldgroup/MFieldGroup.vue +79 -0
- package/src/components/iconbutton/MIconButton.spec.ts +108 -0
- package/src/components/iconbutton/MIconButton.stories.ts +66 -0
- package/src/components/iconbutton/MIconButton.vue +73 -0
- package/src/components/link/MLink.spec.ts +154 -0
- package/src/components/link/MLink.stories.ts +98 -0
- package/src/components/link/MLink.vue +86 -109
- package/src/components/loader/MLoader.spec.ts +104 -0
- package/src/components/loader/MLoader.stories.ts +45 -0
- package/src/components/loader/MLoader.vue +65 -55
- package/src/components/overlay/MOverlay.spec.ts +51 -0
- package/src/components/overlay/MOverlay.stories.ts +40 -0
- package/src/components/overlay/MOverlay.vue +27 -19
- package/src/components/passwordinput/MPasswordInput.spec.ts +104 -0
- package/src/components/passwordinput/MPasswordInput.stories.ts +75 -0
- package/src/components/passwordinput/MPasswordInput.vue +129 -76
- package/src/components/quantityselector/MQuantitySelector.spec.ts +262 -0
- package/src/components/quantityselector/MQuantitySelector.stories.ts +89 -0
- package/src/components/quantityselector/MQuantitySelector.vue +160 -136
- package/src/components/radio/MRadio.spec.ts +104 -0
- package/src/components/radio/MRadio.stories.ts +68 -0
- package/src/components/radio/MRadio.vue +56 -39
- package/src/components/radiogroup/MRadioGroup.spec.ts +54 -0
- package/src/components/radiogroup/MRadioGroup.stories.ts +61 -0
- package/src/components/radiogroup/MRadioGroup.vue +79 -0
- package/src/components/select/MSelect.spec.ts +114 -0
- package/src/components/select/MSelect.stories.ts +101 -0
- package/src/components/select/MSelect.vue +77 -119
- package/src/components/statusbadge/MStatusBadge.stories.ts +45 -0
- package/src/components/statusbadge/MStatusBadge.vue +40 -0
- package/src/components/statusbadge/MstatusBadge.spec.ts +16 -0
- package/src/components/statusdot/MStatusDot.spec.ts +51 -0
- package/src/components/statusdot/MStatusDot.stories.ts +48 -0
- package/src/components/statusdot/MStatusDot.vue +36 -0
- package/src/components/statusnotification/MStatusNotification.spec.ts +99 -0
- package/src/components/statusnotification/MStatusNotification.stories.ts +96 -0
- package/src/components/statusnotification/MStatusNotification.vue +106 -0
- package/src/components/textarea/MTextArea.spec.ts +112 -0
- package/src/components/textarea/MTextArea.stories.ts +67 -0
- package/src/components/textarea/MTextArea.vue +81 -42
- package/src/components/textinput/MTextInput.spec.ts +121 -0
- package/src/components/textinput/MTextInput.stories.ts +114 -0
- package/src/components/textinput/MTextInput.vue +127 -47
- package/src/components/toggle/MToggle.spec.ts +99 -0
- package/src/components/toggle/MToggle.stories.ts +68 -0
- package/src/components/toggle/MToggle.vue +63 -103
- package/src/components/togglegroup/MToggleGroup.spec.ts +78 -0
- package/src/components/togglegroup/MToggleGroup.stories.ts +61 -0
- package/src/components/togglegroup/MToggleGroup.vue +97 -0
- package/src/components/usingIcons.mdx +43 -0
- package/src/components/usingPresets.mdx +125 -0
- package/src/main.ts +47 -0
- package/dist/demo.html +0 -1
- package/dist/mozaic-vue.adeo.css +0 -45
- package/dist/mozaic-vue.adeo.umd.js +0 -41775
- package/dist/mozaic-vue.common.js +0 -41765
- package/dist/mozaic-vue.common.js.map +0 -1
- package/dist/mozaic-vue.umd.js +0 -41776
- package/dist/mozaic-vue.umd.js.map +0 -1
- package/dist/mozaic-vue.umd.min.js +0 -4
- package/dist/mozaic-vue.umd.min.js.map +0 -1
- package/postinstall.js +0 -3
- package/src/components/accordion/MAccordion.vue +0 -128
- package/src/components/accordion/index.js +0 -7
- package/src/components/autocomplete/MAutocomplete.vue +0 -198
- package/src/components/autocomplete/index.js +0 -7
- package/src/components/badge/index.js +0 -7
- package/src/components/breadcrumb/index.js +0 -7
- package/src/components/button/index.js +0 -7
- package/src/components/card/MCard.vue +0 -78
- package/src/components/card/index.js +0 -7
- package/src/components/checkbox/MCheckboxGroup.vue +0 -155
- package/src/components/checkbox/index.js +0 -12
- package/src/components/container/MContainer.vue +0 -33
- package/src/components/container/index.js +0 -7
- package/src/components/datatable/MDataTable.vue +0 -651
- package/src/components/datatable/MDataTableHeader.vue +0 -55
- package/src/components/datatable/MDataTableTop.vue +0 -35
- package/src/components/datatable/helpers.js +0 -132
- package/src/components/datatable/index.js +0 -12
- package/src/components/field/index.js +0 -7
- package/src/components/fileuploader/MFileResult.vue +0 -149
- package/src/components/fileuploader/MFileUploader.vue +0 -142
- package/src/components/fileuploader/index.js +0 -7
- package/src/components/flag/MFlag.vue +0 -46
- package/src/components/flag/index.js +0 -7
- package/src/components/heading/MHeading.vue +0 -75
- package/src/components/heading/index.js +0 -7
- package/src/components/hero/MHero.vue +0 -93
- package/src/components/hero/index.js +0 -7
- package/src/components/icon/MIcon.vue +0 -120
- package/src/components/icon/index.js +0 -7
- package/src/components/index.js +0 -43
- package/src/components/layer/MLayer.vue +0 -208
- package/src/components/layer/index.js +0 -7
- package/src/components/link/index.js +0 -7
- package/src/components/listbox/MListBox.vue +0 -106
- package/src/components/listbox/index.js +0 -7
- package/src/components/loader/index.js +0 -7
- package/src/components/modal/MModal.vue +0 -179
- package/src/components/modal/index.js +0 -7
- package/src/components/notification/MNotification.vue +0 -110
- package/src/components/notification/index.js +0 -7
- package/src/components/optionbutton/MOptionButton.vue +0 -67
- package/src/components/optionbutton/index.js +0 -7
- package/src/components/optioncard/MOptionCard.vue +0 -132
- package/src/components/optioncard/index.js +0 -7
- package/src/components/optiongroup/MOptionGroup.vue +0 -18
- package/src/components/optiongroup/index.js +0 -7
- package/src/components/overlay/MOverlayLoader.vue +0 -43
- package/src/components/overlay/index.js +0 -12
- package/src/components/pagination/MPagination.vue +0 -162
- package/src/components/pagination/index.js +0 -7
- package/src/components/passwordinput/index.js +0 -7
- package/src/components/phonenumber/MPhoneNumber.vue +0 -390
- package/src/components/phonenumber/index.js +0 -7
- package/src/components/progressbar/MProgress.vue +0 -102
- package/src/components/progressbar/index.js +0 -7
- package/src/components/quantityselector/index.js +0 -7
- package/src/components/radio/MRadioGroup.vue +0 -111
- package/src/components/radio/index.js +0 -12
- package/src/components/ratingstars/MStarsInput.vue +0 -118
- package/src/components/ratingstars/MStarsResult.vue +0 -89
- package/src/components/ratingstars/index.js +0 -12
- package/src/components/select/index.js +0 -7
- package/src/components/stepper/MStepper.vue +0 -70
- package/src/components/stepper/index.js +0 -7
- package/src/components/tabs/MTab.vue +0 -184
- package/src/components/tabs/index.js +0 -7
- package/src/components/tags/MTag.vue +0 -173
- package/src/components/tags/index.js +0 -7
- package/src/components/textarea/index.js +0 -7
- package/src/components/textinput/MTextInputField.vue +0 -105
- package/src/components/textinput/MTextInputIcon.vue +0 -42
- package/src/components/textinput/index.js +0 -7
- package/src/components/toggle/index.js +0 -7
- package/src/components/tooltip/MTooltip.vue +0 -42
- package/src/components/tooltip/index.js +0 -7
- package/src/index.js +0 -62
- package/src/shims-tsx.d.ts +0 -13
- package/src/shims.vue.d.ts +0 -4
- package/src/tokens/adeo/android/colors.xml +0 -391
- package/src/tokens/adeo/android/font_dimens.xml +0 -18
- package/src/tokens/adeo/css/_variables.scss +0 -385
- package/src/tokens/adeo/css/root.scss +0 -387
- package/src/tokens/adeo/ios/StyleDictionaryColor.h +0 -399
- package/src/tokens/adeo/ios/StyleDictionaryColor.m +0 -411
- package/src/tokens/adeo/ios/StyleDictionaryColor.swift +0 -394
- package/src/tokens/adeo/ios/StyleDictionarySize.h +0 -69
- package/src/tokens/adeo/ios/StyleDictionarySize.m +0 -70
- package/src/tokens/adeo/ios/StyleDictionarySize.swift +0 -71
- package/src/tokens/adeo/js/tokens.js +0 -483
- package/src/tokens/adeo/js/tokensObject.js +0 -10354
- package/src/tokens/adeo/scss/_tokens.scss +0 -1300
- package/src/utils/mozaicClasses.js +0 -16
- package/src/utils/theme.validator.js +0 -19
- package/types/index.d.ts +0 -100
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
2
|
+
import MBreadcrumb from './MBreadcrumb.vue';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof MBreadcrumb> = {
|
|
5
|
+
title: 'Navigation/Breadcrumb',
|
|
6
|
+
component: MBreadcrumb,
|
|
7
|
+
parameters: {
|
|
8
|
+
docs: {
|
|
9
|
+
description: {
|
|
10
|
+
component:
|
|
11
|
+
'A breadcrumb is a navigation help that displays the hierarchical path of the current page within a website or application. It helps users understand their location and allows them to navigate back to previous levels easily. Breadcrumbs improve usability and accessibility, especially in multi-level websites, dashboards, and e-commerce platforms.',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
args: {
|
|
16
|
+
links: [
|
|
17
|
+
{
|
|
18
|
+
label: 'Home',
|
|
19
|
+
href: '#',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: 'level 01',
|
|
23
|
+
href: '#',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: 'level 02',
|
|
27
|
+
href: '#',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
label: 'Current Page',
|
|
31
|
+
href: '#',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
render: (args) => ({
|
|
36
|
+
components: { MBreadcrumb },
|
|
37
|
+
setup() {
|
|
38
|
+
return { args };
|
|
39
|
+
},
|
|
40
|
+
template: `
|
|
41
|
+
<MBreadcrumb v-bind="args"></MBreadcrumb>
|
|
42
|
+
`,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
export default meta;
|
|
46
|
+
type Story = StoryObj<typeof MBreadcrumb>;
|
|
47
|
+
|
|
48
|
+
export const Default: Story = {};
|
|
49
|
+
|
|
50
|
+
export const Inverse: Story = {
|
|
51
|
+
parameters: {
|
|
52
|
+
backgrounds: {
|
|
53
|
+
default: 'Inverse',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
args: { appearance: 'inverse' },
|
|
57
|
+
};
|
|
@@ -1,73 +1,70 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<nav
|
|
3
|
-
class="mc-breadcrumb"
|
|
4
|
-
:class="{
|
|
5
|
-
'mc-breadcrumb--dark': dark,
|
|
6
|
-
'mc-breadcrumb--responsive': responsive,
|
|
7
|
-
}"
|
|
8
|
-
aria-label="Breadcrumb"
|
|
9
|
-
>
|
|
2
|
+
<nav class="mc-breadcrumb" :class="classObject" aria-label="Breadcrumb">
|
|
10
3
|
<ul class="mc-breadcrumb__container">
|
|
11
4
|
<li
|
|
12
|
-
v-for="(item, index) in items"
|
|
13
|
-
:key="`breadcrumb-${index}`"
|
|
14
5
|
class="mc-breadcrumb__item"
|
|
15
|
-
|
|
6
|
+
v-for="(link, index) in links"
|
|
7
|
+
:key="`breadcrumb-${index}`"
|
|
16
8
|
>
|
|
17
|
-
<
|
|
18
|
-
:href="
|
|
19
|
-
:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
:
|
|
26
|
-
@click="$emit('link-clicked', item)"
|
|
9
|
+
<MLink
|
|
10
|
+
:href="link.href"
|
|
11
|
+
:router="link.router"
|
|
12
|
+
:appearance="appearance"
|
|
13
|
+
inline
|
|
14
|
+
:class="{
|
|
15
|
+
'mc-breadcrumb__current': isLastLink(index),
|
|
16
|
+
}"
|
|
17
|
+
:aria-current="isLastLink(index) ? 'page' : undefined"
|
|
27
18
|
>
|
|
28
|
-
{{
|
|
29
|
-
</
|
|
19
|
+
{{ link.label }}
|
|
20
|
+
</MLink>
|
|
30
21
|
</li>
|
|
31
22
|
</ul>
|
|
32
23
|
</nav>
|
|
33
24
|
</template>
|
|
34
25
|
|
|
35
|
-
<script>
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import { computed } from 'vue';
|
|
36
28
|
import MLink from '../link/MLink.vue';
|
|
29
|
+
/**
|
|
30
|
+
* A breadcrumb is a navigation help that displays the hierarchical path of the current page within a website or application. It helps users understand their location and allows them to navigate back to previous levels easily. Breadcrumbs improve usability and accessibility, especially in multi-level websites, dashboards, and e-commerce platforms.
|
|
31
|
+
*/
|
|
32
|
+
const props = defineProps<{
|
|
33
|
+
/**
|
|
34
|
+
* Allows to define the breadcrumb style
|
|
35
|
+
*/
|
|
36
|
+
appearance?: 'standard' | 'inverse';
|
|
37
|
+
/**
|
|
38
|
+
* Links of the breadcrumb
|
|
39
|
+
*/
|
|
40
|
+
links?: Array<{
|
|
41
|
+
/**
|
|
42
|
+
* The label displayed for the link.
|
|
43
|
+
*/
|
|
44
|
+
label: string;
|
|
45
|
+
/**
|
|
46
|
+
* URL for the link (for external links or the `to` prop for `router-link`).
|
|
47
|
+
*/
|
|
48
|
+
href: string;
|
|
49
|
+
/**
|
|
50
|
+
* If `true`, the link will be rendered as a `router-link` for internal navigation (Vue Router).
|
|
51
|
+
*/
|
|
52
|
+
router?: boolean;
|
|
53
|
+
}>;
|
|
54
|
+
}>();
|
|
37
55
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
props: {
|
|
46
|
-
items: {
|
|
47
|
-
type: Array,
|
|
48
|
-
required: true,
|
|
49
|
-
},
|
|
50
|
-
dark: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
default: false,
|
|
53
|
-
},
|
|
54
|
-
responsive: {
|
|
55
|
-
type: Boolean,
|
|
56
|
-
default: false,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
56
|
+
const classObject = computed(() => {
|
|
57
|
+
return {
|
|
58
|
+
[`mc-breadcrumb--${props.appearance}`]:
|
|
59
|
+
props.appearance && props.appearance != 'standard',
|
|
60
|
+
};
|
|
61
|
+
});
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
'mc-link--light': this.dark,
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
},
|
|
63
|
+
const isLastLink = (index: number) => {
|
|
64
|
+
return index === (props.links?.length ?? 0) - 1;
|
|
67
65
|
};
|
|
68
66
|
</script>
|
|
69
67
|
|
|
70
|
-
<style lang="scss">
|
|
71
|
-
@
|
|
72
|
-
@import 'components/_c.breadcrumb';
|
|
68
|
+
<style lang="scss" scoped>
|
|
69
|
+
@use '@mozaic-ds/styles/components/breadcrumb';
|
|
73
70
|
</style>
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, it, expect } from 'vitest';
|
|
3
|
+
import MButton from './MButton.vue';
|
|
4
|
+
import ChevronRight24 from '@mozaic-ds/icons-vue/src/components/ChevronRight24/ChevronRight24.vue';
|
|
5
|
+
import MLoader from '../loader/MLoader.vue';
|
|
6
|
+
|
|
7
|
+
describe('MButton component', () => {
|
|
8
|
+
it('renders with a label', () => {
|
|
9
|
+
const wrapper = mount(MButton, {
|
|
10
|
+
slots: {
|
|
11
|
+
default: 'Click Me',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
expect(wrapper.text()).toContain('Click Me');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('applies the correct appearance class based on the appearance prop', () => {
|
|
18
|
+
const wrapper = mount(MButton, {
|
|
19
|
+
props: {
|
|
20
|
+
appearance: 'accent',
|
|
21
|
+
},
|
|
22
|
+
slots: {
|
|
23
|
+
default: 'Styled Button',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
expect(wrapper.classes()).toContain('mc-button--accent');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('applies the correct size class based on the size prop', () => {
|
|
31
|
+
const wrapper = mount(MButton, {
|
|
32
|
+
props: {
|
|
33
|
+
label: 'Sized Button',
|
|
34
|
+
size: 'l',
|
|
35
|
+
},
|
|
36
|
+
slots: {
|
|
37
|
+
default: 'Sized Button',
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
expect(wrapper.classes()).toContain('mc-button--l');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('disables the button when the disabled prop is true', async () => {
|
|
45
|
+
const wrapper = mount(MButton, {
|
|
46
|
+
props: {
|
|
47
|
+
disabled: true,
|
|
48
|
+
},
|
|
49
|
+
slots: {
|
|
50
|
+
default: 'Disabled Button',
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const button = wrapper.find('button');
|
|
55
|
+
expect(button.attributes('disabled')).toBeDefined();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('applies the correct ghost class when ghost prop is true', () => {
|
|
59
|
+
const wrapper = mount(MButton, {
|
|
60
|
+
props: {
|
|
61
|
+
ghost: true,
|
|
62
|
+
},
|
|
63
|
+
slots: {
|
|
64
|
+
default: 'Ghost Button',
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
expect(wrapper.classes()).toContain('mc-button--ghost');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('applies the outlined class when outlined prop is true', () => {
|
|
72
|
+
const wrapper = mount(MButton, {
|
|
73
|
+
props: {
|
|
74
|
+
outlined: true,
|
|
75
|
+
},
|
|
76
|
+
slots: {
|
|
77
|
+
default: 'Outlined Button',
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
expect(wrapper.classes()).toContain('mc-button--outlined');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('has type="button" by default', () => {
|
|
85
|
+
const wrapper = mount(MButton, {
|
|
86
|
+
slots: {
|
|
87
|
+
default: 'Default Button',
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const button = wrapper.find('button');
|
|
92
|
+
expect(button.attributes('type')).toBe('button');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('can have type="submit" when the type prop is "submit"', () => {
|
|
96
|
+
const wrapper = mount(MButton, {
|
|
97
|
+
props: {
|
|
98
|
+
type: 'submit',
|
|
99
|
+
},
|
|
100
|
+
slots: {
|
|
101
|
+
default: 'Submit Button',
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const button = wrapper.find('button');
|
|
106
|
+
expect(button.attributes('type')).toBe('submit');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('renders with an icon in the left position', () => {
|
|
110
|
+
const wrapper = mount(MButton, {
|
|
111
|
+
props: {
|
|
112
|
+
iconPosition: 'left',
|
|
113
|
+
},
|
|
114
|
+
slots: {
|
|
115
|
+
default: 'Button with Icon',
|
|
116
|
+
icon: ChevronRight24,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const icon = wrapper.findComponent(ChevronRight24);
|
|
121
|
+
expect(icon.exists()).toBe(true);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('renders with an icon in the right position', () => {
|
|
125
|
+
const wrapper = mount(MButton, {
|
|
126
|
+
props: {
|
|
127
|
+
iconPosition: 'right',
|
|
128
|
+
},
|
|
129
|
+
slots: {
|
|
130
|
+
default: 'Button with Icon',
|
|
131
|
+
icon: ChevronRight24,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const icon = wrapper.findComponent(ChevronRight24);
|
|
136
|
+
expect(icon.exists()).toBe(true);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('renders with only an icon when iconPosition is "only"', () => {
|
|
140
|
+
const wrapper = mount(MButton, {
|
|
141
|
+
props: {
|
|
142
|
+
iconPosition: 'only',
|
|
143
|
+
},
|
|
144
|
+
slots: {
|
|
145
|
+
default: 'Icon Only Button',
|
|
146
|
+
icon: ChevronRight24,
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const icon = wrapper.findComponent(ChevronRight24);
|
|
151
|
+
expect(icon.exists()).toBe(true);
|
|
152
|
+
|
|
153
|
+
const label = wrapper.find('.mc-button__label');
|
|
154
|
+
expect(label.exists()).toBe(false);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('renders loader when isLoading prop is true', () => {
|
|
158
|
+
const wrapper = mount(MButton, {
|
|
159
|
+
props: {
|
|
160
|
+
isLoading: true,
|
|
161
|
+
},
|
|
162
|
+
slots: {
|
|
163
|
+
default: 'Loading Button',
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
const loader = wrapper.findComponent(MLoader);
|
|
168
|
+
expect(loader.exists()).toBe(true);
|
|
169
|
+
|
|
170
|
+
const label = wrapper.find('.mc-button__label');
|
|
171
|
+
expect(label.attributes('style')).toContain('visibility: hidden');
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('does not render loader when isLoading prop is false', () => {
|
|
175
|
+
const wrapper = mount(MButton, {
|
|
176
|
+
props: {
|
|
177
|
+
isLoading: false,
|
|
178
|
+
},
|
|
179
|
+
slots: {
|
|
180
|
+
default: 'Normal Button',
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const loader = wrapper.findComponent(MLoader);
|
|
185
|
+
expect(loader.exists()).toBe(false);
|
|
186
|
+
|
|
187
|
+
const label = wrapper.find('.mc-button__label');
|
|
188
|
+
expect(label.exists()).toBe(true);
|
|
189
|
+
expect(label.text()).toBe('Normal Button');
|
|
190
|
+
});
|
|
191
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
2
|
+
|
|
3
|
+
import MButton from './MButton.vue';
|
|
4
|
+
import Download24 from '@mozaic-ds/icons-vue/src/components/Download24/Download24.vue';
|
|
5
|
+
import ChevronRight24 from '@mozaic-ds/icons-vue/src/components/ChevronRight24/ChevronRight24.vue';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof MButton> = {
|
|
8
|
+
title: 'Action/Button',
|
|
9
|
+
component: MButton,
|
|
10
|
+
parameters: {
|
|
11
|
+
docs: {
|
|
12
|
+
description: {
|
|
13
|
+
component:
|
|
14
|
+
'Buttons are key interactive elements used to perform actions and can be used as standalone element, or as part of another component. Their appearance depends on the type of action required from the user and the context in which they are used.',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
args: { default: 'Button Label' },
|
|
19
|
+
argTypes: {
|
|
20
|
+
$slots: {
|
|
21
|
+
table: {
|
|
22
|
+
disable: true,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
render: (args) => ({
|
|
27
|
+
components: { MButton, Download24, ChevronRight24 },
|
|
28
|
+
setup() {
|
|
29
|
+
return { args };
|
|
30
|
+
},
|
|
31
|
+
template: `
|
|
32
|
+
<MButton
|
|
33
|
+
v-bind="args"
|
|
34
|
+
>
|
|
35
|
+
<template v-if="${'icon' in args}" v-slot:icon>${args.icon}</template>
|
|
36
|
+
<template v-if="${'default' in args}" v-slot>${args.default}</template>
|
|
37
|
+
</MButton>
|
|
38
|
+
`,
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
export default meta;
|
|
42
|
+
type Story = StoryObj<typeof MButton>;
|
|
43
|
+
|
|
44
|
+
export const Filled: Story = {};
|
|
45
|
+
|
|
46
|
+
export const Outline: Story = {
|
|
47
|
+
args: { outlined: true },
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const Ghost: Story = {
|
|
51
|
+
args: { ghost: true },
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const Icon: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
iconPosition: 'left',
|
|
57
|
+
icon: '<ChevronRight24/>',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const Loading: Story = {
|
|
62
|
+
args: {
|
|
63
|
+
isLoading: true,
|
|
64
|
+
ariaLabel: 'Loading button',
|
|
65
|
+
},
|
|
66
|
+
};
|