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

[FEATURE] Gérer l'abscence de label pour les inputs et textarea #617

Merged
merged 2 commits into from
May 2, 2024
Merged
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
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
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
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',
};
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',
};