Skip to content

Commit 63138b6

Browse files
authored
Merge pull request #2 from ivteplo/library: Make this a JavaScript library
2 parents 4256109 + 6cde1a3 commit 63138b6

File tree

17 files changed

+1823
-326
lines changed

17 files changed

+1823
-326
lines changed

.gitignore

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
build
2+
3+
# Logs
4+
logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
lerna-debug.log*
10+
.pnpm-debug.log*
11+
12+
# Diagnostic reports (https://nodejs.org/api/report.html)
13+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
14+
15+
# Runtime data
16+
pids
17+
*.pid
18+
*.seed
19+
*.pid.lock
20+
21+
# Directory for instrumented libs generated by jscoverage/JSCover
22+
lib-cov
23+
24+
# Coverage directory used by tools like istanbul
25+
coverage
26+
*.lcov
27+
28+
# nyc test coverage
29+
.nyc_output
30+
31+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
32+
.grunt
33+
34+
# Bower dependency directory (https://bower.io/)
35+
bower_components
36+
37+
# node-waf configuration
38+
.lock-wscript
39+
40+
# Compiled binary addons (https://nodejs.org/api/addons.html)
41+
build/Release
42+
43+
# Dependency directories
44+
node_modules/
45+
jspm_packages/
46+
47+
# Snowpack dependency directory (https://snowpack.dev/)
48+
web_modules/
49+
50+
# TypeScript cache
51+
*.tsbuildinfo
52+
53+
# Optional npm cache directory
54+
.npm
55+
56+
# Optional eslint cache
57+
.eslintcache
58+
59+
# Optional stylelint cache
60+
.stylelintcache
61+
62+
# Microbundle cache
63+
.rpt2_cache/
64+
.rts2_cache_cjs/
65+
.rts2_cache_es/
66+
.rts2_cache_umd/
67+
68+
# Optional REPL history
69+
.node_repl_history
70+
71+
# Output of 'npm pack'
72+
*.tgz
73+
74+
# Yarn Integrity file
75+
.yarn-integrity
76+
77+
# dotenv environment variable files
78+
.env
79+
.env.development.local
80+
.env.test.local
81+
.env.production.local
82+
.env.local
83+
84+
# parcel-bundler cache (https://parceljs.org/)
85+
.cache
86+
.parcel-cache
87+
88+
# Next.js build output
89+
.next
90+
out
91+
92+
# Nuxt.js build / generate output
93+
.nuxt
94+
dist
95+
96+
# Gatsby files
97+
.cache/
98+
# Comment in the public line in if your project uses Gatsby and not Next.js
99+
# https://nextjs.org/blog/next-9-1#public-directory-support
100+
# public
101+
102+
# vuepress build output
103+
.vuepress/dist
104+
105+
# vuepress v2.x temp and cache directory
106+
.temp
107+
.cache
108+
109+
# Docusaurus cache and generated files
110+
.docusaurus
111+
112+
# Serverless directories
113+
.serverless/
114+
115+
# FuseBox cache
116+
.fusebox/
117+
118+
# DynamoDB Local files
119+
.dynamodb/
120+
121+
# TernJS port file
122+
.tern-port
123+
124+
# Stores VSCode versions used for testing VSCode extensions
125+
.vscode-test
126+
127+
# yarn v2
128+
.yarn/cache
129+
.yarn/unplugged
130+
.yarn/build-state.yml
131+
.yarn/install-state.gz
132+
.pnp.*

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
# Bottom Sheet
2-
Bottom sheet, implemented in pure HTML, CSS, and JavaScript
1+
# HTML Sheet Element
2+
3+
HTML Custom Element for creating sheets
4+
35

46
## Features
7+
58
- There is a draggable area to resize the sheet
6-
- The sheet can be closed using a button in the top right corner or using the `Esc` key
9+
- The sheet can be closed using a button in the top right corner, using the `Esc` key, or by clicking outside the bottom sheet
10+
- This behavior is configurable. You can turn off the `Esc` or the click outside the sheet when you want.
11+
12+
13+
## API Documentation
14+
15+
You can find API documentation [here](./documentation/API.md)
16+

documentation/API.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# `SheetElement`
2+
3+
HTML Custom Element for creating sheets
4+
5+
<details open>
6+
<summary><b>Example:</b> Define the element in the registry and use it in your HTML</summary>
7+
8+
```jsx
9+
customElements.define("ui-sheet", SheetElement)
10+
11+
// in HTML:
12+
<ui-sheet>
13+
<p>Hello World!</p>
14+
</ui-sheet>
15+
```
16+
17+
</details>
18+
19+
<details open>
20+
<summary><b>Example:</b> Sheet open by default</summary>
21+
22+
```jsx
23+
<ui-sheet open>
24+
<p>Hello World!</p>
25+
</ui-sheet>
26+
```
27+
28+
</details>
29+
30+
<details open>
31+
<summary><b>Example:</b> Execute certain actions when the sheet opens or closes</summary>
32+
33+
```jsx
34+
const sheet = document.querySelector("...")
35+
36+
sheet.addEventListener("show", event => {
37+
console.log("The sheet is now shown")
38+
})
39+
40+
sheet.addEventListener("close", event => {
41+
console.log("The sheet is now closed")
42+
})
43+
```
44+
45+
</details>
46+
47+
<details open>
48+
<summary><b>Example:</b> Open the sheet programmatically</summary>
49+
50+
```jsx
51+
const sheet = document.querySelector("...")
52+
53+
sheet.showModal()
54+
// is the same as:
55+
sheet.show()
56+
```
57+
58+
</details>
59+
60+
61+
## `options`
62+
63+
Options for behavior customization
64+
65+
<details open>
66+
<summary><b>Example:</b> Make the sheet <i>not</i> close on background click</summary>
67+
68+
```jsx
69+
<ui-sheet ignore-background-click>
70+
...
71+
</ui-sheet>
72+
```
73+
74+
</details>
75+
76+
<details open>
77+
<summary><b>Example:</b> Make the sheet <i>not</i> close when pressing Escape</summary>
78+
79+
```jsx
80+
<ui-sheet ignore-escape-key>
81+
...
82+
</ui-sheet>
83+
```
84+
85+
</details>
86+
87+
88+
## `showModal(): void`
89+
90+
Open the sheet
91+
92+
93+
## `show(): void`
94+
95+
Open the sheet
96+
97+
98+
## `close(): void`
99+
100+
Collapse the sheet
101+
102+
103+
## `get open(): boolean`
104+
105+
Check if the sheet is open
106+
107+
108+
## `set open(value: boolean): boolean`
109+
110+
An alternative way to open or close the sheet
111+
112+
<details open>
113+
<summary><b>Example</b></summary>
114+
115+
```jsx
116+
sheet.open = true // the same as executing sheet.showModal()
117+
sheet.open = false // the same as executing sheet.close()
118+
```
119+
120+
</details>

0 commit comments

Comments
 (0)