@1024pix/pix-ui 57.2.0 → 58.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/addon/components/pix-app-layout.gjs +7 -0
- package/addon/components/pix-navigation-button.gjs +57 -48
- package/addon/components/pix-navigation-shrunk-button.gjs +53 -0
- package/addon/components/pix-navigation.hbs +13 -1
- package/addon/components/pix-navigation.js +25 -1
- package/addon/services/shrink-navigation-service.js +23 -0
- package/addon/styles/_pix-navigation-shrunk-button.scss +43 -0
- package/addon/styles/_pix-navigation.scss +22 -0
- package/addon/styles/addon.scss +1 -0
- package/addon/styles/pix-design-tokens/_colors.scss +2 -0
- package/addon/translations/en.js +4 -0
- package/addon/translations/es.js +4 -0
- package/addon/translations/fr.js +4 -0
- package/addon/translations/nl.js +4 -0
- package/app/components/pix-navigation-shrunk-button.js +1 -0
- package/app/services/shrink-navigation-service.js +1 -0
- package/package.json +1 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { VARIANTS } from '@1024pix/pix-ui/helpers/variants';
|
|
2
2
|
import { warn } from '@ember/debug';
|
|
3
|
+
import { inject as service } from '@ember/service';
|
|
3
4
|
import Component from '@glimmer/component';
|
|
4
5
|
|
|
5
6
|
import onWindowResize from '../modifiers/on-window-resize';
|
|
6
7
|
|
|
7
8
|
export default class PixAppLayout extends Component {
|
|
9
|
+
@service shrinkNavigationService;
|
|
10
|
+
|
|
8
11
|
#computeMarginTopElement(entries) {
|
|
9
12
|
for (const entry of entries) {
|
|
10
13
|
if (entry.target.id === 'pix-layout-banner-container') {
|
|
@@ -36,6 +39,10 @@ export default class PixAppLayout extends Component {
|
|
|
36
39
|
},
|
|
37
40
|
);
|
|
38
41
|
|
|
42
|
+
if (this.args.variant === 'admin') {
|
|
43
|
+
this.shrinkNavigationService.displayShrunkNavigationButton();
|
|
44
|
+
}
|
|
45
|
+
|
|
39
46
|
return value;
|
|
40
47
|
}
|
|
41
48
|
get classNames() {
|
|
@@ -4,11 +4,13 @@ import { service } from '@ember/service';
|
|
|
4
4
|
import Component from '@glimmer/component';
|
|
5
5
|
|
|
6
6
|
import PixIcon from './pix-icon';
|
|
7
|
+
import PixNavigationShrunkButton from './pix-navigation-shrunk-button';
|
|
7
8
|
|
|
8
9
|
export default class PixNavigationButton extends Component {
|
|
9
10
|
defaultParams = {};
|
|
10
11
|
defaultModel = [];
|
|
11
12
|
@service router;
|
|
13
|
+
@service shrinkNavigationService;
|
|
12
14
|
|
|
13
15
|
get isActiveRoute() {
|
|
14
16
|
return this.args.route === this.router.currentRouteName;
|
|
@@ -19,56 +21,63 @@ export default class PixNavigationButton extends Component {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
<template>
|
|
22
|
-
{{#if
|
|
23
|
-
<
|
|
24
|
+
{{#if this.shrinkNavigationService.isShrunk}}
|
|
25
|
+
<PixNavigationShrunkButton
|
|
24
26
|
@route={{@route}}
|
|
25
|
-
@
|
|
26
|
-
|
|
27
|
-
class="pix-navigation-button"
|
|
28
|
-
target={{if this.isLinkOpenInANewWindow "_blank"}}
|
|
29
|
-
...attributes
|
|
30
|
-
>
|
|
31
|
-
{{#if @icon}}
|
|
32
|
-
<PixIcon
|
|
33
|
-
class="pix-navigation-button__icon"
|
|
34
|
-
@ariaHidden={{true}}
|
|
35
|
-
@name={{@icon}}
|
|
36
|
-
@plainIcon={{if this.isActiveRoute true false}}
|
|
37
|
-
/>
|
|
38
|
-
{{/if}}
|
|
39
|
-
{{yield}}
|
|
40
|
-
{{#if this.isLinkOpenInANewWindow}}
|
|
41
|
-
<PixIcon
|
|
42
|
-
class="pix-navigation-button__external-icon"
|
|
43
|
-
@ariaHidden={{true}}
|
|
44
|
-
@name="openNew"
|
|
45
|
-
/>
|
|
46
|
-
{{/if}}
|
|
47
|
-
</LinkTo>
|
|
27
|
+
@icon={{@icon}}
|
|
28
|
+
>{{yield}}</PixNavigationShrunkButton>
|
|
48
29
|
{{else}}
|
|
49
|
-
{{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
30
|
+
{{#if @route}}
|
|
31
|
+
<LinkTo
|
|
32
|
+
@route={{@route}}
|
|
33
|
+
@models={{if @model (array @model) this.defaultModel}}
|
|
34
|
+
@query={{if @query @query this.defaultParams}}
|
|
35
|
+
class="pix-navigation-button"
|
|
36
|
+
target={{if this.isLinkOpenInANewWindow "_blank"}}
|
|
37
|
+
...attributes
|
|
38
|
+
>
|
|
39
|
+
{{#if @icon}}
|
|
40
|
+
<PixIcon
|
|
41
|
+
class="pix-navigation-button__icon"
|
|
42
|
+
@ariaHidden={{true}}
|
|
43
|
+
@name={{@icon}}
|
|
44
|
+
@plainIcon={{if this.isActiveRoute true false}}
|
|
45
|
+
/>
|
|
46
|
+
{{/if}}
|
|
47
|
+
{{yield}}
|
|
48
|
+
{{#if this.isLinkOpenInANewWindow}}
|
|
49
|
+
<PixIcon
|
|
50
|
+
class="pix-navigation-button__external-icon"
|
|
51
|
+
@ariaHidden={{true}}
|
|
52
|
+
@name="openNew"
|
|
53
|
+
/>
|
|
54
|
+
{{/if}}
|
|
55
|
+
</LinkTo>
|
|
56
|
+
{{else}}
|
|
57
|
+
{{! template-lint-disable link-href-attributes }}
|
|
58
|
+
<a
|
|
59
|
+
class="pix-navigation-button"
|
|
60
|
+
target={{if this.isLinkOpenInANewWindow "_blank"}}
|
|
61
|
+
...attributes
|
|
62
|
+
>
|
|
63
|
+
{{#if @icon}}
|
|
64
|
+
<PixIcon
|
|
65
|
+
class="pix-navigation-button__icon"
|
|
66
|
+
@ariaHidden={{true}}
|
|
67
|
+
@name={{@icon}}
|
|
68
|
+
@plainIcon={{@iconPlain}}
|
|
69
|
+
/>
|
|
70
|
+
{{/if}}
|
|
71
|
+
{{yield}}
|
|
72
|
+
{{#if this.isLinkOpenInANewWindow}}
|
|
73
|
+
<PixIcon
|
|
74
|
+
class="pix-navigation-button__external-icon"
|
|
75
|
+
@ariaHidden={{true}}
|
|
76
|
+
@name="openNew"
|
|
77
|
+
/>
|
|
78
|
+
{{/if}}
|
|
79
|
+
</a>
|
|
80
|
+
{{/if}}
|
|
72
81
|
{{/if}}
|
|
73
82
|
</template>
|
|
74
83
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { on } from '@ember/modifier';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
import { LinkTo } from '@ember/routing';
|
|
4
|
+
import Component from '@glimmer/component';
|
|
5
|
+
import { tracked } from '@glimmer/tracking';
|
|
6
|
+
|
|
7
|
+
import PixIcon from './pix-icon';
|
|
8
|
+
|
|
9
|
+
export default class PixNavigationShrunkButton extends Component {
|
|
10
|
+
@tracked isTooltipVisible = false;
|
|
11
|
+
|
|
12
|
+
@action
|
|
13
|
+
showTooltip() {
|
|
14
|
+
this.isTooltipVisible = true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@action
|
|
18
|
+
hideTooltip() {
|
|
19
|
+
setTimeout(() => (this.isTooltipVisible = false));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@action
|
|
23
|
+
hideTooltipOnMouseOut(event) {
|
|
24
|
+
const isFocused = event.target.contains(document.activeElement);
|
|
25
|
+
|
|
26
|
+
if (isFocused) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.hideTooltip(event);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<div
|
|
35
|
+
class="navigation-tooltip {{if this.isTooltipVisible 'navigation-tooltip--visible' ''}}"
|
|
36
|
+
{{on "mouseleave" this.hideTooltipOnMouseOut}}
|
|
37
|
+
{{on "mouseenter" this.showTooltip}}
|
|
38
|
+
{{on "focusin" this.showTooltip}}
|
|
39
|
+
{{on "focusout" this.hideTooltip}}
|
|
40
|
+
>
|
|
41
|
+
<LinkTo
|
|
42
|
+
@route={{@route}}
|
|
43
|
+
class="pix-navigation-button navigation-shrunk-button"
|
|
44
|
+
...attributes
|
|
45
|
+
>
|
|
46
|
+
<PixIcon class="pix-navigation-button__icon" @ariaHidden={{true}} @name={{@icon}} />
|
|
47
|
+
</LinkTo>
|
|
48
|
+
<span role="tooltip" class="navigation-tooltip__content" aria-hidden="true">
|
|
49
|
+
{{yield}}
|
|
50
|
+
</span>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
53
|
+
}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
<aside
|
|
2
2
|
...attributes
|
|
3
|
-
class="pix-navigation
|
|
3
|
+
class="pix-navigation
|
|
4
|
+
{{if this.navigationMenuOpened 'pix-navigation--opened'}}
|
|
5
|
+
{{if this.shrinkNavigationService.isShrunk 'pix-navigation--shrunk'}}"
|
|
4
6
|
>
|
|
5
7
|
<header class="pix-navigation__brand">{{yield to="brand"}}
|
|
8
|
+
{{#if this.shrinkNavigationService.canNavigationBeShrunk}}
|
|
9
|
+
<div class="pix-navigation__shrunk-container">
|
|
10
|
+
<PixIconButton
|
|
11
|
+
class="pix-navigation-shrunk-button"
|
|
12
|
+
@iconName={{this.shrunkNavigationIcon}}
|
|
13
|
+
@triggerAction={{this.shrinkNavigation}}
|
|
14
|
+
@ariaLabel="{{this.shrunkNavigationAriaLabel}}"
|
|
15
|
+
/>
|
|
16
|
+
</div>
|
|
17
|
+
{{/if}}
|
|
6
18
|
<div class="pix-navigation__burger-menu"><PixButton
|
|
7
19
|
aria-controls="{{this.navigationId}} {{this.footerId}}"
|
|
8
20
|
aria-expanded={{this.navigationMenuOpened}}
|
|
@@ -5,8 +5,11 @@ import { inject as service } from '@ember/service';
|
|
|
5
5
|
import Component from '@glimmer/component';
|
|
6
6
|
import { tracked } from '@glimmer/tracking';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import { formatMessage } from '../translations';
|
|
9
|
+
|
|
10
|
+
export default class PixNavigation extends Component {
|
|
9
11
|
@service router;
|
|
12
|
+
@service shrinkNavigationService;
|
|
10
13
|
|
|
11
14
|
constructor(...args) {
|
|
12
15
|
super(...args);
|
|
@@ -23,6 +26,10 @@ export default class PixMNavigation extends Component {
|
|
|
23
26
|
@tracked
|
|
24
27
|
navigationMenuOpened = false;
|
|
25
28
|
|
|
29
|
+
formatMessage(message, values) {
|
|
30
|
+
return formatMessage(this.args.locale ?? 'fr', `pixNavigation.${message}`, values);
|
|
31
|
+
}
|
|
32
|
+
|
|
26
33
|
@action
|
|
27
34
|
toggleNavigationMenu() {
|
|
28
35
|
this.navigationMenuOpened = !this.navigationMenuOpened;
|
|
@@ -44,6 +51,23 @@ export default class PixMNavigation extends Component {
|
|
|
44
51
|
}
|
|
45
52
|
}
|
|
46
53
|
|
|
54
|
+
@action
|
|
55
|
+
shrinkNavigation() {
|
|
56
|
+
this.shrinkNavigationService.shrinkNavigation();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
get shrunkNavigationIcon() {
|
|
60
|
+
return this.shrinkNavigationService.isShrunk ? 'arrowMenuOpen' : 'arrowMenuClose';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
get shrunkNavigationAriaLabel() {
|
|
64
|
+
return this.formatMessage(
|
|
65
|
+
this.shrinkNavigationService.isShrunk
|
|
66
|
+
? 'expandNavigationAriaLabel'
|
|
67
|
+
: 'shrinkNavigationAriaLabel',
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
47
71
|
get navigationId() {
|
|
48
72
|
return `${this._navigationId}-nav`;
|
|
49
73
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { action } from '@ember/object';
|
|
2
|
+
import Service from '@ember/service';
|
|
3
|
+
import { tracked } from '@glimmer/tracking';
|
|
4
|
+
|
|
5
|
+
export default class ShrinkNavigationService extends Service {
|
|
6
|
+
@tracked canNavigationBeShrunk = false;
|
|
7
|
+
@tracked isShrunk = false;
|
|
8
|
+
|
|
9
|
+
@action displayShrunkNavigationButton() {
|
|
10
|
+
this.canNavigationBeShrunk = true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@action shrinkNavigation() {
|
|
14
|
+
this.isShrunk = !this.isShrunk;
|
|
15
|
+
|
|
16
|
+
const root = document.documentElement;
|
|
17
|
+
|
|
18
|
+
if (this.isShrunk) {
|
|
19
|
+
return root.style.setProperty('--pix-navigation-width', '88px');
|
|
20
|
+
}
|
|
21
|
+
return root.style.setProperty('--pix-navigation-width', '15rem');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
@use "pix-design-tokens/typography";
|
|
2
|
+
|
|
3
|
+
.navigation-tooltip {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
|
|
9
|
+
&__content {
|
|
10
|
+
@extend %pix-title-xxs;
|
|
11
|
+
|
|
12
|
+
position: absolute;
|
|
13
|
+
left: calc(100% + 10px);
|
|
14
|
+
width: max-content;
|
|
15
|
+
padding: var(--pix-spacing-1x) var(--pix-spacing-4x);
|
|
16
|
+
color: var(--pix-neutral-800);
|
|
17
|
+
background-color: var(--pix-neutral-0);
|
|
18
|
+
border-radius: var(--pix-spacing-2x);
|
|
19
|
+
visibility: hidden;
|
|
20
|
+
opacity: 0;
|
|
21
|
+
transition: opacity 0.3s;
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&--visible {
|
|
26
|
+
&:hover, &:active {
|
|
27
|
+
.navigation-tooltip__content {
|
|
28
|
+
visibility: visible;
|
|
29
|
+
opacity: 1;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Focus event is triggered by the button. That's why we are duplicating the style for this case.
|
|
34
|
+
.navigation-shrunk-button:focus-within + .navigation-tooltip__content {
|
|
35
|
+
visibility: visible;
|
|
36
|
+
opacity: 1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.navigation-shrunk-button {
|
|
42
|
+
justify-content: center;
|
|
43
|
+
}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
color: var(--pix-navigation-text-color);
|
|
22
22
|
background-color: var(--pix-navigation-color);
|
|
23
23
|
border-radius: var(--pix-spacing-6x);
|
|
24
|
+
transition: all 0.3s ease;
|
|
24
25
|
|
|
25
26
|
@include breakpoints.device-is('mobile') {
|
|
26
27
|
flex-direction: column;
|
|
@@ -36,6 +37,16 @@
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
&--shrunk {
|
|
41
|
+
--pix-navigation-width: 88px;
|
|
42
|
+
|
|
43
|
+
transition: all 0.3s ease;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&__shrunk-container {
|
|
47
|
+
position: relative;
|
|
48
|
+
height: 20px;
|
|
49
|
+
}
|
|
39
50
|
|
|
40
51
|
&__brand {
|
|
41
52
|
margin-bottom: 0;
|
|
@@ -218,3 +229,14 @@
|
|
|
218
229
|
}
|
|
219
230
|
}
|
|
220
231
|
|
|
232
|
+
.pix-navigation-shrunk-button {
|
|
233
|
+
position: absolute;
|
|
234
|
+
left: calc(100% - 4px);
|
|
235
|
+
background-color: var(--pix-neutral-0);
|
|
236
|
+
border: 1px solid var(--pix-primary-900);
|
|
237
|
+
|
|
238
|
+
@include breakpoints.device-is('mobile') {
|
|
239
|
+
visibility: hidden;
|
|
240
|
+
opacity: 0;
|
|
241
|
+
}
|
|
242
|
+
}
|
package/addon/styles/addon.scss
CHANGED
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
--pix-neutral-20: rgb(var(--pix-neutral-20-inline));
|
|
38
38
|
--pix-neutral-100-inline:205, 209, 217;
|
|
39
39
|
--pix-neutral-100: rgb(var(--pix-neutral-100-inline));
|
|
40
|
+
--pix-neutral-300-inline:147, 157, 173;
|
|
41
|
+
--pix-neutral-300: rgb(var(--pix-neutral-300-inline));
|
|
40
42
|
--pix-neutral-500-inline:94, 108, 132;
|
|
41
43
|
--pix-neutral-500: rgb(var(--pix-neutral-500-inline));
|
|
42
44
|
--pix-neutral-800-inline:37, 56, 88;
|
package/addon/translations/en.js
CHANGED
package/addon/translations/es.js
CHANGED
|
@@ -19,4 +19,8 @@ export default {
|
|
|
19
19
|
pageNumber: 'Página {current, number} / {total, number}',
|
|
20
20
|
nextPageLabel: 'Ir a la página siguiente',
|
|
21
21
|
},
|
|
22
|
+
pixNavigation: {
|
|
23
|
+
shrinkNavigationAriaLabel: 'Reducir el ancho del menú de navegación',
|
|
24
|
+
expandNavigationAriaLabel: 'Volver al ancho inicial del menú de navegación',
|
|
25
|
+
},
|
|
22
26
|
};
|
package/addon/translations/fr.js
CHANGED
package/addon/translations/nl.js
CHANGED
|
@@ -21,4 +21,8 @@ export default {
|
|
|
21
21
|
tag: {
|
|
22
22
|
removeButton: 'Verwijderen',
|
|
23
23
|
},
|
|
24
|
+
pixNavigation: {
|
|
25
|
+
shrinkNavigationAriaLabel: 'De breedte van het navigatiemenu verkleinen',
|
|
26
|
+
expandNavigationAriaLabel: 'Terug naar de oorspronkelijke breedte van het navigatiemenu',
|
|
27
|
+
},
|
|
24
28
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@1024pix/pix-ui/components/pix-navigation-shrunk-button';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@1024pix/pix-ui/services/shrink-navigation-service';
|