Skip to content

Commit

Permalink
feat(sequential-links): add sequential links component
Browse files Browse the repository at this point in the history
  • Loading branch information
LAMM26 committed Sep 3, 2024
1 parent 9c82836 commit d1a067b
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/sdg/src/lib/sequential-links/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './sequential-links.component';
export * from './sequential-links.interface';
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div class="container">
@if (previous()) {
<div class="link" (click)="goToLink(previous()!.url)">

Check warning on line 3 in packages/sdg/src/lib/sequential-links/sequential-links.component.html

View workflow job for this annotation

GitHub Actions / build

click must be accompanied by either keyup, keydown or keypress event for accessibility

Check warning on line 3 in packages/sdg/src/lib/sequential-links/sequential-links.component.html

View workflow job for this annotation

GitHub Actions / build

Elements with interaction handlers must be focusable
<mat-icon class="arrow">arrow_left_alt</mat-icon>
<div class="content">
<p><b>Précédent</b></p>
<p class="text">{{ previous()?.text }}</p>
</div>
</div>
}
@if (next()) {
<div class="link" (click)="goToLink(next()!.url)">

Check warning on line 12 in packages/sdg/src/lib/sequential-links/sequential-links.component.html

View workflow job for this annotation

GitHub Actions / build

click must be accompanied by either keyup, keydown or keypress event for accessibility
<mat-icon class="arrow">arrow_right_alt</mat-icon>
<div class="content">
<p><b>Suivant</b></p>
<p class="text">{{ next()?.text }}</p>
</div>
</div>
}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@use 'sass:map';
@use '../core/theme/colors';

.container {
display: flex;
flex-flow: column;
min-height: 88px;
}

.arrow {
font-variation-settings: 'wght' 350;
}

.link {
display: flex;
padding: 16px 16px 16px 8px;
column-gap: 8px;
border-top: 1px solid colors.$grey-light;
cursor: pointer;

&:hover {
background-color: colors.$grey-pale;

.text {
text-decoration: underline;
}
}

&:focus {
outline: solid 2px colors.$blue-light;
outline-offset: 0;
}

&:last-of-type {
border-bottom: 1px solid colors.$grey-light;
}
}

.content {
display: flex;
flex-flow: column;
row-gap: 8px;
}

.text {
color: colors.$blue-piv;
}

p {
margin: 0px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { TEST_CONFIG } from '../../test-config';
import { SequentialLinksComponent } from './sequential-links.component';

describe('SequentialLinksComponent', () => {
let component: SequentialLinksComponent;
let fixture: ComponentFixture<SequentialLinksComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [SequentialLinksComponent],
providers: [...TEST_CONFIG.providers!]
}).compileComponents();

fixture = TestBed.createComponent(SequentialLinksComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { NgFor, NgIf } from '@angular/common';
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import { MatIconModule } from '@angular/material/icon';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';

import { SequentialLink } from './sequential-links.interface';

@Component({
selector: 'sdg-sequential-links',
standalone: true,
imports: [NgIf, NgFor, MatIconModule, RouterLink],
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './sequential-links.component.html',
styleUrls: ['./sequential-links.component.scss']
})
export class SequentialLinksComponent {
constructor(
private router: Router,
private activatedRoute: ActivatedRoute
) {}

previous = input<SequentialLink>();
next = input<SequentialLink>();
isHandset = input<boolean>();

goToLink(url: string) {
console.log(url);
this.router.navigate(['../', url], { relativeTo: this.activatedRoute });
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface SequentialLink {
text: string;
url: string;
}
1 change: 1 addition & 0 deletions packages/sdg/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from './lib/alert';
export * from './lib/notice';
export * from './lib/tile';
export * from './lib/consult';
export * from './lib/sequential-links';
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<p>
<span
>Les <b>liens séquentiels</b> sont des liens permettant de naviguer vers une
page de contenu suivante ou précédente. Pour plus d'information, voir les
</span>
<span
><app-external-link
title="Liens séquentiels"
link="https://design.quebec.ca/design/composants/navigation/liens-sequentiels"
/></span>
<span>du Système de design gouvernemental.</span>
</p>

<app-example-viewer
title="Liens séquentiels"
configFolder="sequential-links"
codeFolder="sequential-links"
>
<sdg-sequential-links
[previous]="previous"
[next]="next"
[isHandset]="isHandset()"
></sdg-sequential-links>
</app-example-viewer>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { TEST_CONFIG } from 'projects/demo/src/test-config';

import { SequentialLinksDemoComponent } from './sequential-links.component';

describe('SequentialLinksDemoComponent', () => {
let component: SequentialLinksDemoComponent;
let fixture: ComponentFixture<SequentialLinksDemoComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [SequentialLinksDemoComponent],
providers: [...TEST_CONFIG.providers!]
}).compileComponents();

fixture = TestBed.createComponent(SequentialLinksDemoComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Component, Signal } from '@angular/core';

import { NoticeComponent, SequentialLink } from '@igo2/sdg';

import { SequentialLinksComponent } from '../../../../../../../../packages/sdg/src/lib/sequential-links/sequential-links.component';
import { AppService } from '../../../../app.service';
import { ExampleViewerComponent } from '../../../../components/example-viewer/example-viewer.component';
import { ExternalLinkComponent } from '../../../../components/external-link/external-link.component';

@Component({
selector: 'app-sequential-links',
standalone: true,
imports: [
ExampleViewerComponent,
ExternalLinkComponent,
NoticeComponent,
SequentialLinksComponent
],
templateUrl: './sequential-links.component.html',
styleUrl: './sequential-links.component.scss'
})
export class SequentialLinksDemoComponent {
constructor(private appService: AppService) {}

previous: SequentialLink = {
text: "Fil d'Ariane",
url: 'fil-ariane'
};

next: SequentialLink = {
text: 'Tuile',
url: 'tuile'
};

get isHandset(): Signal<boolean> {
return this.appService.isHandset;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ export const routes: INavigationRoutes = [
(m) => m.BreadcrumbDemoComponent
)
},
{
path: 'liens-sequentiels',
title: 'Liens séquentiels',
loadComponent: () =>
import('./sequential-links/sequential-links.component').then(
(m) => m.SequentialLinksDemoComponent
)
},
{
path: 'tuile',
title: 'Tuile',
Expand Down

0 comments on commit d1a067b

Please sign in to comment.