Skip to content

Commit a0fea64

Browse files
committed
✨(frontend) create side modal component
Create SideModal component for displaying modal on the side of the screen. This component is build above the Cunningham component, so all the cunnighama props are still available.
1 parent de922e1 commit a0fea64

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to
1111
## Added
1212

1313
- 🤡(demo) generate dummy documents on dev users #120
14+
- ✨(frontend) create side modal component #134
1415

1516
## Changed
1617

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Modal, ModalSize } from '@openfun/cunningham-react';
2+
import { ComponentPropsWithRef, PropsWithChildren } from 'react';
3+
import { createGlobalStyle } from 'styled-components';
4+
5+
interface SideModalStyleProps {
6+
side: 'left' | 'right';
7+
width: string;
8+
}
9+
10+
const SideModalStyle = createGlobalStyle<SideModalStyleProps>`
11+
& .c__modal{
12+
width: ${({ width }) => width};
13+
${({ side }) => side === 'right' && 'left: auto;'};
14+
15+
.c__modal__scroller {
16+
height: 100%;
17+
display: flex;
18+
flex-direction: column;
19+
}
20+
}
21+
`;
22+
23+
type SideModalType = Omit<ComponentPropsWithRef<typeof Modal>, 'size'>;
24+
25+
interface SideModalProps extends SideModalType {
26+
side: 'left' | 'right';
27+
width: string;
28+
}
29+
30+
export const SideModal = ({
31+
children,
32+
side,
33+
width,
34+
...modalProps
35+
}: PropsWithChildren<SideModalProps>) => {
36+
return (
37+
<>
38+
<SideModalStyle width={width} side={side} />
39+
<Modal {...modalProps} size={ModalSize.FULL}>
40+
{children}
41+
</Modal>
42+
</>
43+
);
44+
};

0 commit comments

Comments
 (0)