@1024pix/pix-ui 31.0.0 → 32.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
+ ## v32.0.0 (24/04/2023)
4
+
5
+
6
+ ### :rocket: Amélioration
7
+ - [#387](https://github.com/1024pix/pix-ui/pull/387) [FEATURE] Ne plus calculer le couleur de fond d'icône du PixIndicatorCard (PIX-7746)
8
+
9
+ ## v31.1.0 (18/04/2023)
10
+
11
+
12
+ ### :rocket: Amélioration
13
+ - [#384](https://github.com/1024pix/pix-ui/pull/384) [FEATURE] Ajouter une icône avant le label du composant Pix-Select (PIX-7634)
14
+
3
15
  ## v31.0.0 (14/04/2023)
4
16
 
5
17
 
@@ -4,12 +4,7 @@
4
4
  <div class="indicator-card__icon" aria-hidden="true"></div>
5
5
  <div class="indicator-card__content" aria-hidden="true"></div>
6
6
  {{else}}
7
- <div
8
- id={{this.iconId}}
9
- class="indicator-card__icon"
10
- aria-hidden="true"
11
- {{did-insert this.setIconColor}}
12
- >
7
+ <div id={{this.iconId}} class="indicator-card__icon {{this.color}}" aria-hidden="true">
13
8
  <FaIcon @icon={{@icon}} @prefix={{@iconPrefix}} />
14
9
  </div>
15
10
  <dl class="indicator-card__content">
@@ -1,21 +1,14 @@
1
1
  import Component from '@glimmer/component';
2
- import { action } from '@ember/object';
3
2
  import { guidFor } from '@ember/object/internals';
4
- import accessibleContrastedColorGenerator from '@1024pix/pix-ui/utils/accessible-contrasted-color-generator';
5
3
 
6
4
  export default class PixIndicatorCard extends Component {
7
5
  id = guidFor(this);
8
6
  iconId = 'icon-' + this.id;
9
7
  tooltipId = 'tooltip-' + this.id;
10
8
 
11
- @action
12
- setIconColor() {
13
- const element = document.getElementById(this.iconId);
14
- try {
15
- element.style.color = this.args.color;
16
- element.style.backgroundColor = accessibleContrastedColorGenerator(this.args.color);
17
- } catch (error) {
18
- console.error(error.message);
19
- }
9
+ get color() {
10
+ const { color } = this.args;
11
+ if (!color) return `indicator-card__icon--grey`;
12
+ return `indicator-card__icon--${color}`;
20
13
  }
21
14
  }
@@ -34,6 +34,10 @@
34
34
  aria-controls={{this.listId}}
35
35
  aria-disabled={{@isDisabled}}
36
36
  >
37
+ {{#if @icon}}
38
+ <FaIcon @icon={{@icon}} />
39
+ {{/if}}
40
+
37
41
  <span class="pix-select-button__text">{{this.placeholder}}</span>
38
42
 
39
43
  <FaIcon
@@ -12,9 +12,28 @@
12
12
  justify-content: center;
13
13
  align-items: center;
14
14
  border-radius: 8px 0 0 8px;
15
- background-color: $pix-neutral-20;
16
15
  min-width: 96px;
17
16
  font-size: 2.5rem;
17
+
18
+ &--grey {
19
+ color: $pix-neutral-60;
20
+ background-color: $pix-neutral-5;
21
+ }
22
+
23
+ &--blue {
24
+ color: $pix-primary-60;
25
+ background-color: $pix-primary-5;
26
+ }
27
+
28
+ &--green {
29
+ color: $pix-success-60;
30
+ background-color: $pix-success-5;
31
+ }
32
+
33
+ &--purple {
34
+ color: $pix-tertiary-60;
35
+ background-color: $pix-tertiary-5;
36
+ }
18
37
  }
19
38
 
20
39
  &__content {
@@ -48,6 +48,9 @@ export const argTypes = {
48
48
  color: {
49
49
  name: 'Color',
50
50
  description: "Couleur de l'icone",
51
+ table: { defaultValue: { summary: 'grey' } },
52
+ control: { type: 'select' },
53
+ options: ['grey', 'blue', 'green', 'purple'],
51
54
  },
52
55
  icon: {
53
56
  name: 'Icon',
@@ -28,6 +28,7 @@ export const Template = (args) => {
28
28
  @errorMessage={{this.errorMessage}}
29
29
  @isDisabled={{this.isDisabled}}
30
30
  @placement={{this.placement}}
31
+ @icon={{this.icon}}
31
32
  />
32
33
  `,
33
34
  context: args,
@@ -218,6 +219,19 @@ WithDropDownAtTheTop.args = {
218
219
  placement: 'top',
219
220
  };
220
221
 
222
+ export const WithIcon = Template.bind({});
223
+ WithIcon.args = {
224
+ icon: 'earth-europe',
225
+ isSearchable: false,
226
+ label: 'With icon',
227
+ onChange: action('onChange'),
228
+ options: [
229
+ { value: 'en', label: 'English' },
230
+ { value: 'fr', label: 'Français' },
231
+ ],
232
+ value: 'fr',
233
+ };
234
+
221
235
  export const argTypes = {
222
236
  options: {
223
237
  name: 'options',
@@ -374,4 +388,14 @@ export const argTypes = {
374
388
  defaultValue: { summary: null },
375
389
  },
376
390
  },
391
+ icon: {
392
+ name: 'icon',
393
+ description:
394
+ "Permet l'affichage d'une icône FontAwesome avant le placeholder ou le label de l'option sélectionnée.",
395
+ type: { name: 'string', required: false },
396
+ table: {
397
+ type: { summary: 'string' },
398
+ defaultValue: { summary: null },
399
+ },
400
+ },
377
401
  };
@@ -61,6 +61,12 @@ Ici nous avons forcé le placement de la dropdown en haut du select mais sachez
61
61
  <Story name="WithDropDownAtTheTop" story={stories.WithDropDownAtTheTop} />
62
62
  </Canvas>
63
63
 
64
+ ## WithIcon
65
+
66
+ <Canvas>
67
+ <Story name="WithIcon" story={stories.WithIcon} />
68
+ </Canvas>
69
+
64
70
  ## Usage
65
71
 
66
72
  ```html
@@ -80,6 +86,7 @@ Ici nous avons forcé le placement de la dropdown en haut du select mais sachez
80
86
  @requiredText="{{requiredText}}"
81
87
  @errorMessage="{{errorMessage}}"
82
88
  @placement="{{placement}}"
89
+ @icon="{{icon}}"
83
90
  />
84
91
  ```
85
92
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "31.0.0",
3
+ "version": "32.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"
@@ -48,7 +48,6 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@formatjs/intl": "^2.5.1",
51
- "color": "^4.2.3",
52
51
  "ember-auto-import": "^2.5.0",
53
52
  "ember-cli-babel": "^7.26.8",
54
53
  "ember-cli-htmlbars": "^6.1.1",
@@ -1,29 +0,0 @@
1
- import Color from 'color';
2
-
3
- // See this link that explains why we had to implement lightenBy and darkenBy https://github.com/Qix-/color/issues/53#issuecomment-487822576
4
- function lightenBy(color, ratio) {
5
- const lightness = color.lightness();
6
- return color.lightness(lightness + (100 - lightness) * ratio);
7
- }
8
-
9
- function darkenBy(color, ratio) {
10
- const lightness = color.lightness();
11
- return color.lightness(lightness - lightness * ratio);
12
- }
13
-
14
- export default function (hex) {
15
- const color = Color(hex);
16
- let newColor = color;
17
- let contrast;
18
- do {
19
- if (color.luminosity() < 0.5) {
20
- newColor = lightenBy(newColor, 0.05);
21
- } else {
22
- newColor = darkenBy(newColor, 0.05);
23
- }
24
- contrast = color.contrast(newColor);
25
-
26
- // newColor.luminosity() can return 0.9999..99 when newColor is white but reinstanciating Color with the hexacode #FFFFFF returns 1
27
- } while (contrast < 3 && Color(newColor.hex()).luminosity() < 1);
28
- return newColor.hex();
29
- }