Skip to content

Commit 9c5c99f

Browse files
committed
README updates
1 parent 569c592 commit 9c5c99f

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

elements/pfe-modal/README.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# PatternFly Modal Element
1+
# PFElements Modal Element
22

33
## Overview
44

55
`pfe-modal` is a self-contained modal window that is hidden on page load and (when activated) restricts the user from interacting with content in the main window.
66

77
## Usage
8+
9+
### With a trigger
810
```html
911
<pfe-modal>
1012
<button slot="pfe-modal--trigger">Open modal</button>
@@ -16,6 +18,16 @@
1618
</pfe-modal>
1719
```
1820

21+
### Without a trigger
22+
```html
23+
<pfe-modal>
24+
<h2 slot="pfe-modal--header">Modal with a header</h2>
25+
<p>Lorem ipsum dolor sit amet, <a href="#foo">consectetur adipisicing</a> elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
26+
<pfe-cta>
27+
<a href="#bar">Learn more</a>
28+
</pfe-cta>
29+
</pfe-modal>
30+
```
1931
## Slots
2032

2133
### Trigger
@@ -31,14 +43,32 @@ The default slot can contain any type of content. When the header is not present
3143

3244
### open
3345

46+
Manually opens a modal. Return the modal that has been opened.
47+
48+
```
49+
document.querySelector("pfe-modal").open();
50+
```
51+
3452
### close
3553

54+
Manually closes a modal. Returns the modal that has been closed.
55+
56+
```
57+
document.querySelector("pfe-modal").close();
58+
```
59+
3660
### toggle
3761

62+
Manually toggles a modal. Returns the modal that has been toggled.
63+
64+
```
65+
document.querySelector("pfe-modal").toggle();
66+
```
67+
3868
## Events
3969

4070
### pfe-modal:open
41-
Fires when a user clicks on the trigger. open can be accessed from outside the web component by getting the modal that you want to fire and passing in the firing event: `document.querySelector("pfe-modal#custom-id").open(event).`
71+
Fires when a user clicks on the trigger or manually opens a modal.
4272

4373
```
4474
detail: {
@@ -47,7 +77,7 @@ detail: {
4777
```
4878

4979
### pfe-modal:close
50-
Fires when either a user clicks on either the close button or the overlay. close can be accessed from outside the web component by getting the modal that you want to fire and passing in the firing event: `document.querySelector("pfe-modal#custom-id").close(event).`
80+
Fires when either a user clicks on either the close button or the overlay or manually closes a modal.
5181

5282
```
5383
detail: {
@@ -71,7 +101,7 @@ From the PFElements root directory, run:
71101

72102
## Code style
73103

74-
Collapsible (and all PFElements) use [Prettier][prettier] to auto-format JS and JSON. The style rules get applied when you commit a change. If you choose to, you can [integrate your editor][prettier-ed] with Prettier to have the style rules applied on every save.
104+
Modal (and all PFElements) use [Prettier][prettier] to auto-format JS and JSON. The style rules get applied when you commit a change. If you choose to, you can [integrate your editor][prettier-ed] with Prettier to have the style rules applied on every save.
75105

76106
[prettier]: https://github.com/prettier/prettier/
77107
[prettier-ed]: https://github.com/prettier/prettier/#editor-integration

0 commit comments

Comments
 (0)