Add inline prop for modals to allow them to be used as actual components on pages
This commit is contained in:
parent
47dbb4ddb3
commit
0cd7dfa296
|
@ -7,9 +7,10 @@
|
|||
import Context from "../context"
|
||||
|
||||
export let fixed = false
|
||||
export let inline = false
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
let visible = !!fixed
|
||||
let visible = fixed || inline
|
||||
$: dispatch(visible ? "show" : "hide")
|
||||
|
||||
export function show() {
|
||||
|
@ -20,7 +21,7 @@
|
|||
}
|
||||
|
||||
export function hide() {
|
||||
if (!visible || fixed) {
|
||||
if (!visible || fixed || inline) {
|
||||
return
|
||||
}
|
||||
visible = false
|
||||
|
@ -45,7 +46,13 @@
|
|||
|
||||
<svelte:window on:keydown={handleKey} />
|
||||
|
||||
{#if visible}
|
||||
<!-- These svelte if statements need to be defined like this. -->
|
||||
<!-- The modal transitions do not work if nested inside more than one "if" -->
|
||||
{#if visible && inline}
|
||||
<div use:focusFirstInput class="spectrum-Modal is-open">
|
||||
<slot />
|
||||
</div>
|
||||
{:else if visible}
|
||||
<Portal target=".modal-container">
|
||||
<div
|
||||
class="spectrum-Underlay is-open"
|
||||
|
|
Loading…
Reference in New Issue