Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1f5d596
Create a `BottomSheet` class
ivteplo Jan 13, 2023
291c709
Set up Vite for building and testing
ivteplo Apr 20, 2023
02bda79
Work in process: add basic functionality, use CSS modules
ivteplo Sep 21, 2023
a29e81d
Improve DOM generation code by using JSX
ivteplo Sep 21, 2023
c1b4785
Update utilities.css version in the example code
ivteplo Sep 21, 2023
3cc7c3c
Force the developer to specify an identifier for the sheet
ivteplo Sep 21, 2023
bae85ba
Support `reference` in the `createElement` attribute to remove crypti…
ivteplo Sep 21, 2023
70bfedd
Update styles. Don't use CSS modules
ivteplo Oct 1, 2023
c5cdf87
Rename CSS classes
ivteplo Oct 1, 2023
05fe4fd
Add a method to unmount the bottom sheet component / restore initial …
ivteplo Oct 1, 2023
8d4aa1c
Fix test (`aria-controls` wasn't specified in HTML). Improve API
ivteplo Nov 24, 2023
49c8409
Merge branch 'main' of https://github.com/ivteplo/bottom-sheet into l…
ivteplo Nov 24, 2023
2b73b8c
Add some documentation
ivteplo Nov 24, 2023
f939bf8
Improve example inside README.md
ivteplo Nov 24, 2023
0cf102e
Use null-coalescing operator when calling reference setter in `create…
ivteplo Dec 13, 2023
6c42522
Fix wrong library path in the test page
ivteplo Dec 13, 2023
7c2dc3c
Trigger `hide` and `show` events on the sheet
ivteplo Dec 15, 2023
4f0e9ae
Document the new code. Improve names and code style
ivteplo Dec 15, 2023
a8e3405
Update documentation. Don't minify the build output
ivteplo Dec 15, 2023
3abf225
Switch to HTML Custom Elements API. Stop changing height
ivteplo Feb 9, 2024
651c84e
Adapt styles for desktop and tablets
ivteplo Feb 9, 2024
be2e89b
Dispatch custom events
ivteplo Feb 9, 2024
3dc4d59
Add more comments
ivteplo Feb 9, 2024
0d3c6e0
Update folder structure
ivteplo Feb 9, 2024
4f89947
Make the library user define the element in the registry
ivteplo Feb 9, 2024
51faa82
Fix the sheet not closing on backdrop click
ivteplo Feb 9, 2024
91b7dc3
Fix the error that prevented the dragging process
ivteplo Mar 16, 2024
7f31673
Generate simple API documentation
ivteplo Mar 16, 2024
7354771
Improve documentation generation
ivteplo Mar 17, 2024
8c948d9
Bind options to HTML attributes
ivteplo Mar 17, 2024
6cde1a3
Update documentation
ivteplo Mar 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
build

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Bottom Sheet
Bottom sheet, implemented in pure HTML, CSS, and JavaScript
# HTML Sheet Element

HTML Custom Element for creating sheets


## Features

- There is a draggable area to resize the sheet
- The sheet can be closed using a button in the top right corner or using the `Esc` key
- The sheet can be closed using a button in the top right corner, using the `Esc` key, or by clicking outside the bottom sheet
- This behavior is configurable. You can turn off the `Esc` or the click outside the sheet when you want.


## API Documentation

You can find API documentation [here](./documentation/API.md)

120 changes: 120 additions & 0 deletions documentation/API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# `SheetElement`

HTML Custom Element for creating sheets

<details open>
<summary><b>Example:</b> Define the element in the registry and use it in your HTML</summary>

```jsx
customElements.define("ui-sheet", SheetElement)

// in HTML:
<ui-sheet>
<p>Hello World!</p>
</ui-sheet>
```

</details>

<details open>
<summary><b>Example:</b> Sheet open by default</summary>

```jsx
<ui-sheet open>
<p>Hello World!</p>
</ui-sheet>
```

</details>

<details open>
<summary><b>Example:</b> Execute certain actions when the sheet opens or closes</summary>

```jsx
const sheet = document.querySelector("...")

sheet.addEventListener("show", event => {
console.log("The sheet is now shown")
})

sheet.addEventListener("close", event => {
console.log("The sheet is now closed")
})
```

</details>

<details open>
<summary><b>Example:</b> Open the sheet programmatically</summary>

```jsx
const sheet = document.querySelector("...")

sheet.showModal()
// is the same as:
sheet.show()
```

</details>


## `options`

Options for behavior customization

<details open>
<summary><b>Example:</b> Make the sheet <i>not</i> close on background click</summary>

```jsx
<ui-sheet ignore-background-click>
...
</ui-sheet>
```

</details>

<details open>
<summary><b>Example:</b> Make the sheet <i>not</i> close when pressing Escape</summary>

```jsx
<ui-sheet ignore-escape-key>
...
</ui-sheet>
```

</details>


## `showModal(): void`

Open the sheet


## `show(): void`

Open the sheet


## `close(): void`

Collapse the sheet


## `get open(): boolean`

Check if the sheet is open


## `set open(value: boolean): boolean`

An alternative way to open or close the sheet

<details open>
<summary><b>Example</b></summary>

```jsx
sheet.open = true // the same as executing sheet.showModal()
sheet.open = false // the same as executing sheet.close()
```

</details>
Loading