-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add modal sample using already defined component
- Loading branch information
1 parent
a545430
commit 000c2e5
Showing
39 changed files
with
342 additions
and
204 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
44 changes: 44 additions & 0 deletions
44
angular/demo/src/app/samples/alert/alert-icon.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,44 @@ | ||
import biCheckCircleFill from '!raw-loader!bootstrap-icons/icons/check-circle-fill.svg'; | ||
import biDashCircleFill from '!raw-loader!bootstrap-icons/icons/dash-circle-fill.svg'; | ||
import biExclamationTriangleFill from '!raw-loader!bootstrap-icons/icons/exclamation-triangle-fill.svg'; | ||
import biInfoCircleFill from '!raw-loader!bootstrap-icons/icons/info-circle-fill.svg'; | ||
import biLightbulb from '!raw-loader!bootstrap-icons/icons/lightbulb.svg'; | ||
import type {AlertWidget} from '@agnos-ui/angular'; | ||
import {SlotComponent, SlotDirective} from '@agnos-ui/angular'; | ||
import {NgIf} from '@angular/common'; | ||
import {Component, inject} from '@angular/core'; | ||
import {DomSanitizer} from '@angular/platform-browser'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [NgIf, SlotDirective], | ||
providers: [SlotDirective], | ||
selector: 'app-icon-structure', | ||
host: { | ||
style: 'display: contents;', | ||
}, | ||
template: ` | ||
<span class="d-flex align-items-center me-2" [innerHTML]="sanitizer.bypassSecurityTrustHtml(typeIcon[state.type])"></span> | ||
<div class="d-flex w-100 alert-body"> | ||
<ng-template [auSlot]="state.slotDefault" [auSlotProps]="{widget, state}"></ng-template> | ||
<button | ||
*ngIf="state.dismissible" | ||
type="button" | ||
class="btn-close ms-auto" | ||
(click)="widget.api.close()" | ||
[attr.aria-label]="state.ariaCloseButtonLabel" | ||
></button> | ||
</div> | ||
`, | ||
}) | ||
export default class AlertIconComponent extends SlotComponent<AlertWidget> { | ||
sanitizer = inject(DomSanitizer); | ||
|
||
typeIcon: Record<string, string> = { | ||
success: biCheckCircleFill, | ||
info: biInfoCircleFill, | ||
warning: biExclamationTriangleFill, | ||
danger: biDashCircleFill, | ||
light: biLightbulb, | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,31 +1,24 @@ | ||
import {AgnosUIAngularModule, provideWidgetsConfig} from '@agnos-ui/angular'; | ||
import {NgFor} from '@angular/common'; | ||
import {Component} from '@angular/core'; | ||
import {FormsModule} from '@angular/forms'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [AgnosUIAngularModule, NgFor, FormsModule], | ||
imports: [AgnosUIAngularModule], | ||
providers: [ | ||
provideWidgetsConfig((config) => { | ||
config.alert = {...config.alert, dismissible: false}; | ||
return config; | ||
}), | ||
], | ||
template: ` <au-component auAlert auType="primary">Simple primary alert</au-component> | ||
template: ` | ||
<au-component auAlert auType="primary">Simple primary alert</au-component> | ||
<au-component auAlert auType="secondary">Simple secondary alert</au-component> | ||
<au-component auAlert auType="success">Simple success alert</au-component> | ||
<au-component auAlert auType="danger">Simple danger alert</au-component> | ||
<au-component auAlert auType="warning">Simple warning alert</au-component> | ||
<au-component auAlert auType="info">Simple info alert</au-component> | ||
<au-component auAlert auType="light">Simple light alert</au-component> | ||
<au-component auAlert auType="dark">Simple dark alert</au-component>`, | ||
<au-component auAlert auType="dark">Simple dark alert</au-component> | ||
`, | ||
}) | ||
export default class GenericAlertComponent {} |
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,17 @@ | ||
import {AgnosUIAngularModule, ModalService} from '@agnos-ui/angular'; | ||
import {Component, inject} from '@angular/core'; | ||
import type {ModalData} from './custom-content.component'; | ||
import CustomContentComponent from './custom-content.component'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [AgnosUIAngularModule], | ||
template: ` <button class="btn btn-primary" type="button" (click)="openModal()">Launch demo modal</button> `, | ||
}) | ||
export default class DemoContentModalComponent { | ||
readonly modalService = inject(ModalService); | ||
|
||
openModal() { | ||
this.modalService.open<ModalData>({slotTitle: 'Hi there!', slotDefault: CustomContentComponent, contentData: {name: 'World'}}); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
angular/demo/src/app/samples/modal/custom-content.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,14 @@ | ||
import type {ModalWidget} from '@agnos-ui/angular'; | ||
import {SlotComponent} from '@agnos-ui/angular'; | ||
import {Component} from '@angular/core'; | ||
|
||
export type ModalData = {name: string}; | ||
|
||
@Component({ | ||
standalone: true, | ||
template: ` | ||
<p>Hello, {{ state.contentData.name }}!</p> | ||
<button type="button" class="btn btn-outline-primary" (click)="widget.api.close(true)">Close</button> | ||
`, | ||
}) | ||
export default class CustomContentComponent extends SlotComponent<ModalWidget<ModalData>> {} |
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
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
Oops, something went wrong.