Skip to content

Commit 45a573b

Browse files
committed
✨ Add transparent modal for opening custom components
1 parent 1fdef66 commit 45a573b

File tree

11 files changed

+59
-28
lines changed

11 files changed

+59
-28
lines changed

src/components/Button/button.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ export type SvelteButtonProps = {
2828

2929
export type ReactButtonProps = {
3030
onClick?: React.MouseEventHandler<HTMLButtonElement>
31-
children: React.ReactNode
31+
children?: React.ReactNode
3232
} & ButtonProps

src/components/Modal/Modal.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const {
2626
showCloseIcon = true,
2727
closeOnEsc = true,
2828
closeOnOverlay = true,
29+
transparent,
2930
theme,
3031
id,
3132
className,
@@ -40,6 +41,7 @@ const close = [
4041
4142
const classes = [
4243
styles.modal,
44+
transparent && styles.transparent,
4345
theme && styles[theme],
4446
className
4547
]

src/components/Modal/Modal.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
export let showCloseIcon: ModalProps['showCloseIcon'] = true
1919
export let closeOnEsc: ModalProps['closeOnEsc'] = true
2020
export let closeOnOverlay: ModalProps['closeOnOverlay'] = true
21+
export let transparent: ModalProps['transparent'] = false
2122
export let theme: ModalProps['theme'] = null
2223
export let id : ModalProps['className'] = ''
2324
export let className: ModalProps['className'] = ''
@@ -31,6 +32,7 @@
3132
3233
const classes = classNames([
3334
styles.modal,
35+
transparent && styles.transparent,
3436
theme && styles[theme],
3537
className
3638
])

src/components/Modal/Modal.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const Modal = ({
2626
showCloseIcon = true,
2727
closeOnEsc = true,
2828
closeOnOverlay = true,
29+
transparent,
2930
theme,
3031
id,
3132
className,
@@ -35,6 +36,7 @@ const Modal = ({
3536
const classes = classNames([
3637
styles.modal,
3738
theme && styles[theme],
39+
transparent && styles.transparent,
3840
className
3941
])
4042

src/components/Modal/modal.module.scss

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,11 @@
2828
}
2929
}
3030

31-
.close {
32-
@include position(absolute, t10px, r10px);
33-
@include spacing(p-xs);
34-
35-
svg {
36-
@include size(10px);
37-
}
38-
}
39-
40-
.title {
41-
@include typography(lg);
42-
@include spacing(mb-xs);
43-
@include layout(flex, v-center, xs);
44-
45-
svg {
46-
@include size(20px);
47-
}
48-
}
49-
50-
.subTitle {
51-
@include typography(primary-20);
52-
@include spacing(mb-xs);
31+
&.transparent {
32+
@include border(0);
33+
@include spacing(p0);
34+
@include size('wfit-content');
35+
@include background(transparent);
5336
}
5437

5538
&.info {
@@ -83,6 +66,30 @@
8366
@include typography(alert);
8467
}
8568
}
69+
70+
.close {
71+
@include position(absolute, t10px, r10px);
72+
@include spacing(p-xs);
73+
74+
svg {
75+
@include size(10px);
76+
}
77+
}
78+
79+
.title {
80+
@include typography(lg);
81+
@include spacing(mb-xs);
82+
@include layout(flex, v-center, xs);
83+
84+
svg {
85+
@include size(20px);
86+
}
87+
}
88+
89+
.subTitle {
90+
@include typography(primary-20);
91+
@include spacing(mb-xs);
92+
}
8693
}
8794

8895
.overlay {

src/components/Modal/modal.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type ModalProps = {
44
showCloseIcon?: boolean
55
closeOnEsc?: boolean
66
closeOnOverlay?: boolean
7+
transparent?: boolean
78
id?: string
89
className?: string
910
theme?: 'info'

src/icons/components.svg

Lines changed: 1 addition & 1 deletion
Loading

src/icons/file.svg

Lines changed: 1 addition & 1 deletion
Loading

src/icons/home.svg

Lines changed: 1 addition & 1 deletion
Loading

src/icons/sun.svg

Lines changed: 1 addition & 1 deletion
Loading

src/pages/modal.astro

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Button from '@components/Button/Button.astro'
66
import AstroModal from '@components/Modal/Modal.astro'
77
import SvelteModal from '@components/Modal/Modal.svelte'
88
import ReactModal from '@components/Modal/Modal.tsx'
9+
import Spinner from '@components/Spinner/Spinner.astro'
910
1011
import { getSections } from '@helpers'
1112
@@ -215,6 +216,22 @@ const sections = getSections({
215216
This modal was created using the alert theme
216217
</section.component>
217218
</ComponentWrapper>
219+
220+
<ComponentWrapper title="Loading modal">
221+
<Button theme="secondary" id={`modal-btn-10${index}`}>
222+
Trigger
223+
</Button>
224+
<section.component
225+
id={`modal-10${index}`}
226+
showCloseIcon={false}
227+
transparent={true}
228+
>
229+
<Spinner
230+
size={40}
231+
width={5}
232+
/>
233+
</section.component>
234+
</ComponentWrapper>
218235
</div>
219236
))}
220237
</Layout>
@@ -230,7 +247,7 @@ const sections = getSections({
230247
'react'
231248
]
232249

233-
const ids = Array(9).fill(10).map((x, index) => x * (index + 1))
250+
const ids = Array(10).fill(10).map((x, index) => x * (index + 1))
234251
const variants = [
235252
'00',
236253
'01',

0 commit comments

Comments
 (0)