Skip to content
Snippets Groups Projects
Commit 05b3b20c authored by Samuel Abiassi's avatar Samuel Abiassi
Browse files

fix(backtotop): redirection avec les ancres

parent 1c122d78
Loading
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
- feat(tab): ajout de la propriété `disabled` - feat(tab): ajout de la propriété `disabled`
- feat(table): nouveau composant de tableau avec pagination, sélection et tri - feat(table): nouveau composant de tableau avec pagination, sélection et tri
- feat(toggle): ajout des messages d'erreur et de validation - feat(toggle): ajout des messages d'erreur et de validation
- fix(backtotop): l'ancrage fonctionne correctement
- fix(card/tile): `linkTarget` n'est pas utilisé dans le téléchargement - fix(card/tile): `linkTarget` n'est pas utilisé dans le téléchargement
- fix(content): structure html modifiée pour respecter le DSFR - fix(content): structure html modifiée pour respecter le DSFR
- fix(footer): changement d'ordres des liens institutionnels & ajout de l'attribut `title` - fix(footer): changement d'ordres des liens institutionnels & ajout de l'attribut `title`
......
<a class="fr-link fr-icon-arrow-up-fill fr-link--icon-left" href="#top"> <dsfr-link
{{ i18n.t('backtotop.topOfPage') }} class="fr-link fr-icon-arrow-up-fill fr-link--icon-left"
</a> routerLink="./"
[routerLinkExtras]="{ fragment: 'top' }"
>{{ backToTopLabel }}</dsfr-link
>
...@@ -7,5 +7,8 @@ import { I18nService } from '../../shared'; ...@@ -7,5 +7,8 @@ import { I18nService } from '../../shared';
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
}) })
export class DsfrBackToTopComponent { export class DsfrBackToTopComponent {
constructor(/** @internal */ public i18n: I18nService) {} /** @internal */
backToTopLabel = this.i18n.t('backtotop.topOfPage');
constructor(private i18n: I18nService) {}
} }
...@@ -13,6 +13,13 @@ Dans les pages de contenu longues, il est possible de proposer un bouton de reto ...@@ -13,6 +13,13 @@ Dans les pages de contenu longues, il est possible de proposer un bouton de reto
- _Composant_ : `DsfrBackToTopComponent` - _Composant_ : `DsfrBackToTopComponent`
- _Tag_ : `dsfr-backtotop` - _Tag_ : `dsfr-backtotop`
## Fonctionnement
Le lien de retour en haut de page nécessite deux éléments pour fonctionner :
- Un élément html portant un `id` de valeur `top` (ex: `<h1 id="top">Mon titre</h1>`).
- L'activation du paramètre `anchorScrolling` dans les options du router Angular.
## Aperçu ## Aperçu
<Canvas of={Stories.Default} /> <Canvas of={Stories.Default} />
......
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { DsfrLinkModule } from '../link';
import { DsfrBackToTopComponent } from './backtotop.component'; import { DsfrBackToTopComponent } from './backtotop.component';
@NgModule({ @NgModule({
declarations: [DsfrBackToTopComponent], declarations: [DsfrBackToTopComponent],
exports: [DsfrBackToTopComponent], exports: [DsfrBackToTopComponent],
imports: [CommonModule], imports: [CommonModule, DsfrLinkModule],
}) })
export class DsfrBackToTopModule {} export class DsfrBackToTopModule {}
import { RouterTestingModule } from '@angular/router/testing';
import { Meta, moduleMetadata, StoryObj } from '@storybook/angular'; import { Meta, moduleMetadata, StoryObj } from '@storybook/angular';
import { DsfrLinkModule } from '../link';
import { DsfrBackToTopComponent } from './backtotop.component'; import { DsfrBackToTopComponent } from './backtotop.component';
const meta: Meta = { const meta: Meta = {
title: 'COMPONENTS/Back to Top', title: 'COMPONENTS/Back to Top',
component: DsfrBackToTopComponent, component: DsfrBackToTopComponent,
decorators: [moduleMetadata({ imports: [] })], decorators: [moduleMetadata({ imports: [DsfrLinkModule, RouterTestingModule] })],
}; };
export default meta; export default meta;
type Story = StoryObj<DsfrBackToTopComponent>; type Story = StoryObj<DsfrBackToTopComponent>;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment