Skip to content

Commit

Permalink
Add class property
Browse files Browse the repository at this point in the history
  • Loading branch information
probablykasper committed Jan 10, 2024
1 parent 46a65e6 commit 4ccb848
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Next
- Add `class` property
- Fix escape shortcut handling
- Fix Tailwind compatibility

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ This shows all available functionality
form={() => submitMyForm()}
noEscapeHandling
noCloseIcon
let:focus
class="w-full"
>
<p>Content</p>
<input />
<!-- If you want to bring focus to a specific element -->
<input use:focus />
<input autofocus />
<div slot="buttons">
<button type="submit">Submit</button>
Expand Down
4 changes: 3 additions & 1 deletion src/lib/Modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
$: tag = form === undefined ? 'div' : 'form'
export let noCloseIcon = false
export let title: string | null = null
export let classes = ''
export { classes as class }
let dialogEl: HTMLDialogElement
let backdrop = false
Expand Down Expand Up @@ -50,7 +52,7 @@

<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
<dialog
class="modal"
class="modal{classes ? ' ' + classes : ''}"
class:show-backdrop={backdrop}
bind:this={dialogEl}
on:mousedown|self={() => {
Expand Down
12 changes: 6 additions & 6 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
<span>noCloseIcon</span>
<input type="checkbox" bind:checked={noCloseIcon} />
</div>
</div>
<div class="row">
<span>disableEscapeHandling</span>
<input type="checkbox" bind:checked={noEscapeHandling} />
<div class="row">
<span>noEscapeHandling</span>
<input type="checkbox" bind:checked={noEscapeHandling} />
</div>
</div>
</div>

Expand Down Expand Up @@ -75,8 +75,8 @@
display: flex
align-items: center
height: 24px
span
margin-right: 12px
width: 100%
gap: 20px
input
margin-left: auto
p
Expand Down

0 comments on commit 4ccb848

Please sign in to comment.