From 05c3cf2ec6c028a3f5383f32f532a5220d87b5b4 Mon Sep 17 00:00:00 2001 From: rjwaberski Date: Fri, 22 May 2020 16:28:27 +0200 Subject: [PATCH] #260 update fieldset styles, template, script and stories --- src/atoms/fieldset/Fieldset.html | 5 ++++- src/atoms/fieldset/Fieldset.js | 14 ++++++++++++++ src/atoms/fieldset/Fieldset.scss | 21 ++++++++++++++------- src/atoms/fieldset/Fieldset.spec.js | 11 +++++++++++ src/atoms/fieldset/Fieldset.stories.js | 14 ++++++++++++-- 5 files changed, 55 insertions(+), 10 deletions(-) diff --git a/src/atoms/fieldset/Fieldset.html b/src/atoms/fieldset/Fieldset.html index c7698c1fb..80daf9b6a 100644 --- a/src/atoms/fieldset/Fieldset.html +++ b/src/atoms/fieldset/Fieldset.html @@ -1,15 +1,18 @@
{{ legendText }} +
diff --git a/src/atoms/fieldset/Fieldset.js b/src/atoms/fieldset/Fieldset.js index 03bba04e1..94c3feca3 100644 --- a/src/atoms/fieldset/Fieldset.js +++ b/src/atoms/fieldset/Fieldset.js @@ -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: { diff --git a/src/atoms/fieldset/Fieldset.scss b/src/atoms/fieldset/Fieldset.scss index 762a1b814..344774abe 100644 --- a/src/atoms/fieldset/Fieldset.scss +++ b/src/atoms/fieldset/Fieldset.scss @@ -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(); + } } } diff --git a/src/atoms/fieldset/Fieldset.spec.js b/src/atoms/fieldset/Fieldset.spec.js index c681a2465..388e0978f 100644 --- a/src/atoms/fieldset/Fieldset.spec.js +++ b/src/atoms/fieldset/Fieldset.spec.js @@ -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') + }) }) diff --git a/src/atoms/fieldset/Fieldset.stories.js b/src/atoms/fieldset/Fieldset.stories.js index 5adff6137..dad0e797a 100644 --- a/src/atoms/fieldset/Fieldset.stories.js +++ b/src/atoms/fieldset/Fieldset.stories.js @@ -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' @@ -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: ` - + Fieldset content `