Skip to content

Commit 4e1f7f7

Browse files
committed
(feat): modal & background style props
1 parent 03c43d5 commit 4e1f7f7

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/components/animatedModal/AnimatedModal.stories.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ const AnimatedModalTemplate: Story = () => {
2020

2121
return (
2222
<>
23-
<AnimatedModal ref={ref} animation={ModalAnimation.Unfold} />
23+
<AnimatedModal
24+
ref={ref}
25+
animation={ModalAnimation.Unfold}
26+
backgroundStyle={{ backgroundColor: 'blue', opacity: '0.8' }}
27+
modalStyle={{ background: 'rgba(122,242,154, 0.5)' }}
28+
/>
2429
<AnimatedModalFrame>
2530
<button onClick={() => ref.current?.OpenModal()}>Open Unfold Modal</button>
2631
<br />

src/components/animatedModal/AnimatedModal.styles.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ body {
2424

2525
#animated-modal-background {
2626
display:table-cell;
27-
background:rgba(0,0,0,.8);
27+
background-color: black;
28+
opacity: 0.8;
2829
text-align:center;
2930
vertical-align:middle;
3031

src/components/animatedModal/AnimatedModal.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ import { ModalAnimation } from './AnimatedModal.enums';
1111
* @property {ModalAnimation} animation Modal animation
1212
* @property {React.ReactNode} [children] Modal's children
1313
* @property {boolean} [closeOnBackgroundClick] Close modal on background click?
14+
* @property {React.CSSProperties} [backgroundStyle] Background Style
15+
* @property {React.CSSProperties} [modalStyle] Modal Style
1416
*/
1517
interface IAnimatedModalProps {
1618
startOpen?: boolean;
1719
animation: ModalAnimation;
1820
children?: React.ReactNode;
1921
closeOnBackgroundClick?: boolean;
22+
backgroundStyle?: React.CSSProperties;
23+
modalStyle?: React.CSSProperties;
2024
}
2125

2226
/**
@@ -156,8 +160,9 @@ const AnimatedModal = forwardRef(
156160
<div id="animated-modal-container" className={modalClass}>
157161
<div
158162
id="animated-modal-background"
159-
onClick={props.closeOnBackgroundClick ? onBackgroundClick : undefined}>
160-
<div id="animated-modal">
163+
onClick={props.closeOnBackgroundClick ? onBackgroundClick : undefined}
164+
style={props.backgroundStyle}>
165+
<div id="animated-modal" style={props.modalStyle}>
161166
{modalClass.includes(ModalAnimation.Sketch) ? sketchSVG() : undefined}
162167
<div id="modal-content">{props.children ? props.children : defaultModal()}</div>
163168
</div>

0 commit comments

Comments
 (0)