-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Animate the load-in of notices to make the layout shift less jarring. Closes #1789 It also updates the code to the latest code styles: - Stories for notice and alerts were added. - NgFor / NgIf were replaced. - The service was moved from the general services directory to a context base directory. - Notices in the NoticeWrapperService is now a BehaviourSubject. - Custom Types and Functions were replaced with the OpenAPI schema. Co-authored-by: MoritzWeber0 <[email protected]>
- Loading branch information
1 parent
f43efb9
commit 6c20a73
Showing
10 changed files
with
234 additions
and
163 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { Injectable } from '@angular/core'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { NoticeResponse, NoticesService } from 'src/app/openapi'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class NoticeWrapperService { | ||
private _notices = new BehaviorSubject<NoticeResponse[] | undefined>( | ||
undefined, | ||
); | ||
public readonly notices$ = this._notices.asObservable(); | ||
|
||
constructor(private noticesService: NoticesService) { | ||
this.refreshNotices(); | ||
} | ||
|
||
refreshNotices(): void { | ||
this._notices.next(undefined); | ||
this.noticesService.getNotices().subscribe((res) => { | ||
this._notices.next(res); | ||
}); | ||
} | ||
} |
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 @@ | ||
/* | ||
* SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { Meta, moduleMetadata, StoryObj } from '@storybook/angular'; | ||
import { NoticeWrapperService } from 'src/app/general/notice/notice.service'; | ||
import { NoticeLevel } from 'src/app/openapi'; | ||
import { mockNotice, MockNoticeWrapperService } from 'src/storybook/notices'; | ||
import { NoticeComponent } from './notice.component'; | ||
|
||
const meta: Meta<NoticeComponent> = { | ||
title: 'General Components / Notices', | ||
component: NoticeComponent, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<NoticeComponent>; | ||
|
||
export const AllLevels: Story = { | ||
args: {}, | ||
decorators: [ | ||
moduleMetadata({ | ||
providers: [ | ||
{ | ||
provide: NoticeWrapperService, | ||
useFactory: () => | ||
new MockNoticeWrapperService( | ||
Object.values(NoticeLevel).map((level) => ({ | ||
...mockNotice, | ||
title: 'This is an example notice with level ' + level, | ||
level, | ||
})), | ||
), | ||
}, | ||
], | ||
}), | ||
], | ||
}; |
This file was deleted.
Oops, something went wrong.
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.