@1024pix/pix-ui 56.0.0 → 57.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.
@@ -0,0 +1,108 @@
1
+ import { warn } from '@ember/debug';
2
+ import { on } from '@ember/modifier';
3
+ import { action } from '@ember/object';
4
+ import { guidFor } from '@ember/object/internals';
5
+ import Component from '@glimmer/component';
6
+
7
+ import PixIcon from './pix-icon';
8
+ import PixLabel from './pix-label';
9
+
10
+ export default class PixSegmentedControl extends Component {
11
+ get variant() {
12
+ const value = this.args.variant ?? 'primary';
13
+ const variantList = ['primary', 'orga', 'certif'];
14
+
15
+ warn(
16
+ `PixAppLayout: @variant "${value}" should be ${variantList.join(', ')}`,
17
+ variantList.includes(value),
18
+ {
19
+ id: 'pix-ui.pix-segmented-control.variant.not-valid',
20
+ },
21
+ );
22
+
23
+ return value;
24
+ }
25
+
26
+ get className() {
27
+ const classes = ['pix-segmented-control', `pix-segmented-control--${this.variant}`];
28
+
29
+ if (this.args.inlineLabel) {
30
+ classes.push('pix-segmented-control--inline');
31
+ }
32
+
33
+ return classes.join(' ');
34
+ }
35
+
36
+ @action
37
+ onChange() {
38
+ this.args.onChange(!this.args.toggled);
39
+ }
40
+
41
+ get id() {
42
+ return guidFor(this);
43
+ }
44
+
45
+ get toggleName() {
46
+ return `${this.id}-toggle`;
47
+ }
48
+
49
+ get idViewA() {
50
+ return `${this.id}-viewA`;
51
+ }
52
+
53
+ get idViewB() {
54
+ return `${this.id}-viewB`;
55
+ }
56
+
57
+ get stateViewA() {
58
+ return !this.args.toggled;
59
+ }
60
+
61
+ get stateViewB() {
62
+ return this.args.toggled;
63
+ }
64
+
65
+ <template>
66
+ <div class={{this.className}} role="radiogroup" aria-labelledby={{this.id}}>
67
+ <PixLabel
68
+ @for={{this.id}}
69
+ @screenReaderOnly={{@screenReaderOnly}}
70
+ @subLabel={{@subLabel}}
71
+ @size={{@size}}
72
+ @inlineLabel={{@inlineLabel}}
73
+ >
74
+ {{yield to="label"}}
75
+ </PixLabel>
76
+ <div class="pix-segmented-control__radio">
77
+ <input
78
+ {{on "change" this.onChange}}
79
+ id={{this.idViewA}}
80
+ type="radio"
81
+ name={{this.toggleName}}
82
+ value="viewA"
83
+ checked={{this.stateViewA}}
84
+ />
85
+ <label for={{this.idViewA}}>
86
+ {{#if @iconA}}
87
+ <PixIcon @name={{@iconA}} @plainIcon={{this.stateViewA}} @ariaHidden={{true}} />
88
+ {{/if}}
89
+ {{yield to="viewA"}}
90
+ </label>
91
+ <input
92
+ {{on "change" this.onChange}}
93
+ id={{this.idViewB}}
94
+ type="radio"
95
+ name={{this.toggleName}}
96
+ value="viewB"
97
+ checked={{this.stateViewB}}
98
+ />
99
+ <label for={{this.idViewB}}>
100
+ {{#if @iconB}}
101
+ <PixIcon @name={{@iconB}} @plainIcon={{this.stateViewB}} @ariaHidden={{true}} />
102
+ {{/if}}
103
+ {{yield to="viewB"}}
104
+ </label>
105
+ </div>
106
+ </div>
107
+ </template>
108
+ }
@@ -0,0 +1,65 @@
1
+ @use "pix-design-tokens/typography";
2
+
3
+ .pix-segmented-control {
4
+ display: inline-flex;
5
+ flex-direction: column;
6
+ gap: var(--pix-spacing-1x);
7
+ color: var(--pix-neutral-900);
8
+ font-size: 1rem;
9
+
10
+ &--primary .pix-segmented-control__radio {
11
+ background-color: rgb(var(--pix-primary-100-inline), 0.50);
12
+ }
13
+
14
+ &--orga .pix-segmented-control__radio {
15
+ background-color: rgb(var(--pix-orga-500-inline), 0.20);
16
+ }
17
+
18
+ &--certif .pix-segmented-control__radio {
19
+ background-color: rgb(var(--pix-certif-500-inline), 0.20);
20
+ }
21
+
22
+ &__radio {
23
+ position: relative;
24
+ display: inline-flex;
25
+ gap: var(--pix-spacing-1x, 4px);
26
+ align-items: flex-start;
27
+ padding: var(--pix-spacing-1x, 4px);
28
+ border-radius: 8px;
29
+
30
+ :hover {
31
+ cursor: pointer;
32
+ }
33
+
34
+ input[type="radio"], input[type="radio"]:checked, input[type="radio"]:focus-visible {
35
+ position: absolute;
36
+ outline: none;
37
+ appearance: none;
38
+ }
39
+
40
+ label {
41
+ display: flex;
42
+ gap: 10px;
43
+ align-items: center;
44
+ justify-content: center;
45
+ padding: var(--pix-spacing-1x, 4px) 8px;
46
+ border: 1px solid transparent;
47
+ border-radius: 8px;
48
+ }
49
+
50
+ input[type="radio"]:checked + label {
51
+ font-weight: var(--pix-font-bold);
52
+ background: var(--pix-neutral-0);
53
+ }
54
+
55
+ input[type="radio"]:focus + label {
56
+ border-color: var(--pix-neutral-900);
57
+ }
58
+ }
59
+
60
+ &--inline {
61
+ flex-direction: row;
62
+ gap: var(--pix-spacing-2x);
63
+ align-items: center;
64
+ }
65
+ }
@@ -34,7 +34,7 @@
34
34
  @use 'pix-selectable-tag';
35
35
  @use 'pix-pagination';
36
36
  @use 'pix-checkbox';
37
- @use 'pix-toggle-button';
37
+ @use 'pix-segmented-control';
38
38
  @use 'pix-indicator-card';
39
39
  @use 'trap-focus';
40
40
  @use 'pix-search-input';
@@ -14,18 +14,18 @@
14
14
  .pix-title-l {
15
15
  @extend %-pix-title;
16
16
 
17
- --font-size-title: 2rem;
17
+ --font-size-title: 1.75rem;
18
18
 
19
19
  font-size: var(--font-size-title);
20
20
  line-height: 1.3;
21
21
  letter-spacing: calc(-0.02 * var(--font-size-title));
22
22
 
23
23
  @include breakpoints.device-is('tablet') {
24
- --font-size-title: 2.5rem;
24
+ --font-size-title: 1.875rem;
25
25
  }
26
26
 
27
27
  @include breakpoints.device-is('desktop') {
28
- --font-size-title: 3rem;
28
+ --font-size-title: 2rem;
29
29
  }
30
30
  }
31
31
 
@@ -33,7 +33,7 @@
33
33
  .pix-title-m {
34
34
  @extend %-pix-title;
35
35
 
36
- --font-size-title: 1.625rem;
36
+ --font-size-title: 1.5rem;
37
37
  --letter-spacing-title: -0.02;
38
38
 
39
39
  font-size: var(--font-size-title);
@@ -41,11 +41,11 @@
41
41
  letter-spacing: calc(var(--letter-spacing-title) * var(--font-size-title));
42
42
 
43
43
  @include breakpoints.device-is('tablet') {
44
- --font-size-title: 2rem;
44
+ --font-size-title: 1.625rem;
45
45
  }
46
46
 
47
47
  @include breakpoints.device-is('desktop') {
48
- --font-size-title: 2.25rem;
48
+ --font-size-title: 1.75rem;
49
49
  --letter-spacing-title: -0.01;
50
50
  }
51
51
  }
@@ -61,11 +61,11 @@
61
61
  letter-spacing: calc(-0.01 * var(--font-size-title));
62
62
 
63
63
  @include breakpoints.device-is('tablet') {
64
- --font-size-title: 1.5rem;
64
+ --font-size-title: 1.375rem;
65
65
  }
66
66
 
67
67
  @include breakpoints.device-is('desktop') {
68
- --font-size-title: 1.75rem;
68
+ --font-size-title: 1.5rem;
69
69
  }
70
70
  }
71
71
 
@@ -0,0 +1 @@
1
+ export { default } from '@1024pix/pix-ui/components/pix-segmented-control';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "56.0.0",
3
+ "version": "57.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"
@@ -1,23 +0,0 @@
1
- <div class={{this.className}}>
2
- <PixLabel
3
- @for={{this.id}}
4
- @screenReaderOnly={{@screenReaderOnly}}
5
- @subLabel={{@subLabel}}
6
- @size={{@size}}
7
- @inlineLabel={{@inlineLabel}}
8
- >{{yield to="label"}}</PixLabel>
9
- <button
10
- class="pix-toggle-button__button{{if @useIcons ' pix-toggle-button__button--icon'}}"
11
- id={{this.id}}
12
- aria-pressed={{if @toggled "true" "false"}}
13
- type="button"
14
- {{on "click" this.onToggle}}
15
- >
16
- <span class="pix-toggle-button__view-a{{if @useIcons ' pix-toggle-button__with-icon'}}">
17
- {{yield to="viewA"}}
18
- </span>
19
- <span class="pix-toggle-button__view-b{{if @useIcons ' pix-toggle-button__with-icon'}}">
20
- {{yield to="viewB"}}
21
- </span>
22
- </button>
23
- </div>
@@ -1,27 +0,0 @@
1
- import { action } from '@ember/object';
2
- import { guidFor } from '@ember/object/internals';
3
- import Component from '@glimmer/component';
4
-
5
- export default class PixToggleButton extends Component {
6
- get className() {
7
- const classes = ['pix-toggle-button'];
8
- if (this.args.toggled) {
9
- classes.push('pix-toggle-button--pressed');
10
- }
11
-
12
- if (this.args.inlineLabel) {
13
- classes.push('pix-toggle-button--inline');
14
- }
15
-
16
- return classes.join(' ');
17
- }
18
-
19
- @action
20
- onToggle() {
21
- this.args.onChange(!this.args.toggled);
22
- }
23
-
24
- get id() {
25
- return guidFor(this);
26
- }
27
- }
@@ -1,62 +0,0 @@
1
- @use "pix-design-tokens/typography";
2
-
3
- .pix-toggle-button {
4
- display: inline-flex;
5
- flex-direction: column;
6
- gap: var(--pix-spacing-1x);
7
-
8
- &--inline {
9
- flex-direction: row;
10
- gap: var(--pix-spacing-2x);
11
- align-items: center;
12
- }
13
-
14
- &__button {
15
- @extend %pix-body-s;
16
-
17
- width: fit-content;
18
- padding: var(--pix-spacing-1x);
19
- font-weight: var(--pix-font-bold);
20
- line-height: 1.572;
21
- background: var(--pix-neutral-20);
22
- border: 1px solid var(--pix-neutral-500);
23
- border-radius: 4px;
24
-
25
- &--icon {
26
- font-size: 0;
27
- }
28
- }
29
-
30
- &__view-a,
31
- &__view-b {
32
- display: inline-block;
33
- padding: var(--pix-spacing-1x) var(--pix-spacing-2x);
34
- border-radius: 4px;
35
- }
36
-
37
- &__view-a {
38
- color: var(--pix-neutral-800);
39
- font-weight: var(--pix-font-normal);
40
- }
41
-
42
- &__view-b {
43
- color: var(--pix-neutral-20);
44
- background-color: var(--pix-neutral-800);
45
- }
46
-
47
- &--pressed {
48
- .pix-toggle-button {
49
- &__view-a {
50
- color: var(--pix-neutral-20);
51
- font-weight: inherit;
52
- background-color: var(--pix-neutral-800);
53
- }
54
-
55
- &__view-b {
56
- color: var(--pix-neutral-800);
57
- font-weight: var(--pix-font-normal);
58
- background-color: transparent;
59
- }
60
- }
61
- }
62
- }
@@ -1 +0,0 @@
1
- export { default } from '@1024pix/pix-ui/components/pix-toggle-button';