Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#260 update fieldset styles, template, script and stories #269

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/atoms/fieldset/Fieldset.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<fieldset
class="a-fieldset"
:aria-labelledby="`legend-${id}`"
:disabled="disabled"
>
<legend
:id="`legend-${id}`"
:class="[
legendClass,
'a-fieldset__legend'
'a-fieldset__legend',
{ 'a-fieldset__legend--hidden': hideLegend }
]"
>
{{ legendText }}
</legend>
<!-- @slot Slot for fieldset content -->
<slot />
</fieldset>
14 changes: 14 additions & 0 deletions src/atoms/fieldset/Fieldset.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ export default {
legendClass: {
type: String,
default: null
},
/**
* Visually hide legend
*/
hideLegend: {
type: Boolean,
default: false
},
/**
* Disable content of fieldset
*/
disabled: {
type: Boolean,
default: false
}
},
computed: {
Expand Down
21 changes: 14 additions & 7 deletions src/atoms/fieldset/Fieldset.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
@import '../../../assets/styles/_globals.scss';

$fieldset__border : none !default;
$fieldset__legend-margin : 0 0 25px !default;
$fieldset__legend-font-size : $font-size-large !default;
$fieldset__legend-line-height: 1.2 !default;
$fieldset__border : none !default;
$fieldset__padding : 0 !default;
$fieldset__margin : 0 !default;
$fieldset__legend-padding : 0 !default;
$fieldset__legend-margin : 0 0 $spacer--semi-medium !default;
$fieldset__legend-font-size : $font-size-large !default;
$fieldset__legend-line-height : $font-line-height !default;

.a-fieldset {
margin: 0;
padding: 0;
margin: $fieldset__margin;
padding: $fieldset__padding;
border: $fieldset__border;

&__legend {
margin: $fieldset__legend-margin;
padding: 0;
padding: $fieldset__legend-padding;
font-size: $fieldset__legend-font-size;
line-height: $fieldset__legend-line-height;

&--hidden {
@include visually-hidden();
}
}
}
11 changes: 11 additions & 0 deletions src/atoms/fieldset/Fieldset.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,15 @@ describe('Fieldset', () => {
expect(wrapper.find('.a-fieldset').exists()).toBe(true)
expect(wrapper.find('.a-fieldset > span').text()).toEqual('Fieldset content')
})

it('content is disabled when disabled prop passed', () => {
const wrapper = mount(AFieldset, {
propsData: {
legendText: 'Legend text',
disabled: true
}
})

expect(wrapper.attributes('disabled')).toBe('disabled')
})
})
14 changes: 12 additions & 2 deletions src/atoms/fieldset/Fieldset.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { storiesOf } from '@storybook/vue'
import { text } from '@storybook/addon-knobs'
import { text, boolean } from '@storybook/addon-knobs'

import AFieldset from './Fieldset.vue'

Expand All @@ -10,10 +10,20 @@ storiesOf('Atoms/Fieldset', module)
props: {
legendKnobs: {
default: text('Legend', 'Legend text')
},
disabledKnobs: {
default: boolean('Disabled', false)
},
hideLegendKnobs: {
default: boolean('Hide legend', false)
}
},
template: `
<a-fieldset :legend-text="legendKnobs">
<a-fieldset
:legend-text="legendKnobs"
:hide-legend="hideLegendKnobs"
:disabled="disabledKnobs"
>
<span>Fieldset content</span>
</a-fieldset>
`
Expand Down