-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Voir dans une Sidebar les grains accessibles (PIX-15396)
- Loading branch information
Showing
10 changed files
with
234 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,77 @@ | ||
import PixButton from '@1024pix/pix-ui/components/pix-button'; | ||
import PixProgressGauge from '@1024pix/pix-ui/components/pix-progress-gauge'; | ||
import PixSidebar from '@1024pix/pix-ui/components/pix-sidebar'; | ||
import { action } from '@ember/object'; | ||
import { service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { t } from 'ember-intl'; | ||
import { eq } from 'ember-truth-helpers'; | ||
|
||
export default class ModulixNavbar extends Component { | ||
@service intl; | ||
|
||
get progressValue() { | ||
if (this.args.totalSteps <= 1) { | ||
return 100; | ||
} | ||
return ((this.args.currentStep - 1) / (this.args.totalSteps - 1)) * 100; | ||
} | ||
|
||
@tracked | ||
sidebarOpened = false; | ||
|
||
@action | ||
openSidebar() { | ||
this.sidebarOpened = true; | ||
} | ||
|
||
@action | ||
closeSidebar() { | ||
this.sidebarOpened = false; | ||
} | ||
|
||
get grainTypeTexts() { | ||
return this.args.grainsToDisplay.map((grain) => this.intl.t(`pages.modulix.grain.tag.${grain.type}`)); | ||
} | ||
|
||
get currentGrainIndex() { | ||
return this.grainTypeTexts.length - 1; | ||
} | ||
|
||
<template> | ||
<nav | ||
class="module-navbar" | ||
aria-label={{t "pages.modulix.flashcards.navigation.currentStep" current=@currentStep total=@totalSteps}} | ||
> | ||
<div class="module-navbar__content"> | ||
<div class="module-navbar__content__current-step"> | ||
{{@currentStep}}/{{@totalSteps}} | ||
</div> | ||
<PixButton | ||
@variant="tertiary" | ||
@triggerAction={{this.openSidebar}} | ||
aria-label={{t "pages.modulix.sidebar.button"}} | ||
> | ||
{{t "pages.modulix.flashcards.navigation.currentStep" current=@currentStep total=@totalSteps}} | ||
</PixButton> | ||
|
||
<PixProgressGauge @hidePercentage={{true}} @isDecorative={{true}} @value={{this.progressValue}} /> | ||
</div> | ||
</nav> | ||
|
||
<PixSidebar @title={{@module.title}} @showSidebar={{this.sidebarOpened}} @onClose={{this.closeSidebar}}> | ||
<:content> | ||
<nav> | ||
<ul> | ||
{{#each this.grainTypeTexts as |type index|}} | ||
<li | ||
class="module-sidebar-list-item__link {{if (eq index this.currentGrainIndex) 'current-grain'}}" | ||
aria-current={{if (eq index this.currentGrainIndex) "step"}} | ||
> | ||
{{type}} | ||
</li> | ||
{{/each}} | ||
</ul> | ||
</nav> | ||
</:content> | ||
</PixSidebar> | ||
</template> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.