Skip to content

Commit

Permalink
fix(pix-textarea) : handle no label yield case
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasferraina committed May 2, 2024
1 parent 46a018b commit cf89447
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
22 changes: 12 additions & 10 deletions addon/components/pix-textarea.hbs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<div class="pix-textarea {{if @inlineLabel ' pix-textarea--inline'}}">
<PixLabel
@for={{this.id}}
@requiredLabel={{@requiredLabel}}
@subLabel={{@subLabel}}
@size={{@size}}
@screenReaderOnly={{@screenReaderOnly}}
@inlineLabel={{@inlineLabel}}
>
{{yield to="label"}}
</PixLabel>
{{#if (has-block "label")}}
<PixLabel
@for={{this.id}}
@requiredLabel={{@requiredLabel}}
@subLabel={{@subLabel}}
@size={{@size}}
@screenReaderOnly={{@screenReaderOnly}}
@inlineLabel={{@inlineLabel}}
>
{{yield to="label"}}
</PixLabel>
{{/if}}

<div>
<textarea
Expand Down
3 changes: 3 additions & 0 deletions app/stories/pix-textarea.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Si vous utilisez le `PixTextarea` sans vouloir afficher le label, il faudra rens

<Story of={ComponentStories.textarea} height={100} />

## Without Label

<Story of={ComponentStories.textareaWithoutLabel} height={100} />

## Usage

Expand Down
22 changes: 22 additions & 0 deletions app/stories/pix-textarea.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,30 @@ const Template = (args) => {
};
};

const TemplateWithoutlabel = (args) => {
return {
template: hbs`<PixTextarea
@id={{this.id}}
@value={{this.value}}
@maxlength={{this.maxlength}}
@errorMessage={{this.errorMessage}}
@size={{this.size}}
@subLabel={{this.subLabel}}
@requiredLabel={{this.requiredLabel}}
@inlineLabel={{this.inlineLabel}}
/>`,
context: args,
};
};

export const textarea = Template.bind({});
textarea.args = {
id: 'textarea',
value: 'Contenu du textarea',
};

export const textareaWithoutLabel = TemplateWithoutlabel.bind({});
textarea.args = {
id: 'textarea-without-label',
value: 'Contenu du textarea',
};

0 comments on commit cf89447

Please sign in to comment.