diff --git a/src/ec/packages/ec-component-text-area/__snapshots__/text-area.test.js.snap b/src/ec/packages/ec-component-text-area/__snapshots__/text-area.test.js.snap index b8a4e9f26..f33377379 100644 --- a/src/ec/packages/ec-component-text-area/__snapshots__/text-area.test.js.snap +++ b/src/ec/packages/ec-component-text-area/__snapshots__/text-area.test.js.snap @@ -10,18 +10,17 @@ exports[`EC - Text area Default renders correctly 1`] = ` > Label - -
- Help message -
`; @@ -62,20 +60,19 @@ exports[`EC - Text area Default renders correctly with extra attributes 1`] = ` > Label +
+ Help message +
- {% if _invalid and _invalid_text is not empty %} -
{% block invalid_text _invalid_text %}
- {% endif %} - - {% if _helper_text is not empty %} -
{% block helper_text _helper_text %}
- {% endif %} {% endspaceless %} diff --git a/src/ec/packages/ec-component-text-area/text-area.story.js b/src/ec/packages/ec-component-text-area/text-area.story.js index 5e55e8a35..e622cb337 100644 --- a/src/ec/packages/ec-component-text-area/text-area.story.js +++ b/src/ec/packages/ec-component-text-area/text-area.story.js @@ -1,30 +1,41 @@ import { storiesOf } from '@storybook/html'; -import { withKnobs, text, boolean } from '@storybook/addon-knobs'; +import { withKnobs, text, select, boolean } from '@storybook/addon-knobs'; import { withNotes } from '@ecl-twig/storybook-addon-notes'; import withCode from '@ecl-twig/storybook-addon-code'; - +import specData from '@ecl/ec-specs-text-area/demo/data--default'; import textAreaDocs from './docs/text-area.md'; - import textArea from './text-area.html.twig'; +const inputWidthOptions = { + small: 's', + medium: 'm', + large: 'l', +}; + storiesOf('Components/Forms/Text area', module) .addDecorator(withKnobs) .addDecorator(withNotes) .addDecorator(withCode) .add( 'default', - () => - textArea({ - label: text('Label', 'Label'), - placeholder: text('Placeholder', 'Placeholder'), + () => { + const inputWidthSelect = select('Width', inputWidthOptions, 'm'); + + return textArea({ + label: text('Label', specData.label), + rows: text('Rows', specData.rows), + helper_text: text('Help message', "This is the input's helper text."), invalid: boolean('Invalid', false), - invalid_text: text('Error message', 'Error message'), - helper_text: text('Help message', 'Help message'), + invalid_text: text('Invalid text', 'This is the error message'), disabled: boolean('Disabled', false), - hide_label: boolean('Hide label', false), + required: boolean('Required', false), + required_text: text('Required Text', '*'), + optional_text: text('Optional text', '(optional)'), + width: inputWidthSelect, id: 'example-id', name: 'example-name', - }), + }); + }, { notes: { markdown: textAreaDocs }, } diff --git a/src/ec/packages/ec-component-text-area/text-area.test.js b/src/ec/packages/ec-component-text-area/text-area.test.js index 4cabb4692..5d8fe747f 100644 --- a/src/ec/packages/ec-component-text-area/text-area.test.js +++ b/src/ec/packages/ec-component-text-area/text-area.test.js @@ -29,6 +29,18 @@ describe('EC - Text area', () => { return expect(render(optionsWithDefaultValue)).resolves.toMatchSnapshot(); }); + test('renders correctly with extra group class names', () => { + expect.assertions(1); + + const optionsWithExtraGroupClasses = merge(options, { + extra_group_classes: 'custom-group-class custom-group-class--test', + }); + + return expect( + render(optionsWithExtraGroupClasses) + ).resolves.toMatchSnapshot(); + }); + test('renders correctly with extra class names', () => { expect.assertions(1); @@ -67,6 +79,18 @@ describe('EC - Text area', () => { return expect(render(options)).resolves.toMatchSnapshot(); }); + test('renders correctly with extra group class names', () => { + expect.assertions(1); + + const optionsWithExtraGroupClasses = merge(options, { + extra_group_classes: 'custom-group-class custom-group-class--test', + }); + + return expect( + render(optionsWithExtraGroupClasses) + ).resolves.toMatchSnapshot(); + }); + test('renders correctly with extra class names', () => { expect.assertions(1); @@ -107,6 +131,18 @@ describe('EC - Text area', () => { return expect(render(options)).resolves.toMatchSnapshot(); }); + test('renders correctly with extra group class names', () => { + expect.assertions(1); + + const optionsWithExtraGroupClasses = merge(options, { + extra_group_classes: 'custom-group-class custom-group-class--test', + }); + + return expect( + render(optionsWithExtraGroupClasses) + ).resolves.toMatchSnapshot(); + }); + test('renders correctly with extra class names', () => { expect.assertions(1); diff --git a/src/ec/packages/ec-component-text-input/text-input.html.twig b/src/ec/packages/ec-component-text-input/text-input.html.twig index a933e0f23..1c7a88292 100644 --- a/src/ec/packages/ec-component-text-input/text-input.html.twig +++ b/src/ec/packages/ec-component-text-input/text-input.html.twig @@ -44,7 +44,7 @@ {% if _invalid %} {% set _css_class = _css_class|merge(['ecl-text-input--invalid']) %} {% endif %} -{% set _css_class = _css_class|merge(['ecl-text-input--' ~ _width ]) %} +{% set _css_class = _css_class|merge(['ecl-text-input--' ~ _width]) %} {% set _css_class = _css_class|join(' ') %} {% set _extra_attributes = '' %}