@1024pix/pix-ui 31.1.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,11 @@
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
+
3
9
  ## v31.1.0 (18/04/2023)
4
10
 
5
11
 
@@ -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
  }
@@ -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',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "31.1.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
- }