-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(dialog/sheet): add close dialog/sheet example (#541)
* docs(dialog/sheet): add close dialog example (#520/#509) * docs(dialog/sheet): add close dialog/sheet example
- Loading branch information
Showing
4 changed files
with
284 additions
and
0 deletions.
There are no files selected for viewing
131 changes: 131 additions & 0 deletions
131
apps/app/src/app/pages/(components)/components/(dialog)/dialog-close.preview.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,131 @@ | ||
import { Component, viewChild } from '@angular/core'; | ||
import { | ||
BrnDialogCloseDirective, | ||
BrnDialogComponent, | ||
BrnDialogContentDirective, | ||
BrnDialogTriggerDirective, | ||
} from '@spartan-ng/brain/dialog'; | ||
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm'; | ||
import { | ||
HlmDialogComponent, | ||
HlmDialogContentComponent, | ||
HlmDialogHeaderComponent, | ||
HlmDialogTitleDirective, | ||
} from '@spartan-ng/ui-dialog-helm'; | ||
import { HlmLabelDirective } from '@spartan-ng/ui-label-helm'; | ||
|
||
@Component({ | ||
selector: 'spartan-dialog-close-preview', | ||
standalone: true, | ||
imports: [ | ||
BrnDialogTriggerDirective, | ||
BrnDialogContentDirective, | ||
BrnDialogCloseDirective, | ||
|
||
HlmDialogComponent, | ||
HlmDialogContentComponent, | ||
HlmDialogHeaderComponent, | ||
HlmDialogTitleDirective, | ||
|
||
HlmLabelDirective, | ||
HlmButtonDirective, | ||
], | ||
template: ` | ||
<hlm-dialog #dialogRef> | ||
<button id="edit-profile" brnDialogTrigger hlmBtn>Open</button> | ||
<hlm-dialog-content class="sm:max-w-[425px]" *brnDialogContent="let ctx"> | ||
<hlm-dialog-header> | ||
<h3 hlmDialogTitle>Dialog</h3> | ||
</hlm-dialog-header> | ||
<div class="grid gap-4 py-4"> | ||
<div class="flex items-center justify-between gap-4"> | ||
<label hlmLabel>Close dialog by directive</label> | ||
<button hlmBtn brnDialogClose>Close</button> | ||
</div> | ||
<div class="flex items-center justify-between gap-4"> | ||
<label hlmLabel>Close dialog by reference</label> | ||
<button hlmBtn (click)="dialogRef.close({})">Close</button> | ||
</div> | ||
<div class="flex items-center justify-between gap-4"> | ||
<label hlmLabel>Close dialog by viewchild reference</label> | ||
<button hlmBtn (click)="closeDialog()">Close</button> | ||
</div> | ||
</div> | ||
</hlm-dialog-content> | ||
</hlm-dialog> | ||
`, | ||
}) | ||
export class DialogClosePreviewComponent { | ||
public viewchildDialogRef = viewChild(BrnDialogComponent); | ||
|
||
closeDialog() { | ||
this.viewchildDialogRef()?.close({}); | ||
} | ||
} | ||
|
||
export const defaultCloseCode = ` | ||
import { Component, viewChild } from '@angular/core'; | ||
import { | ||
BrnDialogCloseDirective, | ||
BrnDialogComponent, | ||
BrnDialogContentDirective, | ||
BrnDialogTriggerDirective, | ||
} from '@spartan-ng/brain/dialog'; | ||
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm'; | ||
import { | ||
HlmDialogComponent, | ||
HlmDialogContentComponent, | ||
HlmDialogHeaderComponent, | ||
HlmDialogTitleDirective, | ||
} from '@spartan-ng/ui-dialog-helm'; | ||
import { HlmLabelDirective } from '@spartan-ng/ui-label-helm'; | ||
@Component({ | ||
selector: 'spartan-dialog-close-preview', | ||
standalone: true, | ||
imports: [ | ||
BrnDialogTriggerDirective, | ||
BrnDialogContentDirective, | ||
BrnDialogCloseDirective, | ||
HlmDialogComponent, | ||
HlmDialogContentComponent, | ||
HlmDialogHeaderComponent, | ||
HlmDialogTitleDirective, | ||
HlmLabelDirective, | ||
HlmButtonDirective, | ||
], | ||
template: \` | ||
<hlm-dialog #dialogRef> | ||
<button id="edit-profile" brnDialogTrigger hlmBtn>Open</button> | ||
<hlm-dialog-content class="sm:max-w-[425px]" *brnDialogContent="let ctx"> | ||
<hlm-dialog-header> | ||
<h3 hlmDialogTitle>Dialog</h3> | ||
</hlm-dialog-header> | ||
<div class="grid gap-4 py-4"> | ||
<div class="flex items-center justify-between gap-4"> | ||
<label hlmLabel>Close dialog by directive</label> | ||
<button hlmBtn brnDialogClose>Close</button> | ||
</div> | ||
<div class="flex items-center justify-between gap-4"> | ||
<label hlmLabel>Close dialog by reference</label> | ||
<button hlmBtn (click)="dialogRef.close({})">Close</button> | ||
</div> | ||
<div class="flex items-center justify-between gap-4"> | ||
<label hlmLabel>Close dialog by viewchild reference</label> | ||
<button hlmBtn (click)="closeDialog()">Close</button> | ||
</div> | ||
</div> | ||
</hlm-dialog-content> | ||
</hlm-dialog> | ||
\`, | ||
}) | ||
export class DialogClosePreviewComponent { | ||
public viewchildDialogRef = viewChild(BrnDialogComponent); | ||
closeDialog() { | ||
this.viewchildDialogRef()?.close({}); | ||
} | ||
} | ||
`; |
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
127 changes: 127 additions & 0 deletions
127
apps/app/src/app/pages/(components)/components/(sheet)/sheet-close.preview.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,127 @@ | ||
import { Component, viewChild } from '@angular/core'; | ||
import { provideIcons } from '@ng-icons/core'; | ||
import { lucideCross } from '@ng-icons/lucide'; | ||
import { | ||
BrnSheetCloseDirective, | ||
BrnSheetComponent, | ||
BrnSheetContentDirective, | ||
BrnSheetTriggerDirective, | ||
} from '@spartan-ng/brain/sheet'; | ||
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm'; | ||
import { HlmLabelDirective } from '@spartan-ng/ui-label-helm'; | ||
import { | ||
HlmSheetComponent, | ||
HlmSheetContentComponent, | ||
HlmSheetHeaderComponent, | ||
HlmSheetTitleDirective, | ||
} from '@spartan-ng/ui-sheet-helm'; | ||
|
||
@Component({ | ||
selector: 'spartan-sheet-close-preview', | ||
standalone: true, | ||
imports: [ | ||
BrnSheetTriggerDirective, | ||
BrnSheetContentDirective, | ||
BrnSheetCloseDirective, | ||
HlmSheetComponent, | ||
HlmSheetContentComponent, | ||
HlmSheetHeaderComponent, | ||
HlmSheetTitleDirective, | ||
HlmButtonDirective, | ||
HlmLabelDirective, | ||
], | ||
providers: [provideIcons({ lucideCross })], | ||
template: ` | ||
<hlm-sheet #sheetRef side="right"> | ||
<button id="edit-profile" variant="outline" brnSheetTrigger hlmBtn>Open</button> | ||
<hlm-sheet-content *brnSheetContent="let ctx"> | ||
<hlm-sheet-header> | ||
<h3 hlmSheetTitle>Sheet</h3> | ||
</hlm-sheet-header> | ||
<div class="grid gap-4 py-4"> | ||
<div class="flex items-center justify-between gap-4"> | ||
<label hlmLabel>Close sheet by directive</label> | ||
<button hlmBtn brnSheetClose>Close</button> | ||
</div> | ||
<div class="flex items-center justify-between gap-4"> | ||
<label hlmLabel>Close sheet by reference</label> | ||
<button hlmBtn (click)="sheetRef.close({})">Close</button> | ||
</div> | ||
<div class="flex items-center justify-between gap-4"> | ||
<label hlmLabel>Close sheet by viewchild reference</label> | ||
<button hlmBtn (click)="closeSheet()">Close</button> | ||
</div> | ||
</div> | ||
</hlm-sheet-content> | ||
</hlm-sheet> | ||
`, | ||
}) | ||
export class SheetClosePreviewComponent { | ||
public viewchildSheetRef = viewChild(BrnSheetComponent); | ||
|
||
closeSheet() { | ||
this.viewchildSheetRef()?.close({}); | ||
} | ||
} | ||
|
||
export const defaultCloseCode = ` | ||
import { Component, viewChild } from '@angular/core'; | ||
import { provideIcons } from '@ng-icons/core'; | ||
import { lucideCross } from '@ng-icons/lucide'; | ||
import { BrnSheetCloseDirective, BrnSheetComponent, BrnSheetContentDirective, BrnSheetTriggerDirective } from '@spartan-ng/brain/sheet'; | ||
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm'; | ||
import { HlmLabelDirective } from '@spartan-ng/ui-label-helm'; | ||
import { | ||
HlmSheetComponent, | ||
HlmSheetContentComponent, | ||
HlmSheetHeaderComponent, | ||
HlmSheetTitleDirective, | ||
} from '@spartan-ng/ui-sheet-helm'; | ||
@Component({ | ||
selector: 'spartan-sheet-close-preview', | ||
standalone: true, | ||
imports: [ | ||
BrnSheetTriggerDirective, | ||
BrnSheetContentDirective, | ||
BrnSheetCloseDirective, | ||
HlmSheetComponent, | ||
HlmSheetContentComponent, | ||
HlmSheetHeaderComponent, | ||
HlmSheetTitleDirective, | ||
HlmButtonDirective, | ||
HlmLabelDirective | ||
], | ||
providers: [provideIcons({ lucideCross })], | ||
template: \` | ||
<hlm-sheet #sheetRef side="right"> | ||
<button id="edit-profile" variant="outline" brnSheetTrigger hlmBtn>Open</button> | ||
<hlm-sheet-content *brnSheetContent="let ctx"> | ||
<hlm-sheet-header> | ||
<h3 hlmSheetTitle>Sheet</h3> | ||
</hlm-sheet-header> | ||
<div class="grid gap-4 py-4"> | ||
<div class="flex items-center justify-between gap-4"> | ||
<label hlmLabel>Close sheet by directive</label> | ||
<button hlmBtn brnSheetClose>Close</button> | ||
</div> | ||
<div class="flex items-center justify-between gap-4"> | ||
<label hlmLabel>Close sheet by reference</label> | ||
<button hlmBtn (click)="sheetRef.close({})">Close</button> | ||
</div> | ||
<div class="flex items-center justify-between gap-4"> | ||
<label hlmLabel>Close sheet by viewchild reference</label> | ||
<button hlmBtn (click)="closeSheet()">Close</button> | ||
</div> | ||
</div> | ||
</hlm-sheet-content> | ||
</hlm-sheet> | ||
\`, | ||
}) | ||
export class SheetClosePreviewComponent { | ||
public viewchildSheetRef = viewChild(BrnSheetComponent); | ||
closeSheet() { | ||
this.viewchildSheetRef()?.close({}); | ||
} | ||
}`; |
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