Skip to content

Commit b6ceebd

Browse files
committed
Rename the show event to open
It makes more sense, since `open` and `close` are antonyms just like `show` and `hide` are. However, `close` is used in the `<dialog>` element, so for developer experience it is better to use the first event-name pair.
1 parent 1f2645b commit b6ceebd

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changelog
2+
3+
## v1.0.0
4+
- Basic functionality implementation
5+
- API documentation
6+

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ HTML Custom Element for creating sheets
55

66
## Features
77

8-
- There is a draggable area to resize the sheet
8+
- Has a draggable area to resize the sheet
99
- The sheet can be closed using a button in the top right corner, using the `Esc` key, or by clicking outside the bottom sheet
1010
- This behavior is configurable. You can turn off the `Esc` or the click outside the sheet when you want.
11+
- API is similar to the `<dialog>` element's
1112

1213

1314
## API Documentation

documentation/API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ customElements.define("ui-sheet", SheetElement)
3333
```jsx
3434
const sheet = document.querySelector("...")
3535

36-
sheet.addEventListener("show", event => {
36+
sheet.addEventListener("open", event => {
3737
console.log("The sheet is now shown")
3838
})
3939

library/sheet.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { styleSheet } from "./styleSheet.js"
2727
* @example <caption>Execute certain actions when the sheet opens or closes</caption>
2828
* const sheet = document.querySelector("...")
2929
*
30-
* sheet.addEventListener("show", event => {
30+
* sheet.addEventListener("open", event => {
3131
* console.log("The sheet is now shown")
3232
* })
3333
*
@@ -149,7 +149,7 @@ export class SheetElement extends HTMLElement {
149149
*/
150150
showModal() {
151151
this.setAttribute("open", true)
152-
this.dispatchEvent(new CustomEvent("show"))
152+
this.dispatchEvent(new CustomEvent("open"))
153153
}
154154

155155
/**

test/main.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ openSheetButton.addEventListener("click", () => {
1515
sheet.showModal()
1616
})
1717

18+
sheet.addEventListener("open", () => {
19+
console.log("The sheet has been opened")
20+
})
21+
1822
sheet.addEventListener("close", () => {
1923
console.log("The sheet has been closed")
2024
})
2125

22-
sheet.addEventListener("show", () => {
23-
console.log("The sheet has been shown")
24-
})

0 commit comments

Comments
 (0)