-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sequential-links): add sequential links component
- Loading branch information
Showing
12 changed files
with
227 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './sequential-links.component'; | ||
export * from './sequential-links.interface'; |
20 changes: 20 additions & 0 deletions
20
packages/sdg/src/lib/sequential-links/sequential-links.component.html
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 |
---|---|---|
@@ -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
|
||
<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)"> | ||
<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> |
51 changes: 51 additions & 0 deletions
51
packages/sdg/src/lib/sequential-links/sequential-links.component.scss
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 |
---|---|---|
@@ -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; | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/sdg/src/lib/sequential-links/sequential-links.component.spec.ts
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 |
---|---|---|
@@ -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(); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
packages/sdg/src/lib/sequential-links/sequential-links.component.ts
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 |
---|---|---|
@@ -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 }); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/sdg/src/lib/sequential-links/sequential-links.interface.ts
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface SequentialLink { | ||
text: string; | ||
url: string; | ||
} |
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
24 changes: 24 additions & 0 deletions
24
.../demo/src/app/pages/components/showcases/sequential-links/sequential-links.component.html
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 |
---|---|---|
@@ -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> |
Empty file.
25 changes: 25 additions & 0 deletions
25
...mo/src/app/pages/components/showcases/sequential-links/sequential-links.component.spec.ts
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 |
---|---|---|
@@ -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(); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
...ts/demo/src/app/pages/components/showcases/sequential-links/sequential-links.component.ts
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 |
---|---|---|
@@ -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; | ||
} | ||
} |
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