@1024pix/pix-ui 35.0.1 → 36.0.1

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,18 @@
1
1
  # Pix-UI Changelog
2
2
 
3
+ ## v36.0.1 (26/06/2023)
4
+
5
+
6
+ ### :bug: Correction
7
+ - [#425](https://github.com/1024pix/pix-ui/pull/425) [BUGFIX] Réduire la largeur minimum de PixProgressGauge (PIX-8457).
8
+ - [#424](https://github.com/1024pix/pix-ui/pull/424) [BUGFIX] définir une largeur fixe pour le texte de pourcentage de PixProgressGauge (PIX-8439).
9
+
10
+ ## v36.0.0 (13/06/2023)
11
+
12
+
13
+ ### :boom: BREAKING CHANGE
14
+ - [#417](https://github.com/1024pix/pix-ui/pull/417) [BREAKING] Met à jour la PixProgressBar avec le nouveau design (PIX-8172).
15
+
3
16
  ## v35.0.1 (13/06/2023)
4
17
 
5
18
 
@@ -1,19 +1,13 @@
1
- <div
2
- class="progress-gauge
3
- {{this.progressGaugeClass}}
4
- {{if @isArrowLeft 'progress-gauge--tooltip-left'}}"
5
- ...attributes
6
- >
7
- <div class="progress-gauge__referrer"></div>
8
- <div class="progress-gauge__marker" aria-hidden="true" style={{this.valueGaugeStyle}}></div>
9
-
10
- {{#if @tooltipText}}
11
- <div class="progress-gauge__tooltip-wrapper" style={{this.valueGaugeStyle}}>
12
- <span class="progress-gauge__tooltip">{{@tooltipText}}</span>
13
- </div>
14
- {{/if}}
15
-
16
- {{#if this.hasSubtitle}}
1
+ <div class="progress-gauge {{this.themeMode}} {{this.colorClass}}" ...attributes>
2
+ <div class="progress-gauge__text" role="presentation">{{this.percentageValue}}</div>
3
+ <label for={{this.id}} class="screen-reader-only">{{@label}}</label>
4
+ <progress
5
+ class="progress-gauge__bar"
6
+ id={{this.id}}
7
+ max="100"
8
+ value={{this.value}}
9
+ >{{this.value}}%</progress>
10
+ {{#if @subtitle}}
17
11
  <p class="progress-gauge__sub-title">{{@subtitle}}</p>
18
12
  {{/if}}
19
13
  </div>
@@ -1,29 +1,48 @@
1
1
  import Component from '@glimmer/component';
2
- import { htmlSafe } from '@ember/template';
2
+ import { guidFor } from '@ember/object/internals';
3
3
 
4
4
  export default class PixProgressGauge extends Component {
5
- get progressValue() {
6
- if (!this.args.value || this.args.value < 0) {
7
- return 0;
5
+ get id() {
6
+ return guidFor(this);
7
+ }
8
+
9
+ get value() {
10
+ if (Number(this.args.value) <= 0) return 0;
11
+ if (Number(this.args.value) > 100) return 100;
12
+ if (!this.args.value) {
13
+ throw new Error('ERROR in PixProgressGauge component, @value param is not provided.');
8
14
  }
15
+ return Number(this.args.value);
16
+ }
9
17
 
10
- return this.args.value > 100 ? 100 : this.args.value;
18
+ get percentageValue() {
19
+ return Number(this.value / 100).toLocaleString(navigator.language, { style: 'percent' });
11
20
  }
12
21
 
13
- get valueGaugeStyle() {
14
- return htmlSafe(`width: ${this.progressValue}%`);
22
+ get label() {
23
+ if (!this.args.label || !this.args.label.trim()) {
24
+ throw new Error('ERROR in PixProgressGauge component, @label param is not provided.');
25
+ }
26
+ return this.args.label;
15
27
  }
16
28
 
17
- get hasSubtitle() {
18
- return !!this.args.subtitle;
29
+ get themeMode() {
30
+ const availableMode = ['dark', 'light'];
31
+
32
+ const themeMode =
33
+ this.args.themeMode && availableMode.includes(this.args.themeMode)
34
+ ? this.args.themeMode
35
+ : 'light';
36
+
37
+ return `progress-gauge--theme-${themeMode}`;
19
38
  }
20
39
 
21
- get progressGaugeClass() {
22
- const availableColor = ['blue', 'white'];
40
+ get colorClass() {
41
+ const availableColor = ['blue', 'green', 'purple'];
23
42
 
24
43
  const color =
25
- this.args.color && availableColor.includes(this.args.color) ? this.args.color : `blue`;
44
+ this.args.color && availableColor.includes(this.args.color) ? this.args.color : 'blue';
26
45
 
27
- return `progress-gauge--${color}`;
46
+ return `progress-gauge--content-${color}`;
28
47
  }
29
48
  }
@@ -1,116 +1,128 @@
1
1
  .progress-gauge {
2
2
  position: relative;
3
- min-width: 200px;
3
+ display: grid;
4
+ grid-template-areas:
5
+ 'text progressbar'
6
+ 'subtitle subtitle';
7
+ grid-template-columns: auto 1fr;
8
+ align-items: center;
4
9
  width: 100%;
10
+ min-width: 6rem;
5
11
  border-radius: 5px;
6
12
 
13
+ &__bar {
14
+ grid-area: progressbar;
15
+ inline-size: unset;
16
+ flex-grow: 1;
17
+ height: 0.875rem;
18
+ border: 2px solid $pix-neutral-20;
19
+ border-radius: 1.625rem;
20
+ overflow: hidden;
21
+
22
+ &::-webkit-progress-value {
23
+ background-color: $pix-primary;
24
+ border-radius: 1.625rem;
25
+ }
26
+
27
+ &::-moz-progress-bar {
28
+ background-color: $pix-primary;
29
+ border-radius: 1.625rem;
30
+ }
31
+
32
+ &::-webkit-progress-bar {
33
+ background-color: $pix-neutral-20;
34
+ }
35
+ }
36
+
37
+ &__text {
38
+ @extend %pix-body-s;
39
+
40
+ grid-area: text;
41
+ min-width: 5ch;
42
+ margin-right: $pix-spacing-xxs;
43
+ white-space: nowrap;
44
+ font-weight: 500;
45
+ line-height: 1;
46
+ }
47
+
7
48
  &__sub-title {
8
- font-size: 0.813rem;
9
- color: $pix-primary-60;
49
+ @extend %pix-body-s;
50
+
51
+ grid-area: subtitle;
52
+ width: 100%;
10
53
  margin: 6px 0;
54
+ color: $pix-primary-60;
11
55
  letter-spacing: 0.4px;
12
56
  text-transform: uppercase;
57
+ text-overflow: ellipsis;
58
+ overflow: hidden;
13
59
  }
60
+ }
14
61
 
15
- &__marker,
16
- &__referrer {
17
- height: 4px;
18
- border-radius: 5px;
19
- text-align: right;
62
+ // THEME DARK
63
+ .progress-gauge--theme-dark {
64
+ .progress-gauge__bar {
65
+ border: 2px solid $pix-neutral-0;
20
66
  }
21
67
 
22
- &__marker {
23
- margin-top: -4px;
68
+ .progress-gauge__bar::-webkit-progress-bar {
69
+ background-color: $pix-neutral-0;
24
70
  }
25
71
 
26
- &__tooltip-wrapper {
27
- position: relative;
72
+ .progress-gauge__text,
73
+ .progress-gauge__sub-title {
74
+ color: $pix-neutral-0;
28
75
  }
76
+ }
29
77
 
30
- &__tooltip {
31
- position: absolute;
32
- min-width: 40px;
33
- left: 100%;
34
- transform: translate(-50%);
35
- bottom: calc(100% + 10px);
36
- border-radius: 5px;
37
- text-align: center;
38
- padding: 4px;
39
- font-size: 0.8rem;
40
- font-weight: $font-bold;
41
-
42
- &::before {
43
- content: '';
44
- position: absolute;
45
- left: calc(50% - 4px);
46
- border-top: 4px solid;
47
- border-right: 4px solid transparent;
48
- border-left: 4px solid transparent;
49
- bottom: -4px;
50
- }
78
+ // SPECIFIC BAR COLORS
79
+ .progress-gauge--content-blue {
80
+ .progress-gauge__bar::-webkit-progress-value {
81
+ background-color: $pix-primary;
51
82
  }
52
83
 
53
- &--white {
54
- & .progress-gauge__referrer {
55
- background-color: lighten($pix-primary, 15%);
56
- }
57
-
58
- & .progress-gauge__marker {
59
- background: $pix-neutral-0;
60
- }
84
+ .progress-gauge__bar::-moz-progress-bar {
85
+ background-color: $pix-primary;
86
+ }
61
87
 
62
- & .progress-gauge__tooltip {
63
- background: $pix-neutral-0;
88
+ &:not(.progress-gauge--theme-dark) {
89
+ .progress-gauge__text,
90
+ .progress-gauge__sub-title {
64
91
  color: $pix-primary;
65
-
66
- &::before {
67
- color: $pix-neutral-0;
68
- border-top-color: $pix-neutral-0;
69
- }
70
92
  }
93
+ }
94
+ }
71
95
 
72
- & .progress-gauge__sub-title {
73
- color: $pix-neutral-0;
74
- }
96
+ .progress-gauge--content-green {
97
+ .progress-gauge__bar::-webkit-progress-value {
98
+ background-color: $pix-success-60;
75
99
  }
76
100
 
77
- &--blue {
78
- & .progress-gauge__referrer {
79
- background-color: $pix-neutral-20;
80
- }
101
+ .progress-gauge__bar::-moz-progress-bar {
102
+ background-color: $pix-success-60;
103
+ }
81
104
 
82
- & .progress-gauge__marker {
83
- background-color: $pix-primary-60;
105
+ &:not(.progress-gauge--theme-dark) {
106
+ .progress-gauge__text,
107
+ .progress-gauge__sub-title {
108
+ color: $pix-success-60;
84
109
  }
110
+ }
111
+ }
85
112
 
86
- & .progress-gauge__tooltip {
87
- background-color: $pix-primary-60;
88
- color: $pix-neutral-0;
89
-
90
- &::before {
91
- border-top-color: $pix-primary-60;
92
- }
93
- }
113
+ .progress-gauge--content-purple {
114
+ .progress-gauge__bar::-webkit-progress-value {
115
+ background-color: $pix-tertiary-60;
116
+ }
94
117
 
95
- & .progress-gauge__sub-title {
96
- color: $pix-primary-60;
97
- }
118
+ .progress-gauge__bar::-moz-progress-bar {
119
+ background-color: $pix-tertiary-60;
98
120
  }
99
121
 
100
- &--tooltip-left {
101
- & .progress-gauge__tooltip {
102
- border-bottom-left-radius: 0;
103
- bottom: calc(100% + 14px);
104
- transform: none;
105
- left: 100%;
106
-
107
- &::before {
108
- border-top: 8px solid;
109
- border-right: 8px solid transparent;
110
- border-left: none;
111
- left: 0;
112
- bottom: -8px;
113
- }
122
+ &:not(.progress-gauge--theme-dark) {
123
+ .progress-gauge__text,
124
+ .progress-gauge__sub-title {
125
+ color: $pix-tertiary-60;
114
126
  }
115
127
  }
116
128
  }
@@ -5,36 +5,36 @@ export const Default = (args) => {
5
5
  template: hbs`<PixProgressGauge
6
6
  @value={{this.value}}
7
7
  @color={{this.color}}
8
- @isArrowLeft={{this.isArrowLeft}}
8
+ @themeMode={{this.themeMode}}
9
9
  @subtitle={{this.subtitle}}
10
- @tooltipText={{this.tooltipText}}
10
+ @label={{this.label}}
11
11
  />`,
12
12
  context: args,
13
13
  };
14
14
  };
15
15
  Default.args = {
16
- tooltipText: '%',
16
+ value: '50',
17
17
  };
18
18
 
19
- export const whiteProgressGauge = (args) => {
19
+ export const darkModeProgressGauge = (args) => {
20
20
  return {
21
- template: hbs`<section style='width: 100%; padding: 35px 35px 5px;background-color: lightgray'>
21
+ template: hbs`<section style='width: 100%; padding: 35px 35px 5px;background-color: #253858'>
22
22
  <PixProgressGauge
23
23
  @value={{this.value}}
24
24
  @color={{this.color}}
25
- @isArrowLeft={{this.isArrowLeft}}
25
+ @label={{this.label}}
26
+ @themeMode={{this.themeMode}}
26
27
  @subtitle={{this.subtitle}}
27
- @tooltipText={{this.tooltipText}}
28
28
  />
29
29
  </section>`,
30
30
  context: args,
31
31
  };
32
32
  };
33
- whiteProgressGauge.args = {
33
+ darkModeProgressGauge.args = {
34
34
  value: '50',
35
- tooltipText: '50%',
36
- color: 'white',
37
- isArrowLeft: true,
35
+ label: 'Chargement',
36
+ color: 'purple',
37
+ themeMode: 'dark',
38
38
  subtitle: 'Avancement',
39
39
  };
40
40
 
@@ -42,23 +42,33 @@ export const argTypes = {
42
42
  value: {
43
43
  name: 'value',
44
44
  description: 'Valeur atteinte sur 100',
45
- type: { name: 'number', required: false },
45
+ type: { name: 'number', required: true },
46
46
  table: { defaultValue: { summary: null } },
47
47
  },
48
+ label: {
49
+ name: 'label',
50
+ description:
51
+ "Afficher un label caché permettant d'expliciter le contexte de la jauge de progression",
52
+ type: { name: 'string', required: true },
53
+ table: { defaultValue: { summary: 'null' } },
54
+ },
55
+ themeMode: {
56
+ name: 'themeMode',
57
+ description:
58
+ "Permet d'indiquer si le thème de la barre de progression est en dark mode ou light mode. Modifie la couleur de fond de la barre de progression. Peut prendre les valeurs `light` ou `dark`",
59
+ type: { name: 'string', required: false },
60
+ table: { defaultValue: { summary: 'light' } },
61
+ control: { type: 'select' },
62
+ options: ['dark', 'light'],
63
+ },
48
64
  color: {
49
65
  name: 'color',
50
66
  description:
51
- 'Modifie la couleur de la barre de progression. Peut prendre les valeurs `blue` ou `white`',
67
+ "Modifie la couleur du contenu de la barre de progression. Peut prendre les valeurs `blue`, 'green' ou `purple`",
52
68
  type: { name: 'string', required: false },
53
69
  table: { defaultValue: { summary: 'blue' } },
54
70
  control: { type: 'select' },
55
- options: ['blue', 'white'],
56
- },
57
- isArrowLeft: {
58
- name: 'isArrowLeft',
59
- description: "Modifie la position de l'info bulle sur la gauche",
60
- type: { name: 'boolean', required: false },
61
- table: { defaultValue: { summary: false } },
71
+ options: ['blue', 'green', 'purple'],
62
72
  },
63
73
  subtitle: {
64
74
  name: 'subtitle',
@@ -66,10 +76,4 @@ export const argTypes = {
66
76
  type: { name: 'string', required: false },
67
77
  table: { defaultValue: { summary: 'null' } },
68
78
  },
69
- tooltipText: {
70
- name: 'tooltipText',
71
- description: "Afficher un label dans l'info bulle au dessus de la barre de progression",
72
- type: { name: 'string', required: false },
73
- table: { defaultValue: { summary: 'null' } },
74
- },
75
79
  };
@@ -3,22 +3,24 @@ import * as stories from './pix-progress-gauge.stories.js';
3
3
 
4
4
  <Meta title="Others/Progress Gauge" component="PixProgressGauge" argTypes={stories.argTypes} />
5
5
 
6
- # Progress Gauge
6
+ # PixProgressGauge
7
7
 
8
8
  ## Default
9
9
 
10
- Permet d'afficher un barre de progression sur un barème de 100%. Des paramètres existent pour changer la position de la tooltip ou la couleur du composant
10
+ Permet d'afficher un barre de progression sur un barème de 100%. Des paramètres existent pour changer le mode (dark ou light) ou la couleur du composant.
11
+
12
+ > **⚠️** **Il est nécessaire d'avoir un `label` pour rendre le composant accessible !**
11
13
 
12
14
  <Canvas>
13
15
  <Story name="Default" story={stories.Default} height={60} />
14
16
  </Canvas>
15
17
 
16
- ## White
18
+ ## Dark mode
17
19
 
18
- Démonstration d'une barre de progression blanche avec l'info bulle à gauche avec un sous titre
20
+ Démonstration d'une barre de progression blanche en dark mode avec un sous titre.
19
21
 
20
22
  <Canvas>
21
- <Story name="White" story={stories.whiteProgressGauge} height={100} />
23
+ <Story name="Dark" story={stories.darkModeProgressGauge} height={100} />
22
24
  </Canvas>
23
25
 
24
26
  ## Usage
@@ -26,9 +28,9 @@ Démonstration d'une barre de progression blanche avec l'info bulle à gauche av
26
28
  ```html
27
29
  <PixProgressGauge
28
30
  @value="50"
29
- @color="white"
30
- @tooltipText="50%"
31
- @isArrowLeft="true"
31
+ @label="Chargement"
32
+ @color="green"
33
+ @themeMode="dark"
32
34
  @subTitle="Un sous titre"
33
35
  />
34
36
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "35.0.1",
3
+ "version": "36.0.1",
4
4
  "description": "Pix-UI is the implementation of Pix design principles and guidelines for its products.",
5
5
  "keywords": [
6
6
  "ember-addon"