diff --git a/agnosticui-svelte/src/stories/Button.stories.js b/agnosticui-svelte/src/stories/Button.stories.js index 0e84aebc2..58d16ba66 100644 --- a/agnosticui-svelte/src/stories/Button.stories.js +++ b/agnosticui-svelte/src/stories/Button.stories.js @@ -1,4 +1,3 @@ -import Button from './Button.svelte'; import ButtonSlot from './ButtonSlot.svelte'; export default { diff --git a/agnosticui-vue/src/ButtonExamples.vue b/agnosticui-vue/src/ButtonExamples.vue index 42bbb97e1..416dfbc6a 100644 --- a/agnosticui-vue/src/ButtonExamples.vue +++ b/agnosticui-vue/src/ButtonExamples.vue @@ -1,46 +1,40 @@ diff --git a/agnosticui-vue/src/stories/Button.stories.js b/agnosticui-vue/src/stories/Button.stories.js index aabe0d82c..6c3d80c9c 100644 --- a/agnosticui-vue/src/stories/Button.stories.js +++ b/agnosticui-vue/src/stories/Button.stories.js @@ -1,23 +1,10 @@ -import AgnosticButton from './Button.vue'; -import ButtonsDisabled from './ButtonsDisabled.vue'; -import { action } from '@storybook/addon-actions'; +import Button from './Button.vue'; +import ButtonsDisabled from './ButtonsDisabledTests.vue'; +import ButtonTests from './ButtonTests.vue'; export default { title: 'Button', - component: AgnosticButton, - argTypes: { - label: { control: 'text' }, - mode: { control: 'text' }, - isBordered: { control: 'boolean' }, - isBlock: { control: 'boolean' }, - isDisabled: { control: 'boolean' }, - isRaised: { control: 'boolean' }, - isRounded: { control: 'boolean' }, - isSkinned: { control: 'boolean' }, - size: { - control: { type: 'select', options: ['small', 'large'] }, - }, - }, + component: Button, }; // Storybook does not appear to render code snippets for Vue/Svelte automagically @@ -27,175 +14,63 @@ export default { // some sort of Storybook custom vue loader. So, my closest success has been to use the // `docs.source.code` mechanism you see below. It's not ideal since it requires duplication // of code which could likely diverge, but it's the best comprimise I've found so far. -export const ButtonsDisabledAll = () => ({ - title: 'Buttons Disabled', - components: { ButtonsDisabled }, - template: ``, +export const Buttons = () => ({ + title: 'Buttons', + components: { ButtonTests }, + template: ``, + }); -ButtonsDisabledAll.parameters = { +Buttons.parameters = { docs: { source: { code: ` - - - - - ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + ` } - }, + } } -const Template = (args, { argTypes }) => ({ - props: Object.keys(argTypes), - components: { AgnosticButton }, - template: '', - methods: { - onClick: action('onClick'), - }, +export const ButtonTypesDisabled = () => ({ + title: 'Buttons Disabled', + components: { ButtonsDisabled }, + template: ``, }); - -export const Primary = Template.bind({}); -Primary.args = { - label: 'Primary', - mode: 'primary', -}; -Primary.parameters = { +ButtonTypesDisabled.parameters = { docs: { source: { - code: `` + code: ` + + + + + ` } }, } -export const PrimaryBordered = Template.bind({}); -PrimaryBordered.args = { - label: 'Primary Bordered', - mode: 'primary', - isBordered: true, -}; - -export const PrimaryBlock = Template.bind({}); -PrimaryBlock.args = { - mode: 'primary', - label: 'Block (aka Stacked)', - isBlock: true, -}; - -export const PrimaryRounded = Template.bind({}); -PrimaryRounded.args = { - label: 'Primary Rounded', - mode: 'primary', - isRounded: true, -}; - -export const PrimaryRoundedRaised = Template.bind({}); -PrimaryRoundedRaised.args = { - label: 'Primary Rounded', - mode: 'primary', - isRounded: true, - isRaised: true, -}; - -export const PrimaryBorderedRounded = Template.bind({}); -PrimaryBorderedRounded.args = { - label: 'Primary Borded Rounded', - mode: 'primary', - isBordered: true, - isRounded: true, -}; - -export const Secondary = Template.bind({}); -Secondary.args = { - label: 'Secondary', - mode: 'secondary', -}; - -export const SecondaryBordered = Template.bind({}); -SecondaryBordered.args = { - label: 'Secondary Bordered', - mode: 'secondary', - isBordered: true, -}; - -export const SecondaryRounded = Template.bind({}); -SecondaryRounded.args = { - label: 'Secondary Rounded', - mode: 'secondary', - isRounded: true, -}; - -export const SecondaryRoundedRaised = Template.bind({}); -SecondaryRoundedRaised.args = { - label: 'Secondary Rounded', - mode: 'secondary', - isRounded: true, - isRaised: true, -}; - -export const SecondaryBorderedRounded = Template.bind({}); -SecondaryBorderedRounded.args = { - label: 'Secondary Borded Rounded', - mode: 'secondary', - isBordered: true, - isRounded: true, -}; - -export const Default = Template.bind({}); -Default.args = { - label: 'Default', -}; - -export const DefaultRaised = Template.bind({}); -DefaultRaised.args = { - label: 'Default Raised', - isRaised: true, -}; - -export const DefaultBordered = Template.bind({}); -DefaultBordered.args = { - label: 'Default Bordered', - isBordered: true, -}; - -export const DefaultRounded = Template.bind({}); -DefaultRounded.args = { - label: 'Default Rounded', - isRounded: true, -}; - -export const DefaultBorderedRounded = Template.bind({}); -DefaultBorderedRounded.args = { - label: 'Default Bordered Rounded', - isBordered: true, - isRounded: true, -}; - -export const Disabled = Template.bind({}); -Disabled.args = { - label: 'Disabled', - isDisabled: true, -}; - -export const Large = Template.bind({}); -Large.args = { - size: 'large', - label: 'Large', -}; - -export const Small = Template.bind({}); -Small.args = { - size: 'small', - label: 'Small', -}; - -export const ButtonBlank = Template.bind({}); -ButtonBlank.args = { - label: 'Cancel', - isBlank: true, -}; - -export const ButtonBase = Template.bind({}); -ButtonBase.args = { - label: 'Button Base Only (no skin)', - isSkinned: false, -}; diff --git a/agnosticui-vue/src/stories/Button.test.js b/agnosticui-vue/src/stories/Button.test.js index 40762a62c..ab4989441 100644 --- a/agnosticui-vue/src/stories/Button.test.js +++ b/agnosticui-vue/src/stories/Button.test.js @@ -1,5 +1,5 @@ -import { render, fireEvent, screen } from '@testing-library/vue' -import Button from './Button.vue' +import { render, fireEvent, screen } from '@testing-library/vue'; +import Button from './Button.vue'; /** * Initially, Storybook addon snapshot testing was working well. However, @@ -15,156 +15,138 @@ import Button from './Button.vue' test('snapshot', () => { const rendered = render(Button, { - props: { - label: 'Go' - } + props: {} }); expect(rendered).toMatchSnapshot(); }) // Debug Cheat: screen.debug(screen.getByText('Go');) test('onClick fires', async () => { - const { getByText, emitted } = render(Button, { - props: { - label: 'Go' - } + const { getByRole, emitted } = render(Button, { + props: {} }); - expect(screen.queryByText('Go')).toBeTruthy() - const button = getByText('Go'); + const button = getByRole('button'); await fireEvent(button, new Event('click')) expect(emitted()).toHaveProperty('click') }); test('primary', async () => { - const { getByText } = render(Button, { + const { getByRole } = render(Button, { props: { - label: 'Go', mode: 'primary' } }); - const button = getByText('Go'); + const button = getByRole('button'); expect(button.classList.contains('btn-primary')).toBeTruthy() }); test('secondary', async () => { - const { getByText } = render(Button, { + const { getByRole } = render(Button, { props: { - label: 'Go', mode: 'secondary' } }); - const button = getByText('Go'); + const button = getByRole('button'); expect(button.classList.contains('btn-secondary')).toBeTruthy() }); test('block', async () => { - const { getByText } = render(Button, { + const { getByRole } = render(Button, { props: { - label: 'Go', isBlock: true } }); - const button = getByText('Go'); + const button = getByRole('button'); expect(button.classList.contains('btn-block')).toBeTruthy() }); test('bordered', async () => { - const { getByText } = render(Button, { + const { getByRole } = render(Button, { props: { - label: 'Go', isBordered: true } }); - const button = getByText('Go'); + const button = getByRole('button'); expect(button.classList.contains('btn-bordered')).toBeTruthy() }); test('raised', async () => { - const { getByText } = render(Button, { + const { getByRole } = render(Button, { props: { - label: 'Go', isRaised: true } }); - const button = getByText('Go'); + const button = getByRole('button'); expect(button.classList.contains('btn-raised')).toBeTruthy() }); test('blank', async () => { - const { getByText } = render(Button, { + const { getByRole } = render(Button, { props: { - label: 'Go', isBlank: true } }); - const button = getByText('Go'); + const button = getByRole('button'); expect(button.classList.contains('btn-blank')).toBeTruthy() }); test('rouned', async () => { - const { getByText } = render(Button, { + const { getByRole } = render(Button, { props: { - label: 'Go', isRounded: true } }); - const button = getByText('Go'); + const button = getByRole('button'); expect(button.classList.contains('btn-rounded')).toBeTruthy() }); test('disabled', async () => { - const { getByText } = render(Button, { + const { getByRole } = render(Button, { props: { - label: 'Go', isDisabled: true } }); - const button = getByText('Go'); + const button = getByRole('button'); expect(button.classList.contains('disabled')).toBeTruthy() }); test('default type is button', async () => { - const { getByText } = render(Button, { - props: { - label: 'Go', - } + const { getByRole } = render(Button, { + props: {} }); - const button = getByText('Go'); + const button = getByRole('button'); expect(button.getAttribute('type')).toEqual('button'); }); test('type submit', async () => { - const { getByText } = render(Button, { + const { getByRole } = render(Button, { props: { - label: 'Go', type: 'submit' } }); - const button = getByText('Go'); + const button = getByRole('button'); expect(button.getAttribute('type')).toEqual('submit'); }); test('small', async () => { - const { getByText } = render(Button, { + const { getByRole } = render(Button, { props: { - label: 'Go', size: 'small' } }); - const button = getByText('Go'); + const button = getByRole('button'); expect(button.classList.contains('btn-small')).toBeTruthy(); }); test('custom css class', async () => { - const { getByText } = render(Button, { + const { getByRole } = render(Button, { props: { - label: 'Go', css: 'my-class' } }); - const button = getByText('Go'); + const button = getByRole('button'); expect(button.classList.contains('my-class')).toBeTruthy(); }); diff --git a/agnosticui-vue/src/stories/Button.vue b/agnosticui-vue/src/stories/Button.vue index 8f4303cfd..1e4680371 100644 --- a/agnosticui-vue/src/stories/Button.vue +++ b/agnosticui-vue/src/stories/Button.vue @@ -1,8 +1,6 @@ @@ -10,10 +8,6 @@ export default { name: "agnostic-button", props: { - label: { - type: String, - required: true, - }, mode: { type: String, default: "", @@ -46,14 +40,6 @@ export default { type: Boolean, default: true, }, - isIconLeft: { - type: Boolean, - default: false, - }, - isIconRight: { - type: Boolean, - default: false, - }, type: { type: String, default: "button", @@ -79,8 +65,6 @@ export default { [this.$style["btn-block"]]: this.isBlock, [this.$style["btn-rounded"]]: this.isRounded, [this.$style["btn-raised"]]: this.isRaised, - [this.$style["btn-icon-left"]]: this.isIconLeft, - [this.$style["btn-icon-right"]]: this.isIconRight, [this.$style["btn-primary"]]: this.mode === "primary", [this.$style["btn-secondary"]]: this.mode === "secondary", [`${this.css}`]: !!this.css, diff --git a/agnosticui-vue/src/stories/ButtonGroup.stories.js b/agnosticui-vue/src/stories/ButtonGroup.stories.js index 14ee9b17e..f675e0ad0 100644 --- a/agnosticui-vue/src/stories/ButtonGroup.stories.js +++ b/agnosticui-vue/src/stories/ButtonGroup.stories.js @@ -1,11 +1,73 @@ import ButtonGroup from "./ButtonGroup.vue"; -import Button from "./Button.vue"; +import ButtonGroupTests from "./ButtonGroupTests.vue"; export default { title: 'Button Groups', component: ButtonGroup, }; + +export const All = () => ({ + title: 'Button Groups', + components: { ButtonGroupTests }, + template: ``, +}); +All.parameters = { + docs: { + source: { + code: ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ({ components: { ButtonGroup, Button }, template: ' + + ` + } + } +}; + diff --git a/agnosticui-vue/src/stories/ButtonIconLeft.vue b/agnosticui-vue/src/stories/ButtonIconLeft.vue deleted file mode 100644 index f5f6bc159..000000000 --- a/agnosticui-vue/src/stories/ButtonIconLeft.vue +++ /dev/null @@ -1,32 +0,0 @@ - - - \ No newline at end of file diff --git a/agnosticui-vue/src/stories/ButtonIconRight.vue b/agnosticui-vue/src/stories/ButtonIconRight.vue index 9bf2169f5..7a70983df 100644 --- a/agnosticui-vue/src/stories/ButtonIconRight.vue +++ b/agnosticui-vue/src/stories/ButtonIconRight.vue @@ -1,33 +1,34 @@ \ No newline at end of file diff --git a/agnosticui-vue/src/stories/ButtonIconTests.vue b/agnosticui-vue/src/stories/ButtonIconTests.vue new file mode 100644 index 000000000..59b971bc9 --- /dev/null +++ b/agnosticui-vue/src/stories/ButtonIconTests.vue @@ -0,0 +1,65 @@ + + + + \ No newline at end of file diff --git a/agnosticui-vue/src/stories/ButtonTests.vue b/agnosticui-vue/src/stories/ButtonTests.vue new file mode 100644 index 000000000..cb733b299 --- /dev/null +++ b/agnosticui-vue/src/stories/ButtonTests.vue @@ -0,0 +1,50 @@ + + + diff --git a/agnosticui-vue/src/stories/ButtonsDisabled.vue b/agnosticui-vue/src/stories/ButtonsDisabled.vue deleted file mode 100644 index 376a1f337..000000000 --- a/agnosticui-vue/src/stories/ButtonsDisabled.vue +++ /dev/null @@ -1,16 +0,0 @@ - - - diff --git a/agnosticui-vue/src/stories/ButtonsDisabledTests.vue b/agnosticui-vue/src/stories/ButtonsDisabledTests.vue new file mode 100644 index 000000000..f447170f9 --- /dev/null +++ b/agnosticui-vue/src/stories/ButtonsDisabledTests.vue @@ -0,0 +1,16 @@ + + + diff --git a/agnosticui-vue/src/stories/__snapshots__/Button.test.js.snap b/agnosticui-vue/src/stories/__snapshots__/Button.test.js.snap index cb486e76f..eefac50fc 100644 --- a/agnosticui-vue/src/stories/__snapshots__/Button.test.js.snap +++ b/agnosticui-vue/src/stories/__snapshots__/Button.test.js.snap @@ -7,22 +7,14 @@ Object { + /> , "container":
+ />
, "debug": [Function], "emitted": [Function],