Skip to content

Commit

Permalink
[fix](@svelteui/core): fix resize issue on Modal for smaller viewports
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #419
  • Loading branch information
BeeMargarida committed Jul 18, 2023
1 parent 2357938 commit 0770e2b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
8 changes: 4 additions & 4 deletions apps/docs/src/lib/data/main/homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,11 @@ export const components = [
component: Mark,
link: 'core/mark',
title: 'Mark',
color: '$blue600',
color: '$blue600',
content: 'Enter some text'
},
{
icon: BoxIcon,
},
{
icon: BoxIcon,
component: Blockquote,
link: 'core/blockquote',
title: 'Blockquote',
Expand Down
13 changes: 13 additions & 0 deletions packages/svelteui-core/src/components/Modal/Modal.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
function handleClose() {
opened = false;
}
const content = Array(100)
.fill(0)
.map((_, index) => 'Svelte is a complier');
</script>

<Meta title="Components/Modal" component={Modal} />
Expand All @@ -32,3 +36,12 @@
</Template>

<Story name="Modal" id="modalStory" />

<Story name="With Overflow" id="modalOverflowStory">
<Button on:click={toggleOpen}>Click Me</Button>
<Modal {opened} on:close={handleClose} overflow="inside">
{#each content as _}
<p>{_}</p>
{/each}
</Modal>
</Story>
10 changes: 8 additions & 2 deletions packages/svelteui-core/src/components/Modal/Modal.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ export default createStyles((theme, { centered, overflow, size, zIndex }: ModalS
alignItems: centered ? 'center' : 'flex-start'
},

transition: {
display: 'flex',
justifyContent: 'center',
width: '100%',
maxWidth: '100%'
},

title: {
marginRight: +theme.space.md.value,
textOverflow: 'ellipsis',
Expand All @@ -61,8 +68,7 @@ export default createStyles((theme, { centered, overflow, size, zIndex }: ModalS
backgroundColor: 'white',
marginTop: centered ? 'auto' : undefined,
marginBottom: centered ? 'auto' : undefined,
zIndex: 1,
marginLeft: 'calc(var(--removed-scroll-width, 0px) * -1)'
zIndex: 1
},

header: {
Expand Down
24 changes: 12 additions & 12 deletions packages/svelteui-core/src/components/Modal/Modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
shouldTrigger && event.code === 'Escape' && closeOnEscape && onClose();
}}
>
<div transition:scale={{ duration: 100, easing: sineInOut }}>
<div class={classes.transition} transition:scale={{ duration: 100, easing: sineInOut }}>
<Paper
class={classes.modal}
{shadow}
Expand Down Expand Up @@ -143,17 +143,17 @@
</div>
</Paper>
</div>
<div transition:fade={{ duration: 200, easing: sineInOut }}>
<Overlay
class={classes.overlay}
override={{ position: 'fixed' }}
zIndex={0}
on:mousedown={() => closeOnClickOutside && onClose()}
blur={overlayBlur}
color={overlayColor || 'black'}
opacity={_overlayOpacity}
/>
</div>
</div>
<div transition:fade={{ duration: 200, easing: sineInOut }}>
<Overlay
class={classes.overlay}
override={{ position: 'fixed' }}
zIndex={0}
on:mousedown={() => closeOnClickOutside && onClose()}
blur={overlayBlur}
color={overlayColor || 'black'}
opacity={_overlayOpacity}
/>
</div>
</Box>
</OptionalPortal>
Expand Down

0 comments on commit 0770e2b

Please sign in to comment.