forked from carbon-design-system/carbon-components-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add CvButtonSet (carbon-design-system#1123)
* feat: add CvButtonSet and tests * chore: add CvButtonSet stories Co-authored-by: Lee Chase <lee.chase@uk.ibm.com>
- Loading branch information
Showing
9 changed files
with
92 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/v3/src/components/CvButton/CvButtonSet.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { CvButtonSet, CvButton } from './'; | ||
|
||
export default { | ||
title: 'Components/CvButtonSet', | ||
component: CvButtonSet, | ||
}; | ||
|
||
const Template = (args, { argTypes }) => { | ||
return { | ||
props: Object.keys(argTypes), | ||
components: { CvButtonSet, CvButton }, | ||
template: ` | ||
<cv-button-set v-bind="$props"> | ||
<cv-button>One</cv-button> | ||
<cv-button kind="secondary">Two</cv-button> | ||
<cv-button kind="danger">Three</cv-button> | ||
</cv-button-set>`, | ||
}; | ||
}; | ||
|
||
export const Default = Template.bind({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<template> | ||
<div | ||
:class="[ | ||
`${carbonPrefix}--btn-set`, | ||
{ [`${carbonPrefix}--btn-set--stacked`]: stacked }, | ||
]" | ||
> | ||
<!-- @slot Default content of button set, expects buttons --> | ||
<slot /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { carbonPrefix } from '../../global/settings'; | ||
export default { | ||
name: 'CvButtonSet', | ||
props: { | ||
/** | ||
* Button set stacked vertically | ||
*/ | ||
stacked: Boolean, | ||
}, | ||
setup() { | ||
return { | ||
carbonPrefix, | ||
}; | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,5 +84,3 @@ export default { | |
}, | ||
}; | ||
</script> | ||
|
||
<style lang="scss"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/v3/src/components/CvButton/__tests__/CvButtonSet.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { shallowMount } from '@vue/test-utils'; | ||
import { carbonPrefix } from '../../../global/settings'; | ||
|
||
import { CvButtonSet } from '..'; | ||
|
||
describe('CvButtonSeet', () => { | ||
it('renders button set and slot', async () => { | ||
const slotContent = 'slot content'; | ||
const wrapper = shallowMount(CvButtonSet, { | ||
slots: { | ||
default: slotContent, | ||
}, | ||
}); | ||
|
||
const buttonSet = wrapper.find(`.${carbonPrefix}--btn-set`); | ||
expect(buttonSet).not.toBeUndefined(); | ||
expect(buttonSet.text()).toBe(slotContent); | ||
}); | ||
|
||
it('renders button set stacked and slot', async () => { | ||
const slotContent = 'slot content'; | ||
const wrapper = shallowMount(CvButtonSet, { | ||
slots: { | ||
default: slotContent, | ||
}, | ||
props: { | ||
stacked: true, | ||
}, | ||
}); | ||
|
||
const buttonSet = wrapper.find(`.${carbonPrefix}--btn-set`); | ||
expect(buttonSet).not.toBeUndefined(); | ||
expect(buttonSet.classes()).toContain(`${carbonPrefix}--btn-set--stacked`); | ||
expect(buttonSet.text()).toBe(slotContent); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import CvButton from './CvButton'; | ||
import CvIconButton from './CvIconButton'; | ||
import CvButtonSet from './CvButtonSet'; | ||
import CvButtonConsts from './consts'; | ||
|
||
export { CvButton, CvButtonConsts, CvIconButton }; | ||
export { CvButton, CvButtonConsts, CvButtonSet, CvIconButton }; | ||
export default CvButton; |