@1024pix/pix-ui 46.9.4 → 46.10.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/addon/components/pix-checkbox.hbs +10 -0
- package/addon/components/pix-checkbox.js +29 -0
- package/addon/components/pix-label-wrapped.hbs +7 -0
- package/addon/components/pix-label-wrapped.js +10 -0
- package/addon/styles/_pix-checkbox.scss +5 -0
- package/addon/styles/_pix-label-wrapped.scss +20 -3
- package/addon/translations/fr.js +6 -0
- package/app/stories/pix-button.stories.js +3 -3
- package/app/stories/pix-checkbox-variant-tile.mdx +7 -0
- package/app/stories/pix-checkbox-variant-tile.stories.js +34 -0
- package/app/stories/pix-checkbox.stories.js +0 -1
- package/app/stories/pix-icon-button.mdx +2 -2
- package/app/stories/pix-toggle.stories.js +2 -2
- package/config/icons.js +3 -0
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
@screenReaderOnly={{@screenReaderOnly}}
|
|
9
9
|
@isDisabled={{this.isDisabled}}
|
|
10
10
|
@variant={{@variant}}
|
|
11
|
+
@state={{@state}}
|
|
11
12
|
>
|
|
12
13
|
<:inputElement>
|
|
13
14
|
<input
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
class={{this.inputClasses}}
|
|
17
18
|
checked={{@checked}}
|
|
18
19
|
aria-disabled={{this.isDisabled}}
|
|
20
|
+
aria-describedby={{this.stateId}}
|
|
19
21
|
{{on "click" this.avoidCheckedStateChangeIfIsDisabled}}
|
|
20
22
|
...attributes
|
|
21
23
|
/>
|
|
@@ -24,4 +26,12 @@
|
|
|
24
26
|
{{yield to="label"}}
|
|
25
27
|
</:default>
|
|
26
28
|
</PixLabelWrapped>
|
|
29
|
+
|
|
30
|
+
<span class="screen-reader-only" id={{this.stateId}}>
|
|
31
|
+
{{#if this.hasSuccessState}}
|
|
32
|
+
{{this.stateSuccessMessage}}
|
|
33
|
+
{{else if this.hasErrorState}}
|
|
34
|
+
{{this.stateErrorMessage}}
|
|
35
|
+
{{/if}}
|
|
36
|
+
</span>
|
|
27
37
|
</div>
|
|
@@ -2,6 +2,7 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { guidFor } from '@ember/object/internals';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
import { warn } from '@ember/debug';
|
|
5
|
+
import { formatMessage } from '../translations';
|
|
5
6
|
|
|
6
7
|
export default class PixCheckbox extends Component {
|
|
7
8
|
constructor() {
|
|
@@ -12,6 +13,18 @@ export default class PixCheckbox extends Component {
|
|
|
12
13
|
return this.args.id || guidFor(this);
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
get stateId() {
|
|
17
|
+
return `${this.id}-state`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get hasSuccessState() {
|
|
21
|
+
return this.args.state === 'success';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get hasErrorState() {
|
|
25
|
+
return this.args.state === 'error';
|
|
26
|
+
}
|
|
27
|
+
|
|
15
28
|
get inputClasses() {
|
|
16
29
|
const classes = ['pix-checkbox__input'];
|
|
17
30
|
|
|
@@ -19,6 +32,10 @@ export default class PixCheckbox extends Component {
|
|
|
19
32
|
classes.push(`${classes[0]}--indeterminate`);
|
|
20
33
|
}
|
|
21
34
|
|
|
35
|
+
if (this.hasSuccessState || this.hasErrorState) {
|
|
36
|
+
classes.push(`${classes[0]}--state`);
|
|
37
|
+
}
|
|
38
|
+
|
|
22
39
|
return classes.join(' ');
|
|
23
40
|
}
|
|
24
41
|
|
|
@@ -40,4 +57,16 @@ export default class PixCheckbox extends Component {
|
|
|
40
57
|
event.preventDefault();
|
|
41
58
|
}
|
|
42
59
|
}
|
|
60
|
+
|
|
61
|
+
get stateSuccessMessage() {
|
|
62
|
+
return this.formatMessage('state.success');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get stateErrorMessage() {
|
|
66
|
+
return this.formatMessage('state.error');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
formatMessage(message) {
|
|
70
|
+
return formatMessage('fr', `input.${message}`);
|
|
71
|
+
}
|
|
43
72
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
<label for={{@for}} class={{this.className}} ...attributes>
|
|
2
|
+
{{#if this.hasError}}
|
|
3
|
+
<FaIcon @icon="circle-xmark" />
|
|
4
|
+
{{/if}}
|
|
5
|
+
{{#if this.hasSuccess}}
|
|
6
|
+
<FaIcon @icon="circle-check" />
|
|
7
|
+
{{/if}}
|
|
8
|
+
|
|
2
9
|
{{yield to="inputElement"}}
|
|
3
10
|
|
|
4
11
|
<span class="{{if @screenReaderOnly 'screen-reader-only'}}">
|
|
@@ -7,6 +7,8 @@ export default class PixLabelWrapped extends Component {
|
|
|
7
7
|
if (this.args.inlineLabel) classes.push('pix-label--inline-label');
|
|
8
8
|
if (this.args.isDisabled) classes.push('pix-label-wrapped--disabled');
|
|
9
9
|
if (this.args.variant === 'tile') classes.push('pix-label-wrapped--variant-tile');
|
|
10
|
+
if (this.args.state === 'success') classes.push('pix-label-wrapped--state-success');
|
|
11
|
+
if (this.args.state === 'error') classes.push('pix-label-wrapped--state-error');
|
|
10
12
|
|
|
11
13
|
const size = ['small', 'large'].includes(this.args.size) ? this.args.size : 'default';
|
|
12
14
|
|
|
@@ -14,4 +16,12 @@ export default class PixLabelWrapped extends Component {
|
|
|
14
16
|
|
|
15
17
|
return classes.join(' ');
|
|
16
18
|
}
|
|
19
|
+
|
|
20
|
+
get hasError() {
|
|
21
|
+
return this.args.state === 'error';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get hasSuccess() {
|
|
25
|
+
return this.args.state === 'success';
|
|
26
|
+
}
|
|
17
27
|
}
|
|
@@ -24,12 +24,29 @@
|
|
|
24
24
|
|
|
25
25
|
&.pix-label-wrapped {
|
|
26
26
|
&--disabled {
|
|
27
|
-
background: var(--pix-neutral-20);
|
|
28
|
-
border-color: var(--pix-neutral-100);
|
|
27
|
+
--state-background-color: var(--pix-neutral-20);
|
|
28
|
+
--state-border-color: var(--pix-neutral-100);
|
|
29
|
+
|
|
30
|
+
&.pix-label-wrapped--state-success {
|
|
31
|
+
--state-background-color: var(--pix-neutral-0);
|
|
32
|
+
--state-border-color: var(--pix-success-300);
|
|
33
|
+
|
|
34
|
+
color: var(--pix-success-700);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&.pix-label-wrapped--state-error {
|
|
38
|
+
--state-background-color: var(--pix-neutral-0);
|
|
39
|
+
--state-border-color: var(--pix-error-500);
|
|
40
|
+
|
|
41
|
+
color: var(--pix-error-700);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
background: var(--state-background-color);
|
|
45
|
+
border-color: var(--state-border-color);
|
|
29
46
|
|
|
30
47
|
&:hover,
|
|
31
48
|
&:active {
|
|
32
|
-
background: var(--
|
|
49
|
+
background: var(--state-background-color);
|
|
33
50
|
}
|
|
34
51
|
}
|
|
35
52
|
}
|
package/addon/translations/fr.js
CHANGED
|
@@ -55,7 +55,7 @@ export default {
|
|
|
55
55
|
description: `Nom de l'icône font-awesome à afficher **avant** le label`,
|
|
56
56
|
type: { name: 'string', required: false },
|
|
57
57
|
control: { type: 'select' },
|
|
58
|
-
options: ['
|
|
58
|
+
options: ['magnifying-glass', 'plus', 'xmark'],
|
|
59
59
|
table: {
|
|
60
60
|
type: { summary: 'string' },
|
|
61
61
|
defaultValue: { summary: null },
|
|
@@ -66,7 +66,7 @@ export default {
|
|
|
66
66
|
description: `Nom de l'icône font-awesome à afficher **après** le label`,
|
|
67
67
|
type: { name: 'string', required: false },
|
|
68
68
|
control: { type: 'select' },
|
|
69
|
-
options: ['
|
|
69
|
+
options: ['magnifying-glass', 'plus', 'xmark'],
|
|
70
70
|
table: {
|
|
71
71
|
type: { summary: 'string' },
|
|
72
72
|
defaultValue: { summary: null },
|
|
@@ -231,7 +231,7 @@ export const icons = Template.bind({});
|
|
|
231
231
|
icons.args = {
|
|
232
232
|
...Default.args,
|
|
233
233
|
iconBefore: 'magnifying-glass',
|
|
234
|
-
iconAfter: '
|
|
234
|
+
iconAfter: 'plus',
|
|
235
235
|
};
|
|
236
236
|
|
|
237
237
|
export const disabled = Template.bind({});
|
|
@@ -23,6 +23,13 @@ Un cursor `not-allowed` est défini sur la checkbox et son label lorsqu'elle est
|
|
|
23
23
|
<Story of={ComponentStories.checkedIsDisabledVariantTile} height={120} />
|
|
24
24
|
<Story of={ComponentStories.isIndeterminateIsDisabledVariantTile} height={120} />
|
|
25
25
|
|
|
26
|
+
#### Succès/Erreur
|
|
27
|
+
|
|
28
|
+
Un champ de statut permet de préciser une coloration particulière en cas de "succès" ou d'"erreur".
|
|
29
|
+
|
|
30
|
+
<Story of={ComponentStories.isDisabledIsSuccessVariantTile} height={120} />
|
|
31
|
+
<Story of={ComponentStories.isDisabledIsErrorVariantTile} height={120} />
|
|
32
|
+
|
|
26
33
|
## Usage
|
|
27
34
|
|
|
28
35
|
```html
|
|
@@ -11,6 +11,16 @@ export default {
|
|
|
11
11
|
control: { type: 'select' },
|
|
12
12
|
type: { required: true },
|
|
13
13
|
},
|
|
14
|
+
state: {
|
|
15
|
+
name: 'state',
|
|
16
|
+
description: 'Si `isDisabled` permet de marquer la checkbox comme correcte ou incorrecte',
|
|
17
|
+
options: ['neutral', 'success', 'error'],
|
|
18
|
+
control: { type: 'select' },
|
|
19
|
+
table: {
|
|
20
|
+
type: { summary: 'string' },
|
|
21
|
+
defaultValue: { summary: 'neutral' },
|
|
22
|
+
},
|
|
23
|
+
},
|
|
14
24
|
...pixCheckboxStories.argTypes,
|
|
15
25
|
},
|
|
16
26
|
};
|
|
@@ -26,6 +36,7 @@ const VariantTileTemplate = (args) => {
|
|
|
26
36
|
@checked={{this.checked}}
|
|
27
37
|
@isDisabled={{this.isDisabled}}
|
|
28
38
|
@variant={{this.variant}}
|
|
39
|
+
@state={{this.state}}
|
|
29
40
|
>
|
|
30
41
|
<:label>{{this.label}}</:label>
|
|
31
42
|
</PixCheckbox></div>`,
|
|
@@ -45,6 +56,7 @@ isDisabledVariantTile.args = {
|
|
|
45
56
|
id: 'accept-newsletter-2',
|
|
46
57
|
label: 'Recevoir la newsletter',
|
|
47
58
|
variant: 'tile',
|
|
59
|
+
state: 'neutral',
|
|
48
60
|
isDisabled: true,
|
|
49
61
|
};
|
|
50
62
|
|
|
@@ -53,6 +65,7 @@ checkedIsDisabledVariantTile.args = {
|
|
|
53
65
|
id: 'accept-newsletter-2',
|
|
54
66
|
label: 'Recevoir la newsletter',
|
|
55
67
|
variant: 'tile',
|
|
68
|
+
state: 'neutral',
|
|
56
69
|
isDisabled: true,
|
|
57
70
|
checked: true,
|
|
58
71
|
};
|
|
@@ -62,7 +75,28 @@ isIndeterminateIsDisabledVariantTile.args = {
|
|
|
62
75
|
id: 'accept-newsletter-2',
|
|
63
76
|
label: 'Recevoir la newsletter',
|
|
64
77
|
variant: 'tile',
|
|
78
|
+
state: 'neutral',
|
|
65
79
|
isDisabled: true,
|
|
66
80
|
checked: true,
|
|
67
81
|
isIndeterminate: true,
|
|
68
82
|
};
|
|
83
|
+
|
|
84
|
+
export const isDisabledIsSuccessVariantTile = VariantTileTemplate.bind({});
|
|
85
|
+
isDisabledIsSuccessVariantTile.args = {
|
|
86
|
+
id: 'accept-newsletter-2',
|
|
87
|
+
label: 'Recevoir la newsletter',
|
|
88
|
+
variant: 'tile',
|
|
89
|
+
isDisabled: true,
|
|
90
|
+
checked: true,
|
|
91
|
+
state: 'success',
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const isDisabledIsErrorVariantTile = VariantTileTemplate.bind({});
|
|
95
|
+
isDisabledIsErrorVariantTile.args = {
|
|
96
|
+
id: 'accept-newsletter-2',
|
|
97
|
+
label: 'Recevoir la newsletter',
|
|
98
|
+
variant: 'tile',
|
|
99
|
+
isDisabled: true,
|
|
100
|
+
checked: true,
|
|
101
|
+
state: 'error',
|
|
102
|
+
};
|
|
@@ -52,7 +52,7 @@ Bouton de fermeture
|
|
|
52
52
|
```html
|
|
53
53
|
<PixIconButton
|
|
54
54
|
@ariaLabel="L'action du bouton"
|
|
55
|
-
@icon="
|
|
55
|
+
@icon="xmark"
|
|
56
56
|
@triggerAction="{{triggerAction}}"
|
|
57
57
|
@withBackground="{{true}}"
|
|
58
58
|
/>
|
|
@@ -63,7 +63,7 @@ Bouton d'action
|
|
|
63
63
|
```html
|
|
64
64
|
<PixIconButton
|
|
65
65
|
@ariaLabel="L'action du bouton"
|
|
66
|
-
@icon="arrow-
|
|
66
|
+
@icon="arrow-right"
|
|
67
67
|
@triggerAction="{{triggerAction}}"
|
|
68
68
|
@size="small"
|
|
69
69
|
@withBackground="{{true}}"
|
|
@@ -90,8 +90,8 @@ const TemplateWithYields = (args) => {
|
|
|
90
90
|
return {
|
|
91
91
|
template: hbs`<PixToggle @toggled={{this.toggled}} @onChange={{this.onChange}}>
|
|
92
92
|
<:label>{{this.label}}</:label>
|
|
93
|
-
<:on><FaIcon @icon='
|
|
94
|
-
<:off><FaIcon @icon='
|
|
93
|
+
<:on><FaIcon @icon='eye' /></:on>
|
|
94
|
+
<:off><FaIcon @icon='eye-slash' /></:off>
|
|
95
95
|
</PixToggle>`,
|
|
96
96
|
context: args,
|
|
97
97
|
};
|
package/config/icons.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
module.exports = () => ({
|
|
2
2
|
'free-solid-svg-icons': [
|
|
3
|
+
'arrow-left',
|
|
3
4
|
'arrow-right',
|
|
4
5
|
'bullhorn',
|
|
5
6
|
'check',
|
|
@@ -9,9 +10,11 @@ module.exports = () => ({
|
|
|
9
10
|
'circle-exclamation',
|
|
10
11
|
'circle-info',
|
|
11
12
|
'circle-question',
|
|
13
|
+
'circle-xmark',
|
|
12
14
|
'earth-europe',
|
|
13
15
|
'eye',
|
|
14
16
|
'eye-slash',
|
|
17
|
+
'magnifying-glass',
|
|
15
18
|
'plus',
|
|
16
19
|
'triangle-exclamation',
|
|
17
20
|
'up-right-from-square',
|