Skip to content

Commit

Permalink
App 2015 modal (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrloureed authored Jun 26, 2023
1 parent 73144b0 commit 5eb8611
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<style>
* {
font-family: 'Public Sans', sans-serif;
font-family: 'Public Sans', sans-serif !important;
}

.sbdocs-h1,
Expand Down
32 changes: 17 additions & 15 deletions src/elements/modal.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- Use native modal once supported https://caniuse.com/?search=popover -->
<svelte:options immutable tag="v-modal" />

<script lang="ts">
Expand Down Expand Up @@ -34,7 +35,7 @@ const handleClose = (event: MouseEvent | KeyboardEvent) => {
-->
<div
class={cx(
'z-50 bg-gray-2 bg-opacity-25 w-full h-full fixed top-0 left-0 flex justify-center items-center',
'z-50 bg-black bg-opacity-40 w-full h-full fixed top-0 left-0 flex justify-center items-center',
{
invisible: !isOpen,
}
Expand All @@ -45,31 +46,32 @@ const handleClose = (event: MouseEvent | KeyboardEvent) => {
on:keyup|stopPropagation|preventDefault={handleClose}
>
<div
class="w-[400px] relative border border-gray-9 bg-white m-2 p-4 max-w-lg shadow-sm"
class="w-[480px] relative border border-medium bg-white p-6 max-w-lg shadow-sm"
on:click|stopPropagation
on:keyup|stopPropagation
>
<button
class="absolute right-0 top-0 p-3 hover:scale-110 transition-transform text-default hover:text-gray-9"
aria-label="Cancel"
<v-button
class="absolute right-4 top-4 text-gray-6"
icon="x"
label="Delete component"
variant="icon"
on:click={handleClose}
>
<v-icon name="x" size="2xl" />
</button>

<figure>
<figcaption class="mb-2 pr-12 text-2xl font-bold">
on:keydown={handleClose}
/>
<figure class="min-h-[400px] flex flex-col gap-2">
<figcaption class="pr-12 text-lg font-semibold">
{title}
</figcaption>

{#if message}
<p class="mb-8 text-base">{message}</p>
<p class="text-sm text-subtle-1">{message}</p>
{/if}

<slot />
<div class="flex flex-grow"><slot /></div>

<div class="flex flex-row-reverse">
<slot name="action" />
<div class="flex justify-end gap-2">
<slot name="secondary" />
<slot name="primary" />
</div>
</figure>
</div>
Expand Down
15 changes: 9 additions & 6 deletions src/stories/modal.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ Creates a modal overlay
<Story
name='Confirmation'
args={{
title: 'Delete Confirmation!',
title: 'Delete confirmation',
message: 'Are you sure you want to delete this?',
buttonText: 'DELETE',
variant: 'danger',
buttonText: 'Delete',
variant: 'inverse-primary',
open: true,
}}
>
Expand All @@ -63,11 +63,14 @@ Creates a modal overlay
onclose='this.removeAttribute("open")'
>
<v-button
class='ml-4'
variant='${variant}'
label='${buttonText}'
slot='action'
/>
slot='primary'
></v-button>
<v-button
label='Cancel'
slot='secondary'
></v-button>
</v-modal>
</div>
`}
Expand Down

0 comments on commit 5eb8611

Please sign in to comment.