Skip to content

Commit

Permalink
[FEATURE] ajoute une declinaison de la navigation pour mobile (pix-15…
Browse files Browse the repository at this point in the history
…284)

 #770
  • Loading branch information
pix-service-auto-merge authored Nov 28, 2024
2 parents 3095186 + 8caf789 commit 25c24ec
Show file tree
Hide file tree
Showing 12 changed files with 295 additions and 84 deletions.
28 changes: 22 additions & 6 deletions addon/components/pix-navigation.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
<aside ...attributes class="pix-navigation">
<header class="pix-navigation__brand">{{yield to="brand"}}</header>
<nav class="pix-navigation__nav" aria-label={{@navigationAriaLabel}}>{{yield
to="navElements"
}}</nav>
<footer class="pix-navigation__footer">{{yield to="footer"}}</footer>
<aside
...attributes
class="pix-navigation {{if this.navigationMenuOpened 'pix-navigation--opened'}}"
>
<header class="pix-navigation__brand">{{yield to="brand"}}
<div class="pix-navigation__burger-menu"><PixButton
aria-controls="{{this.navigationId}} {{this.footerId}}"
aria-expanded={{this.navigationMenuOpened}}
@iconBefore={{if this.navigationMenuOpened "close" "menu"}}
@triggerAction={{this.toggleNavigationMenu}}
>{{@menuLabel}}</PixButton>
</div>
</header>
<nav
class="pix-navigation__nav"
{{on "click" this.handleNavigationClick}}
aria-label={{@navigationAriaLabel}}
id={{this.navigationId}}
>
{{yield to="navElements"}}
</nav>
<footer class="pix-navigation__footer" id={{this.footerId}}>{{yield to="footer"}}</footer>
</aside>
33 changes: 33 additions & 0 deletions addon/components/pix-navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { guidFor } from '@ember/object/internals';

export default class PixMNavigation extends Component {
constructor(...args) {
super(...args);
this._navigationId = 'navigation-' + guidFor(this);
}
@tracked
navigationMenuOpened = false;

@action
toggleNavigationMenu() {
this.navigationMenuOpened = !this.navigationMenuOpened;
}

@action
handleNavigationClick(event) {
if (event.target.nodeName === 'A') {
this.navigationMenuOpened = false;
}
}

get navigationId() {
return `${this._navigationId}-nav`;
}

get footerId() {
return `${this._navigationId}-footer`;
}
}
8 changes: 7 additions & 1 deletion addon/styles/_pix-app-layout.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
.pix-app-layout {
--pix-navigation-width: 13.375rem;

display: grid;
grid-template-columns: minmax(214px, auto) 1fr;
grid-template-columns: var(--pix-navigation-width) 1fr;
gap: var(--pix-spacing-6x);
padding: var(--pix-spacing-6x);

@include device-is('mobile') {
display: block
}

&--orga {
background-color: var(--pix-orga-50);

Expand Down
126 changes: 115 additions & 11 deletions addon/styles/_pix-navigation.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
.pix-navigation {
--bg-color-focus: rgb(var(--pix-neutral-100-inline), 50%);
--bg-color-active: rgb(var(--pix-neutral-100-inline), 30%);


position: sticky;
bottom: var(--pix-spacing-6x);
z-index: 1;
display: flex;
flex-direction: column;
gap:var(--pix-spacing-6x);
align-items: center;
min-width: 214px;
height: fit-content;
justify-content: space-between;
min-width: var(--pix-navigation-width);
height: auto;
min-height: calc(100vh - var(--pix-spacing-6x) * 2);

// using a margin top / bottom allow user to discover rapidly
Expand All @@ -17,52 +23,151 @@
background-color: var(--pix-navigation-color);
border-radius: var(--pix-spacing-6x);

--pix-navigation-button-bgcolor-hover: rgb(205, 209, 217, .3);
--pix-navigation-button-bgcolor-active: rgb(205, 209, 217, .5);

@include device-is('mobile') {
position: static;
flex-direction: column;
align-items: stretch;
width: 100%;
min-height: auto;
padding: 0;

&--opened {
justify-content: flex-start;
}
}


&__brand {
margin-bottom: 0;
padding:0;
line-height: 0;

img {
width: 132px;
height: 48px;
}

@include device-is('mobile') {
display:flex;
flex-direction: row;
align-items: center;
padding: var(--pix-spacing-4x) var(--pix-spacing-2x) var(--pix-spacing-4x) var(--pix-spacing-10x);

img {
width: 85px;
height: 32px;
}

.pix-navigation--opened & {
padding-bottom: 0
}
}
}

&__burger-menu {
display: none;

@include device-is('mobile') {
display: block;
margin-left:auto;

.pix-button {
background-color: transparent;

&:focus, &:focus-visible {
background-color: rgb(var(--pix-neutral-800-inline), 20%);
outline: none;
}

&:hover {
background-color: rgb(var(--pix-neutral-800-inline), 20%);
}

&:active {
background-color: rgb(var(--pix-neutral-800-inline), 30%);
}
}
}
}

&__nav {
display: flex;
flex-direction: column;
gap: var(--pix-spacing-2x);
align-self: stretch;

@include device-is('mobile') {
display: none;
padding: 0 var(--pix-spacing-6x);

.pix-navigation--opened & {
display: block;
}
}


}

&__footer {
display: flex;
flex-direction: column;
gap: var(--pix-spacing-2x);
margin-top: auto;
padding: 0;
text-align: center;

@extend %pix-body-s;

p {
word-break: break-all;
}

@include device-is('mobile') {
display: none;

.pix-navigation--opened & {
display: flex;
justify-content: stretch;
padding: 0 var(--pix-spacing-6x) var(--pix-spacing-4x);

&::before {
width: 80px;
margin: var(--pix-spacing-6x) auto;
border-top: 1px solid var(--pix-neutral-100);
content: "";
}
}
}

.pix-button {
width: 100%;

@include device-is('mobile') {
width: auto;
}
}

& .pix-button--primary {
color: var(--pix-navigation-color);
background-color:var(--pix-navigation-text-color);

&:hover {
color: currentcolor;
background-color: var(--pix-navigation-button-bgcolor-hover);
background-color: var(--bg-color-focus);
fill: currentcolor;
}

&:focus,
&:focus-visible {
color: currentcolor;
background-color: var(--pix-navigation-button-bgcolor-hover);
background-color: var(--bg-color-focus);
outline-color: currentcolor;
}

&:active {
color: currentcolor;
background-color: var(--pix-navigation-button-bgcolor-active);
background-color: var(--bg-color-active);
}
}

Expand All @@ -72,20 +177,20 @@

&:hover {
color: currentcolor;
background-color: var(--pix-navigation-button-bgcolor-hover);
background-color: var(--bg-color-focus);
fill: currentcolor;
}

&:focus,
&:focus-visible {
color: currentcolor;
background-color: var(--pix-navigation-button-bgcolor-hover);
background-color: var(--bg-color-focus);
outline-color: currentcolor;
}

&:active {
color: currentcolor;
background-color: var(--pix-navigation-button-bgcolor-active);
background-color: var(--bg-color-active);
}
}

Expand All @@ -101,6 +206,5 @@
}
}
}

}

