@1024pix/pix-ui 13.5.0 → 14.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Pix-UI Changelog
2
2
 
3
+ ## v14.1.0 (12/04/2022)
4
+
5
+
6
+ ### :rocket: Amélioration
7
+ - [#213](https://github.com/1024pix/pix-ui/pull/213) [FEATURE] Retirer l'option d'ajouter une icône dans le composant Pix Input (PIX-4766).
8
+
9
+ ## v14.0.0 (12/04/2022)
10
+
11
+
12
+ ### :coffee: Autre
13
+ - [#212](https://github.com/1024pix/pix-ui/pull/212) [BREAKING_CHANGES][BUGFIX] Ajouter un aria-label au Pix Input (PIX-4759).
14
+
15
+ ## v13.5.1 (12/04/2022)
16
+
17
+
18
+ ### :bug: Correction
19
+ - [#211](https://github.com/1024pix/pix-ui/pull/211) [BUGFIX] Ne permettre qu'un label dans les composants Pix Input et Input Password (PIX-4125).
20
+
3
21
  ## v13.5.0 (11/04/2022)
4
22
 
5
23
 
@@ -4,12 +4,14 @@
4
4
  {{#if @requiredLabel}}
5
5
  <abbr title={{@requiredLabel}} class="mandatory-mark" aria-hidden="true">*</abbr>
6
6
  {{/if}}
7
+
7
8
  {{this.label}}
9
+
10
+ {{#if @information}}
11
+ <span class="pix-input__information">{{@information}}</span>
12
+ {{/if}}
8
13
  </label>
9
14
  {{/if}}
10
- {{#if @information}}
11
- <label for={{this.id}} class="pix-input__information">{{@information}}</label>
12
- {{/if}}
13
15
  <div
14
16
  class="pix-input-password__container
15
17
  {{if @errorMessage 'pix-input-password__error-container'}}
@@ -27,6 +29,7 @@
27
29
  aria-label={{this.ariaLabel}}
28
30
  aria-required="{{if @requiredLabel true false}}"
29
31
  required={{if @requiredLabel true false}}
32
+ aria-describedby={{if @errorMessage "text-input-password-error"}}
30
33
  ...attributes
31
34
  />
32
35
 
@@ -44,6 +47,6 @@
44
47
  </div>
45
48
 
46
49
  {{#if @errorMessage}}
47
- <label for={{this.id}} class="pix-input__error-message">{{@errorMessage}}</label>
50
+ <p id="text-input-password-error" class="pix-input__error-message">{{@errorMessage}}</p>
48
51
  {{/if}}
49
52
  </div>
@@ -4,33 +4,33 @@
4
4
  {{#if @requiredLabel}}
5
5
  <abbr title={{@requiredLabel}} class="mandatory-mark" aria-hidden="true">*</abbr>
6
6
  {{/if}}
7
+
7
8
  {{@label}}
9
+
10
+ {{#if @information}}
11
+ <span class="pix-input__information">{{@information}}</span>
12
+ {{/if}}
8
13
  </label>
9
14
  {{/if}}
10
- {{#if @information}}
11
- <label for={{this.id}} class="pix-input__information">{{@information}}</label>
12
- {{/if}}
13
15
 
14
16
  <div class="pix-input__container">
15
17
  <input
16
18
  id={{this.id}}
17
- class={{this.className}}
19
+ class={{if @errorMessage "pix-input__input--error"}}
18
20
  value={{@value}}
21
+ aria-label={{this.ariaLabel}}
19
22
  aria-required="{{if @requiredLabel true false}}"
20
23
  required={{if @requiredLabel true false}}
24
+ aria-describedby={{if @errorMessage "text-input-error"}}
21
25
  ...attributes
22
26
  />
23
27
 
24
28
  {{#if @errorMessage}}
25
29
  <FaIcon @icon="times" class="pix-input__error-icon" />
26
30
  {{/if}}
27
-
28
- {{#if @icon}}
29
- <FaIcon @icon={{@icon}} class="pix-input__icon {{if @isIconLeft 'pix-input__icon--left'}}" />
30
- {{/if}}
31
31
  </div>
32
32
 
33
33
  {{#if @errorMessage}}
34
- <label for={{this.id}} class="pix-input__error-message">{{@errorMessage}}</label>
34
+ <p id="text-input-error" class="pix-input__error-message">{{@errorMessage}}</p>
35
35
  {{/if}}
36
36
  </div>
@@ -1,5 +1,7 @@
1
1
  import Component from '@glimmer/component';
2
2
 
3
+ const ERROR_MESSAGE = 'ERROR in PixInput component, you must provide @label or @ariaLabel params';
4
+
3
5
  export default class PixInput extends Component {
4
6
  get id() {
5
7
  if (!this.args.id || !this.args.id.toString().trim()) {
@@ -8,11 +10,17 @@ export default class PixInput extends Component {
8
10
  return this.args.id;
9
11
  }
10
12
 
11
- get className() {
12
- const classNames = [];
13
- this.args.errorMessage && classNames.push('pix-input__input--error');
14
- this.args.icon && classNames.push('pix-input__input--icon');
15
- this.args.isIconLeft && classNames.push('pix-input__input--icon-left');
16
- return classNames.join(' ');
13
+ get label() {
14
+ if (!this.args.label && !this.args.ariaLabel) {
15
+ throw new Error(ERROR_MESSAGE);
16
+ }
17
+ return this.args.label;
18
+ }
19
+
20
+ get ariaLabel() {
21
+ if (!this.args.label && !this.args.ariaLabel) {
22
+ throw new Error(ERROR_MESSAGE);
23
+ }
24
+ return this.args.label ? null : this.args.ariaLabel;
17
25
  }
18
26
  }
@@ -6,39 +6,25 @@
6
6
  position: relative;
7
7
 
8
8
  &__label {
9
- @include label();
9
+ font-family: $font-roboto;
10
+ font-size: 0.875rem;
11
+ color: $grey-70;
12
+ margin-bottom: 4px;
10
13
  }
11
14
 
12
15
  &__information {
13
16
  font-family: $font-roboto;
14
17
  font-size: 0.75rem;
18
+ margin-top: 4px;
15
19
  color: $blue-zodiac;
16
- margin-bottom: 4px;
20
+
21
+ display: block;
17
22
  }
18
23
 
19
24
  &__container {
20
25
  position: relative;
21
26
  }
22
27
 
23
- svg.pix-input__icon {
24
- position: absolute;
25
- bottom: 9px;
26
- right: 6px;
27
- color: $grey-25;
28
- font-size: 1.125rem;
29
- width: 18px;
30
- height: 18px;
31
-
32
- &--left {
33
- left: 6px;
34
- }
35
- }
36
-
37
- svg ~ svg.pix-input__icon {
38
- right: calc(6px + 12px + 2px);
39
- margin-right: 8px;
40
- }
41
-
42
28
  svg.pix-input__error-icon {
43
29
  position: absolute;
44
30
  bottom: 10px;
@@ -54,8 +40,12 @@
54
40
 
55
41
  &__error-message {
56
42
  @include errorMessage();
57
- margin-top: 4px;
43
+ margin-bottom: 0;
58
44
  bottom: calc(-4px - 1px - 0.75rem);
45
+
46
+ &.pix-input__error-message {
47
+ margin-top:4px;
48
+ }
59
49
  }
60
50
 
61
51
  input {
@@ -75,17 +65,5 @@
75
65
  padding-right: 32px;
76
66
  @include formElementInError();
77
67
  }
78
-
79
- &.pix-input__input--icon {
80
- padding-right: 32px;
81
- }
82
-
83
- &.pix-input__input--icon.pix-input__input--icon-left {
84
- padding-left: 32px;
85
- }
86
-
87
- &.pix-input__input--error.pix-input__input--icon:not(.pix-input__input--icon-left) {
88
- padding-right: 32px;
89
- }
90
68
  }
91
69
  }
@@ -13,7 +13,7 @@ export const form = (args) => {
13
13
  <PixMultiSelect
14
14
  @title="Votre notation en étoiles..."
15
15
  @id="form__pix-mutli-select"
16
- @label="A quel point aimez vous Pix-UI ?"
16
+ @label="A quel point aimez vous Pix UI ?"
17
17
  @onSelect={{onSelect}}
18
18
  @selected={{selected}}
19
19
  @options={{options}} as |star|
@@ -1,4 +1,4 @@
1
- import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs/blocks';
1
+ import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
2
2
  import centered from '@storybook/addon-centered/ember';
3
3
  import * as stories from './form.stories.js';
4
4
 
@@ -12,5 +12,5 @@ import * as stories from './form.stories.js';
12
12
  Un formulaire complet avec les composants Pix UI :
13
13
 
14
14
  <Canvas>
15
- <Story name="Form" story={stories.form} height={600} />
15
+ <Story name="Form" story={stories.form} height={700} />
16
16
  </Canvas>
@@ -72,7 +72,7 @@ export const argTypes = {
72
72
  },
73
73
  ariaLabel: {
74
74
  name: 'ariaLabel',
75
- description: "L'action du bouton, pour l'accessibilité. Requis si label n'est pas définit.",
75
+ description: "L'action du champ, pour l'accessibilité. Requis si label n'est pas définit.",
76
76
  type: { name: 'string', required: true },
77
77
  defaultValue: null,
78
78
  },
@@ -8,10 +8,9 @@ export const Template = (args) => {
8
8
  @label={{label}}
9
9
  @information={{information}}
10
10
  @errorMessage={{errorMessage}}
11
- @icon={{icon}}
12
- @isIconLeft={{isIconLeft}}
13
11
  placeholder='Jeanne, Pierre ...'
14
12
  @requiredLabel={{requiredLabel}}
13
+ @ariaLabel={{ariaLabel}}
15
14
  />
16
15
  `,
17
16
  context: args,
@@ -21,6 +20,7 @@ export const Template = (args) => {
21
20
  export const Default = Template.bind({});
22
21
  Default.args = {
23
22
  id: 'firstName',
23
+ ariaLabel: 'Prénom',
24
24
  };
25
25
 
26
26
  export const withLabel = Template.bind({});
@@ -38,13 +38,6 @@ withErrorMessage.args = {
38
38
  errorMessage: "un message d'erreur",
39
39
  };
40
40
 
41
- export const withIcon = Template.bind({});
42
- withIcon.args = {
43
- id: 'firstName',
44
- label: 'Prénom',
45
- icon: 'eye',
46
- };
47
-
48
41
  export const withRequiredLabel = Template.bind({});
49
42
  withRequiredLabel.args = {
50
43
  id: 'firstName',
@@ -53,6 +46,12 @@ withRequiredLabel.args = {
53
46
  };
54
47
 
55
48
  export const argTypes = {
49
+ ariaLabel: {
50
+ name: 'ariaLabel',
51
+ description: "L'action du champ, pour l'accessibilité. Requis si label n'est pas définit.",
52
+ type: { name: 'string', required: true },
53
+ defaultValue: null,
54
+ },
56
55
  id: {
57
56
  name: 'id',
58
57
  description: 'Identifiant du champ permettant de lui attacher un label',
@@ -83,23 +82,6 @@ export const argTypes = {
83
82
  type: { name: 'string', required: false },
84
83
  defaultValue: null,
85
84
  },
86
- icon: {
87
- name: 'icon',
88
- description: "Affiche l'icône choisie à la fin de l'input",
89
- type: { name: 'string', required: false },
90
- defaultValue: null,
91
- },
92
- isIconLeft: {
93
- name: 'isIconLeft',
94
- description: "Permet d'afficher l'icône choisie sur la gauche",
95
- type: { name: 'boolean', required: false },
96
- control: { type: 'boolean' },
97
- defaultValue: false,
98
- table: {
99
- type: { summary: 'boolean' },
100
- defaultValue: { summary: 'false' },
101
- },
102
- },
103
85
  requiredLabel: {
104
86
  name: 'requiredLabel',
105
87
  description:
@@ -14,6 +14,12 @@ import * as stories from './pix-input.stories.js';
14
14
 
15
15
  Le PixInput permet de créer un champ de texte.
16
16
 
17
+ ## Accessibilité
18
+
19
+ Si vous utilisez le `PixInput` sans label alors il faut renseigner le paramètre `ariaLabel`, sinon le composant renvoie une erreur.
20
+
21
+ > Si vous renseignez les paramètres label et ariaLabel ensemble, ariaLabel sera nullifié.
22
+
17
23
 
18
24
  ## Default
19
25
 
@@ -33,12 +39,6 @@ Le PixInput permet de créer un champ de texte.
33
39
  <Story story={stories.withErrorMessage} height={130} />
34
40
  </Canvas>
35
41
 
36
- ## With icon
37
-
38
- <Canvas>
39
- <Story story={stories.withIcon} height={130} />
40
- </Canvas>
41
-
42
42
  ## With required label
43
43
 
44
44
  <Canvas>
@@ -53,8 +53,6 @@ Le PixInput permet de créer un champ de texte.
53
53
  @label='Prénom'
54
54
  @information='Complément du label'
55
55
  @errorMessage='Un message d`erreur'
56
- @icon='eye'
57
- @isIconLeft={{false}}
58
56
  @requiredLabel='Champ obligatoire'
59
57
  />
60
58
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "13.5.0",
3
+ "version": "14.1.0",
4
4
  "description": "Pix-UI is the implementation of Pix design principles and guidelines for its products.",
5
5
  "keywords": [
6
6
  "ember-addon"