-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(sequential-links): add sequential links component #18
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
|
||
alecarn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<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); | ||
alecarn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Est-ce qu'on pourrait utiliser le host comme container, au lieu d'ajouter un div?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pas certain de comprendre ce que tu veux dire? Ça serait
<sdg-sequential-links>
qui contiendrait direct les deux et faire le scss de cet élément dans la démo?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On ajoute parfois un div intermédiaire entre le host et le contenu de la composante pour ajouté du style ou des classes. Par exemple, ton
<div class="container">
ce situe entre le deux, il est utilisé seulement pour ajouté une classe mais ce style ou cette classe pourrait se retrouver sur le host de la composante.On peut styler le host de la composante via le fichier SCSS et la balise
:host {}
ou
Ajouter un HostBinding
@HostBinding('class.container') containerClass = true;
qui permet d'ajouter la classe container<sdg-sequential-links class="container">