7 changes: 3 additions & 4 deletions addon/styles/_pix-select-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
&__option {
@extend %pix-body-s;

&:nth-child(even) {
background-color: var(--pix-neutral-20);
}

position: relative;
padding: var(--pix-spacing-2x) var(--pix-spacing-8x) var(--pix-spacing-2x) var(--pix-spacing-4x);
color: var(--pix-neutral-900);
border-radius: 8px;

&:nth-child(even) {
background-color: var(--pix-neutral-20);
}

&:hover,
&:focus {
Expand Down
36 changes: 36 additions & 0 deletions addon/styles/_pix-structure-switcher.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@
--pix-structure-bg-hover: var(--pix-certif-50);
}

@include device-is("mobile") {
width: 100%;
}

.pix-button {
width: 100%;

.pix-navigation--opened & {
width: auto;
margin:auto;
}
}

.pix-select__dropdown {
Expand All @@ -24,13 +33,32 @@
margin-left: var(--pix-spacing-6x) !important; // we need to override popperjs inline styles
overflow-y: auto;
border-radius: 8px;

@include device-is('mobile') {
position: static !important;
display: none;
width: 0; // force dropdown to resize to its parent
max-width: none;
max-height: none;
margin-left:0 !important;
overflow-y: visible;
transform: none !important;
transition: none;

.pix-navigation--opened &:not(.pix-select__dropdown--closed) {
display: block;
margin-top: var(--pix-spacing-4x) !important;
}
}
}

.pix-select_list {
display: flex;
flex-direction: column;
gap: var(--pix-spacing-2x);
min-width: 100%;
padding: var(--pix-spacing-2x);
border-top: none;
}

.pix-select-list-category__option--hidden {
Expand All @@ -47,6 +75,10 @@
text-overflow: ellipsis;
border-radius: var(--border-radius-2x);

&:focus:not(.pix-select-list-category__option--selected ) {
background-color: var(--pix-structure-bg-hover);
}

&:hover {
background-color: var(--pix-structure-bg-hover);
}
Expand All @@ -60,5 +92,9 @@
&:hover {
background-color: var(--pix-navigation-color);
}

&:focus {
color: var(--pix-neutral-800)
}
}
}
1 change: 1 addition & 0 deletions app/stories/pix-app-layout.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ C'est ce composant qui va porter la variante de couleur (orga, certif, primary)
```html
<PixAppLayout @variant="orga">
<PixNavigation @navigationAriaLabel="navigation principale"> </PixNavigation>
<main>{{outlet}}</main>
</PixAppLayout>
```

Expand Down
Loading

0 comments on commit 25c24ec

Please sign in to comment.