Skip to content

Commit

Permalink
fix: handle no label yield case
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasferraina committed Apr 30, 2024
1 parent aac50b7 commit 1c3b5f0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
22 changes: 12 additions & 10 deletions addon/components/pix-input.hbs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<div class="pix-input {{if @inlineLabel ' pix-input--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>
<div class="pix-input__container">
<input
Expand Down
4 changes: 4 additions & 0 deletions app/stories/pix-input.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ En readonly, l'input n'est pas modifiable, mais il est toujours focusable et est

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

## Without label

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

## Usage

```html
Expand Down
23 changes: 23 additions & 0 deletions app/stories/pix-input.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@ const Template = (args) => {
};
};

const TemplateWithoutLabel = (args) => {
return {
template: hbs`<PixInput
@id={{this.id}}
@errorMessage={{this.errorMessage}}
placeholder='Jeanne, Pierre ...'
@validationStatus={{this.validationStatus}}
@size={{this.size}}
disabled={{this.disabled}}
readonly={{this.readonly}}
@subLabel={{this.subLabel}}
@inlineLabel={{this.inlineLabel}}
@requiredLabel={{this.requiredLabel}}
/>`,
context: args,
};
};

export const Default = Template.bind({});
Default.args = {
id: 'first-name',
Expand Down Expand Up @@ -150,3 +168,8 @@ withRequiredLabel.args = {
label: 'Prénom',
requiredLabel: 'Champ obligatoire',
};

export const withoutLabel = TemplateWithoutLabel.bind({});
withoutLabel.args = {
id: 'first-name',
};

0 comments on commit 1c3b5f0

Please sign in to comment.