Skip to content

Commit f65aaf2

Browse files
authored
docs(modal): add open programatically (#120)
## PR Checklist Please check if your PR fulfills the following requirements: <!--- [ ] Tests for the changes have been added (for bug fixes/features)--> - [x] Docs have been added/updated (for bug fixes/features) ## PR Type What kind of change does this PR introduce? <!-- Please check the one that applies to this PR using "x". --> - [ ] Bugfix - [ ] Feature - [ ] Code style update (formatting, local variables) - [ ] Refactoring (no functional changes, no API changes) - [ ] Build related changes - [ ] CI-related changes - [x] Documentation content changes - [ ] Other... Please describe: ## Issue Number <!-- Bugs and features must be linked to an issue. --> Issue Number: N/A ## Does this PR introduce a breaking change? <!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. --> - [ ] Yes - [x] No ## Other information @coderabbitai summary
2 parents 4c3050d + 88e2575 commit f65aaf2

4 files changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<button
2+
flowbiteButton
3+
(click)="onClick()">
4+
Trigger modal
5+
</button>
6+
7+
<ng-template
8+
#dialog
9+
let-close="close">
10+
<div flowbiteModalOverlay>
11+
<div flowbiteModal>
12+
<h3 flowbiteModalHeader>Terms of Service</h3>
13+
<div flowbiteModalContent>
14+
<p class="text-base leading-relaxed text-gray-500 dark:text-gray-400">
15+
With less than a month to go before the European Union enacts new consumer privacy laws
16+
for its citizens, companies around the world are updating their terms of service
17+
agreements to comply.
18+
</p>
19+
<p class="text-base leading-relaxed text-gray-500 dark:text-gray-400">
20+
The European Union’s General Data Protection Regulation (G.D.P.R.) goes into effect on May
21+
25 and is meant to ensure a common set of data rights in the European Union. It requires
22+
organizations to notify users as soon as possible of high-risk data breaches that could
23+
personally affect them.
24+
</p>
25+
</div>
26+
<div flowbiteModalFooter>
27+
<button
28+
flowbiteButton
29+
(click)="close()"
30+
color="info">
31+
I accept
32+
</button>
33+
<button
34+
flowbiteButton
35+
(click)="close()"
36+
color="default"
37+
outline>
38+
Decline
39+
</button>
40+
</div>
41+
</div>
42+
</div>
43+
</ng-template>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Button } from 'flowbite-angular/button';
2+
import {
3+
Modal,
4+
ModalContent,
5+
ModalFooter,
6+
ModalHeader,
7+
ModalOverlay,
8+
} from 'flowbite-angular/modal';
9+
10+
import { Component, inject, TemplateRef, viewChild } from '@angular/core';
11+
import { NgpDialogManager } from 'ng-primitives/dialog';
12+
13+
@Component({
14+
imports: [Button, Modal, ModalContent, ModalFooter, ModalHeader, ModalOverlay],
15+
templateUrl: './_open-programatically.component.html',
16+
host: {
17+
class: 'flex flex-wrap flex-row gap-3 p-6',
18+
},
19+
})
20+
export class FlowbiteOpenprogramaticallyComponent {
21+
public readonly ngpDialogManager = inject(NgpDialogManager);
22+
public readonly modal = viewChild('dialog', { read: TemplateRef<unknown> });
23+
24+
onClick(): void {
25+
const modal = this.modal();
26+
27+
if (modal !== undefined) {
28+
this.ngpDialogManager.open(modal);
29+
}
30+
}
31+
}

apps/docs/docs/components/modal/index.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@ keyword: ModalPage
1313
```angular-ts file="./_default.component.ts" group="default" name="typescript"
1414
1515
```
16+
17+
## Open programatically
18+
19+
{{ NgDocActions.demo('flowbiteOpenprogramaticallyComponent', {container: false}) }}
20+
21+
```angular-html file="./_open-programatically.component.html" group="openProgramatically" name="html"
22+
23+
```
24+
25+
```angular-ts file="./_open-programatically.component.ts" group="openProgramatically" name="typescript"
26+
27+
```

apps/docs/docs/components/modal/ng-doc.page.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ComponentCategory from '../ng-doc.category';
22
import { FlowbiteDefaultComponent } from './_default.component';
3+
import { FlowbiteOpenprogramaticallyComponent } from './_open-programatically.component';
34

45
import type { NgDocPage } from '@ng-doc/core';
56

@@ -12,6 +13,7 @@ const Modal: NgDocPage = {
1213
category: ComponentCategory,
1314
demos: {
1415
flowbiteDefaultComponent: FlowbiteDefaultComponent,
16+
flowbiteOpenprogramaticallyComponent: FlowbiteOpenprogramaticallyComponent,
1517
},
1618
};
1719

0 commit comments

Comments
 (0)