-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the loading and error handling on the glossary
- Loading branch information
Showing
11 changed files
with
158 additions
and
33 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
8 changes: 4 additions & 4 deletions
8
...ts/details-error/details-error.stories.ts → src/app/components/error/error.stories.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
2 changes: 1 addition & 1 deletion
2
src/app/pages/definition/components/details-loading/details-loading.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
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
29 changes: 29 additions & 0 deletions
29
src/app/pages/glossary/components/glossary-list/glossary-list.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,29 @@ | ||
import { KeyValuePipe, NgFor } from '@angular/common' | ||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core' | ||
import { type FigureOfSpeechPreview } from 'src/app/models' | ||
import { GlossarySectionComponent } from '../glossary-section/glossary-section.component' | ||
|
||
@Component({ | ||
selector: 'app-glossary-list', | ||
standalone: true, | ||
imports: [NgFor, KeyValuePipe, GlossarySectionComponent], | ||
template: ` | ||
<h1 | ||
class="mb-3 text-2xl font-extrabold tracking-tight text-sky-500 sm:text-center md:text-4xl" | ||
> | ||
Glossaire | ||
</h1> | ||
<div class="flex flex-col gap-3 sm:mx-auto sm:w-2/3 md:w-1/3 md:gap-6"> | ||
<app-glossary-section | ||
*ngFor="let section of glossary | keyvalue" | ||
[key]="section.key" | ||
[entries]="section.value" | ||
/> | ||
</div> | ||
`, | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class GlossaryListComponent { | ||
@Input() glossary = new Map<string, FigureOfSpeechPreview[]>() | ||
} |
41 changes: 41 additions & 0 deletions
41
src/app/pages/glossary/components/glossary-list/glossary-list.stories.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,41 @@ | ||
import { RouterTestingModule } from '@angular/router/testing' | ||
import { moduleMetadata, type Meta, type Story } from '@storybook/angular' | ||
import { type FigureOfSpeechPreview } from 'src/app/models' | ||
import { GlossaryEntryComponent } from '../glossary-entry/glossary-entry-component' | ||
import { GlossarySectionComponent } from '../glossary-section/glossary-section.component' | ||
import { GlossaryListComponent } from './glossary-list.component' | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
export default { | ||
title: 'Pages/Glossary/List', | ||
component: GlossaryListComponent, | ||
decorators: [ | ||
moduleMetadata({ | ||
imports: [RouterTestingModule, GlossarySectionComponent, GlossaryEntryComponent] | ||
}) | ||
] | ||
} as Meta | ||
|
||
const Template: Story<GlossaryListComponent> = ( | ||
args: GlossaryListComponent | ||
) => ({ | ||
props: args | ||
}) | ||
|
||
const previews: FigureOfSpeechPreview[] = [ | ||
{ | ||
name: 'Alitération', | ||
preview: | ||
"L'alitération est la répétition d'une ou de plusieurs consonnes ou plus généralement d'un même son c..." | ||
}, | ||
{ | ||
name: 'Antanaclase', | ||
preview: | ||
"On parle d'antanaclase lorsque l'on emploie deux fois un même mot mais avec un sens différent: on pa..." | ||
} | ||
] | ||
|
||
export const Default = Template.bind({}) | ||
Default.args = { | ||
glossary: new Map<string, FigureOfSpeechPreview[]>([['A', [...previews]]]) | ||
} |
27 changes: 27 additions & 0 deletions
27
src/app/pages/glossary/components/glossary-loading/glossary-loading.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,27 @@ | ||
import { NgFor } from '@angular/common' | ||
import { ChangeDetectionStrategy, Component } from '@angular/core' | ||
|
||
@Component({ | ||
selector: 'app-glossary-loading', | ||
standalone: true, | ||
imports: [NgFor], | ||
template: ` | ||
<div class="animate-pulse space-y-4 md:mx-auto md:w-1/3"> | ||
<!-- Simulate the title --> | ||
<div class="h-6 w-32 bg-sky-500/75 rounded md:mx-auto md:h-8 md:w-48"></div> | ||
<!-- Simulate a section --> | ||
<div *ngFor="let _ of [0, 1, 2, 3, 4]" class="space-y-3"> | ||
<div class="h-6 w-5 bg-sky-500/75 rounded"></div> | ||
<!-- Simulate an entry --> | ||
<div *ngFor="let _ of [0, 1]" class="space-y-2"> | ||
<div class="h-5 w-24 bg-white/75 rounded"></div> | ||
<div class="h-4 w-full bg-gray-500/75 rounded"></div> | ||
</div> | ||
</div> | ||
</div> | ||
`, | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class GlossaryLoadingComponent {} |
16 changes: 16 additions & 0 deletions
16
src/app/pages/glossary/components/glossary-loading/glossary-loading.stories.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,16 @@ | ||
import { type Meta, type Story } from '@storybook/angular' | ||
import { GlossaryLoadingComponent } from './glossary-loading.component' | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
export default { | ||
title: 'Pages/Glossary/Loading', | ||
component: GlossaryLoadingComponent | ||
} as Meta | ||
|
||
const Template: Story<GlossaryLoadingComponent> = ( | ||
args: GlossaryLoadingComponent | ||
) => ({ | ||
props: args | ||
}) | ||
|
||
export const Default = Template.bind({}) |
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
f574082
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.
Successfully deployed to the following URLs:
locutionis – ./
locutionis-pbouillon.vercel.app
locutionis.vercel.app