@1024pix/pix-ui 30.0.0 → 31.0.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,17 @@
1
1
  # Pix-UI Changelog
2
2
 
3
+ ## v31.0.0 (14/04/2023)
4
+
5
+
6
+ ### :building_construction: Tech
7
+ - [#381](https://github.com/1024pix/pix-ui/pull/381) [TECH] Modification de la valeur du Design Token warning-60 et suppression des placeholders de font-weight (PIX-7666).
8
+
9
+ ## v30.1.0 (14/04/2023)
10
+
11
+
12
+ ### :bug: Correction
13
+ - [#377](https://github.com/1024pix/pix-ui/pull/377) [BUGFIX] Faire en sorte que la dropdown du select puisse s'ouvrir ailleurs qu'en bas si besoin (PIX-7237)
14
+
3
15
  ## v30.0.0 (05/04/2023)
4
16
 
5
17
 
@@ -23,122 +23,125 @@
23
23
  {{/if}}
24
24
  </div>
25
25
  {{/if}}
26
+ <PopperJS @placement={{@placement}} as |reference popover|>
27
+ <button
28
+ {{reference}}
29
+ type="button"
30
+ id={{this.selectId}}
31
+ class={{this.className}}
32
+ {{on "click" this.toggleDropdown}}
33
+ aria-expanded={{this.isAriaExpanded}}
34
+ aria-controls={{this.listId}}
35
+ aria-disabled={{@isDisabled}}
36
+ >
37
+ <span class="pix-select-button__text">{{this.placeholder}}</span>
26
38
 
27
- <button
28
- type="button"
29
- id={{this.selectId}}
30
- class={{this.className}}
31
- {{on "click" this.toggleDropdown}}
32
- aria-expanded={{this.isAriaExpanded}}
33
- aria-controls={{this.listId}}
34
- aria-disabled={{@isDisabled}}
35
- >
36
- <span class="pix-select-button__text">{{this.placeholder}}</span>
39
+ <FaIcon
40
+ class="pix-select-button__dropdown-icon"
41
+ @icon={{if this.isExpanded "chevron-up" "chevron-down"}}
42
+ />
43
+ </button>
44
+ <div
45
+ {{popover}}
46
+ class="pix-select__dropdown{{unless this.isExpanded ' pix-select__dropdown--closed'}}"
47
+ id={{this.dropDownId}}
48
+ {{on "transitionend" this.focus}}
49
+ >
50
+ {{#if @isSearchable}}
51
+ <div class="pix-select__search">
52
+ <FaIcon class="pix-select-search__icon" @icon="magnifying-glass" />
53
+ <label class="screen-reader-only" for={{this.searchId}}>{{@searchLabel}}</label>
54
+ <input
55
+ class="pix-select-search__input"
56
+ id={{this.searchId}}
57
+ autocomplete="off"
58
+ tabindex={{if this.isExpanded "0" "-1"}}
59
+ placeholder={{@searchPlaceholder}}
60
+ {{on "input" this.setSearchValue}}
61
+ />
62
+ </div>
63
+ {{/if}}
64
+ <ul role="listbox" id={{this.listId}} class="pix-select__options">
65
+ <li
66
+ class="pix-select-options-category__option{{unless
67
+ @value
68
+ ' pix-select-options-category__option--selected'
69
+ }}{{unless this.displayDefaultOption ' pix-select-options-category__option--hidden'}}"
70
+ role="option"
71
+ tabindex={{if this.isDefaultOptionHidden "-1" "0"}}
72
+ aria-selected={{if @value "false" "true"}}
73
+ {{on "click" (fn this.onChange this.defaultOption)}}
74
+ {{on-enter-action (fn this.onChange this.defaultOption)}}
75
+ {{on-space-action (fn this.onChange this.defaultOption)}}
76
+ >
77
+ {{@placeholder}}
78
+ </li>
79
+ {{#if this.results}}
80
+ {{#if this.displayCategory}}
81
+ {{#each this.results as |element index|}}
82
+ <ul
83
+ class="pix-select-options__category"
84
+ role="group"
85
+ aria-labelledby={{if this.displayCategory (concat "cat-" this.selectId "-" index)}}
86
+ >
87
+ {{#if this.displayCategory}}
88
+ {{! template-lint-disable no-invalid-role }}
89
+ {{!https://www.w3.org/WAI/ARIA/apg/example-index/listbox/listbox-grouped.html}}
90
+ <li
91
+ class="pix-select-options-category__name"
92
+ role="presentation"
93
+ id={{concat "cat-" this.selectId "-" index}}
94
+ >
95
+ {{element.category}}
96
+ </li>
97
+ {{/if}}
37
98
 
38
- <FaIcon
39
- class="pix-select-button__dropdown-icon"
40
- @icon={{if this.isExpanded "chevron-up" "chevron-down"}}
41
- />
42
- </button>
43
- <div
44
- class="pix-select__dropdown{{unless this.isExpanded ' pix-select__dropdown--closed'}}"
45
- id={{this.dropDownId}}
46
- {{on "transitionend" this.focus}}
47
- >
48
- {{#if @isSearchable}}
49
- <div class="pix-select__search">
50
- <FaIcon class="pix-select-search__icon" @icon="magnifying-glass" />
51
- <label class="screen-reader-only" for={{this.searchId}}>{{@searchLabel}}</label>
52
- <input
53
- class="pix-select-search__input"
54
- id={{this.searchId}}
55
- autocomplete="off"
56
- tabindex={{if this.isExpanded "0" "-1"}}
57
- placeholder={{@searchPlaceholder}}
58
- {{on "input" this.setSearchValue}}
59
- />
60
- </div>
61
- {{/if}}
62
- <ul role="listbox" id={{this.listId}} class="pix-select__options">
63
- <li
64
- class="pix-select-options-category__option{{unless
65
- @value
66
- ' pix-select-options-category__option--selected'
67
- }}{{unless this.displayDefaultOption ' pix-select-options-category__option--hidden'}}"
68
- role="option"
69
- tabindex={{if this.isDefaultOptionHidden "-1" "0"}}
70
- aria-selected={{if @value "false" "true"}}
71
- {{on "click" (fn this.onChange this.defaultOption)}}
72
- {{on-enter-action (fn this.onChange this.defaultOption)}}
73
- {{on-space-action (fn this.onChange this.defaultOption)}}
74
- >
75
- {{@placeholder}}
76
- </li>
77
- {{#if this.results}}
78
- {{#if this.displayCategory}}
79
- {{#each this.results as |element index|}}
80
- <ul
81
- class="pix-select-options__category"
82
- role="group"
83
- aria-labelledby={{if this.displayCategory (concat "cat-" this.selectId "-" index)}}
84
- >
85
- {{#if this.displayCategory}}
86
- {{! template-lint-disable no-invalid-role }}
87
- {{!https://www.w3.org/WAI/ARIA/apg/example-index/listbox/listbox-grouped.html}}
88
- <li
89
- class="pix-select-options-category__name"
90
- role="presentation"
91
- id={{concat "cat-" this.selectId "-" index}}
92
- >
93
- {{element.category}}
94
- </li>
95
- {{/if}}
99
+ {{#each element.options as |option|}}
100
+ <li
101
+ class="pix-select-options-category__option{{if
102
+ (eq option.value @value)
103
+ ' pix-select-options-category__option--selected'
104
+ }}"
105
+ role="option"
106
+ tabindex={{if this.isExpanded "0" "-1"}}
107
+ aria-selected={{if (eq option.value @value) "true" "false"}}
108
+ {{on "click" (fn this.onChange option)}}
109
+ {{on-enter-action (fn this.onChange option)}}
110
+ {{on-space-action (fn this.onChange option)}}
111
+ >
112
+ {{option.label}}
96
113
 
97
- {{#each element.options as |option|}}
98
- <li
99
- class="pix-select-options-category__option{{if
100
- (eq option.value @value)
101
- ' pix-select-options-category__option--selected'
102
- }}"
103
- role="option"
104
- tabindex={{if this.isExpanded "0" "-1"}}
105
- aria-selected={{if (eq option.value @value) "true" "false"}}
106
- {{on "click" (fn this.onChange option)}}
107
- {{on-enter-action (fn this.onChange option)}}
108
- {{on-space-action (fn this.onChange option)}}
109
- >
110
- {{option.label}}
114
+ <FaIcon @icon="check" />
115
+ </li>
116
+ {{/each}}
117
+ </ul>
118
+ {{/each}}
119
+ {{else}}
120
+ {{#each this.results as |option|}}
121
+ <li
122
+ class="pix-select-options-category__option{{if
123
+ (eq option.value @value)
124
+ ' pix-select-options-category__option--selected'
125
+ }}"
126
+ role="option"
127
+ tabindex={{if this.isExpanded "0" "-1"}}
128
+ aria-selected={{if (eq option.value @value) "true" "false"}}
129
+ {{on "click" (fn this.onChange option)}}
130
+ {{on-enter-action (fn this.onChange option)}}
131
+ {{on-space-action (fn this.onChange this.defaultOption)}}
132
+ >
133
+ {{option.label}}
111
134
 
112
- <FaIcon @icon="check" />
113
- </li>
114
- {{/each}}
115
- </ul>
116
- {{/each}}
135
+ <FaIcon @icon="check" />
136
+ </li>
137
+ {{/each}}
138
+ {{/if}}
117
139
  {{else}}
118
- {{#each this.results as |option|}}
119
- <li
120
- class="pix-select-options-category__option{{if
121
- (eq option.value @value)
122
- ' pix-select-options-category__option--selected'
123
- }}"
124
- role="option"
125
- tabindex={{if this.isExpanded "0" "-1"}}
126
- aria-selected={{if (eq option.value @value) "true" "false"}}
127
- {{on "click" (fn this.onChange option)}}
128
- {{on-enter-action (fn this.onChange option)}}
129
- {{on-space-action (fn this.onChange this.defaultOption)}}
130
- >
131
- {{option.label}}
132
-
133
- <FaIcon @icon="check" />
134
- </li>
135
- {{/each}}
140
+ <li class="pix-select__empty-search-message">{{@emptySearchMessage}}</li>
136
141
  {{/if}}
137
- {{else}}
138
- <li class="pix-select__empty-search-message">{{@emptySearchMessage}}</li>
139
- {{/if}}
140
- </ul>
141
- </div>
142
+ </ul>
143
+ </div>
144
+ </PopperJS>
142
145
  {{#if @errorMessage}}
143
146
  <p class="pix-select__error-message">{{@errorMessage}}</p>
144
147
  {{/if}}
@@ -74,7 +74,7 @@ $pix-warning-20: #FFE381;
74
74
  $pix-warning-30: #FFD235;
75
75
  $pix-warning-40: #FFBE00;
76
76
  $pix-warning-50: #EAA600;
77
- $pix-warning-60: #CE8900;
77
+ $pix-warning-60: #D87016;
78
78
  $pix-warning-70: #A95800;
79
79
  $pix-warning-80: #874D00;
80
80
 
@@ -114,12 +114,10 @@
114
114
  letter-spacing: 0.02em;
115
115
  }
116
116
 
117
- %pix-body-weight-medium,
118
117
  .pix-body-weight-medium {
119
118
  font-weight: 500;
120
119
  }
121
120
 
122
- %pix-body-weight-bold,
123
121
  .pix-body-weight-bold {
124
122
  font-weight: 700;
125
123
  }
@@ -4,15 +4,6 @@ import { action } from '@storybook/addon-actions';
4
4
  export const Template = (args) => {
5
5
  return {
6
6
  template: hbs`
7
- <style>
8
- .custom {
9
- border: 0;
10
- width: 150px;
11
- }
12
- .custom:hover {
13
- border: 0;
14
- }
15
- </style>
16
7
  {{#if this.id}}
17
8
  <div>
18
9
  <label for={{this.id}}>Un label en dehors du composant</label>
@@ -36,12 +27,50 @@ export const Template = (args) => {
36
27
  @requiredText={{this.requiredText}}
37
28
  @errorMessage={{this.errorMessage}}
38
29
  @isDisabled={{this.isDisabled}}
30
+ @placement={{this.placement}}
39
31
  />
40
32
  `,
41
33
  context: args,
42
34
  };
43
35
  };
44
36
 
37
+ export const TemplatePopover = (args) => {
38
+ return {
39
+ template: hbs`
40
+ <div style="display:flex;height:330px">
41
+ <div style="align-self:flex-end">
42
+ {{#if this.id}}
43
+ <div>
44
+ <label for={{this.id}}>Un label en dehors du composant</label>
45
+ </div>
46
+ {{/if}}
47
+ <PixSelect
48
+ @id={{this.id}}
49
+ @className={{this.className}}
50
+ @options={{this.options}}
51
+ @isSearchable={{this.isSearchable}}
52
+ @onChange={{this.onChange}}
53
+ @label={{this.label}}
54
+ @placeholder={{this.placeholder}}
55
+ @hideDefaultOption={{this.hideDefaultOption}}
56
+ @subLabel={{this.subLabel}}
57
+ @searchLabel={{this.searchLabel}}
58
+ @value={{this.value}}
59
+ @searchPlaceholder={{this.searchPlaceholder}}
60
+ @screenReaderOnly={{this.screenReaderOnly}}
61
+ @emptySearchMessage={{this.emptySearchMessage}}
62
+ @requiredText={{this.requiredText}}
63
+ @errorMessage={{this.errorMessage}}
64
+ @isDisabled={{this.isDisabled}}
65
+ @placement={{this.placement}}
66
+ />
67
+ </div>
68
+ </div>
69
+ `,
70
+ context: args,
71
+ };
72
+ };
73
+
45
74
  export const WithId = Template.bind({});
46
75
  WithId.args = {
47
76
  id: 'custom',
@@ -168,6 +197,27 @@ WithCategoriesAndSearch.args = {
168
197
  onChange: action('onChange'),
169
198
  };
170
199
 
200
+ export const WithDropDownAtTheTop = TemplatePopover.bind({});
201
+ WithDropDownAtTheTop.args = {
202
+ options: [
203
+ { value: '1', label: 'Figues' },
204
+ { value: '3', label: 'Fraises' },
205
+ { value: '2', label: 'Bananes' },
206
+ { value: '4', label: 'Mangues' },
207
+ { value: '5', label: 'Kaki' },
208
+ {
209
+ value: '6',
210
+ label: 'Asiminier trilobé oblong vert (à ne pas confondre avec la papaye)',
211
+ },
212
+ ],
213
+ label: 'JambonFromage',
214
+ placeholder: 'Mon innerText',
215
+ subLabel: 'Mon sous label',
216
+ isSearchable: false,
217
+ onChange: action('onChange'),
218
+ placement: 'top',
219
+ };
220
+
171
221
  export const argTypes = {
172
222
  options: {
173
223
  name: 'options',
@@ -313,4 +363,15 @@ export const argTypes = {
313
363
  type: { summary: false },
314
364
  },
315
365
  },
366
+ placement: {
367
+ name: 'placement',
368
+ description:
369
+ "Permet de placer la dropdown du select par rapport à son bouton. Par défaut, cela s'adapte tout seul.",
370
+ type: { name: 'string', required: false },
371
+ options: ['bottom', 'top', 'left', 'right'],
372
+ table: {
373
+ type: { summary: 'string' },
374
+ defaultValue: { summary: null },
375
+ },
376
+ },
316
377
  };
@@ -53,6 +53,14 @@ Les options sont représentées par un tableau d'objet contenant les propriété
53
53
  <Story name="WithCategoriesAndSearch" story={stories.WithCategoriesAndSearch} height={200} />
54
54
  </Canvas>
55
55
 
56
+ ## WithDropDownAtTheTop
57
+
58
+ Ici nous avons forcé le placement de la dropdown en haut du select mais sachez que ce placement se fait automatiquement par défaut.
59
+
60
+ <Canvas>
61
+ <Story name="WithDropDownAtTheTop" story={stories.WithDropDownAtTheTop} />
62
+ </Canvas>
63
+
56
64
  ## Usage
57
65
 
58
66
  ```html
@@ -71,6 +79,7 @@ Les options sont représentées par un tableau d'objet contenant les propriété
71
79
  @screenReaderOnly="{{screenReaderOnly}}"
72
80
  @requiredText="{{requiredText}}"
73
81
  @errorMessage="{{errorMessage}}"
82
+ @placement="{{placement}}"
74
83
  />
75
84
  ```
76
85
 
@@ -38,7 +38,7 @@ import { Meta, ColorPalette, ColorItem } from '@storybook/addon-docs';
38
38
  Secondary: '#ffd235',
39
39
  40: '#ffbe00',
40
40
  50: '#eaa600',
41
- 60: '#ce8900',
41
+ 60: '#d87016',
42
42
  70: '#a95800',
43
43
  80: '#874d00'}}
44
44
  />
@@ -103,7 +103,7 @@ import { Meta, ColorPalette, ColorItem } from '@storybook/addon-docs';
103
103
  30: '#ffd235',
104
104
  40: '#ffbe00',
105
105
  50: '#eaa600',
106
- 60: '#ce8900',
106
+ 60: '#d87016',
107
107
  70: '#a95800',
108
108
  80: '#874d00'}}
109
109
  />
@@ -1,6 +1,6 @@
1
1
  <!-- Typography.stories.mdx -->
2
2
 
3
- import { Meta, Typeset } from '@storybook/addon-docs';
3
+ import { Meta, Typeset, Markdown } from '@storybook/addon-docs';
4
4
 
5
5
  <Meta title="Utiliser Pix UI/Design Tokens/Typographie" />
6
6
 
@@ -82,24 +82,6 @@ Des **placeholder SCSS** équivalents aux tokens de Figma sont disponibles. C'es
82
82
  fontFamily={'Roboto, Arial, sans-serif'}
83
83
  />
84
84
 
85
- #### Variantes de gras
86
-
87
- Pour les corps, on peut préciser une graisse différente en complément :
88
-
89
- <Typeset
90
- fontSizes={[16]}
91
- fontWeight={500}
92
- sampleText={'@extend %pix-weight-medium;'}
93
- fontFamily={'Roboto, Arial, sans-serif'}
94
- />
95
-
96
- <Typeset
97
- fontSizes={[16]}
98
- fontWeight={700}
99
- sampleText={'@extend %pix-weight-bold;'}
100
- fontFamily={'Roboto, Arial, sans-serif'}
101
- />
102
-
103
85
  ### Comment utiliser un placeholder SCSS ?
104
86
 
105
87
  ```css
@@ -140,6 +122,29 @@ Pour chaque placeholder SCSS, une **classe CSS** utilitaire de même nom existe
140
122
  - `pix-body-s`
141
123
  - `pix-body-xs`
142
124
 
125
+ ## Design tokens
126
+
127
+ Des variables SCSS existent pour certaines propriétés de typographie.
128
+
129
+ ### Font-weight
130
+
131
+ ℹ️ Ces variables ne devraient pas être utilisées pour modifier la graisse d'un titre car les classes utilitaires et les placeholders ci-dessus s'en occupent déjà.
132
+
133
+ `$font-normal: 400;`
134
+
135
+ `$font-medium: 500;`
136
+
137
+ `$font-bold: 700;`
138
+
139
+ ### Font-family
140
+
141
+ ℹ️ Vous ne devriez pas avoir à les utiliser car elles vont de pair avec d'autres propriétés de typo (font-size, line-height, ...).<br/>
142
+ Pour en savoir plus, voir les classes utilitaires et les placeholders ci-dessus.
143
+
144
+ `$font-open-sans: 'Open Sans', Arial, sans-serif;`
145
+
146
+ `$font-roboto: 'Roboto', Arial, sans-serif;`
147
+
143
148
  ## Détails techniques
144
149
 
145
150
  On utilise sur les applications Pix deux polices d'écriture :
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "30.0.0",
3
+ "version": "31.0.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"
@@ -54,6 +54,7 @@
54
54
  "ember-cli-htmlbars": "^6.1.1",
55
55
  "ember-cli-sass": "^11.0.1",
56
56
  "ember-click-outside": "^6.0.1",
57
+ "ember-popperjs": "^3.0.0",
57
58
  "ember-truth-helpers": "^3.1.1",
58
59
  "lodash.debounce": "^4.0.8"
59
60
  },