Skip to content

Commit ba5d231

Browse files
authored
feat: Add minWidth and headerBackground props to Modal (#26)
* feat: Add minWidth and headerBackground props to Modal * test: Modal tests updated
1 parent 60d9b34 commit ba5d231

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

packages/pancake-uikit/src/__tests__/widgets/modal.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ it("renders correctly", () => {
1212
expect(asFragment()).toMatchInlineSnapshot(`
1313
<DocumentFragment>
1414
<div
15-
class="sc-iBPRYJ gkOLPp"
15+
class="sc-iBPRYJ bQXnUd"
1616
>
1717
<div
18-
class="sc-fubCfw lbhyFh"
18+
class="sc-fubCfw gpMxBN"
1919
>
2020
<div
2121
class="sc-dlfnbm sc-hKgILt sc-pFZIQ isWJdv dRpfYw ePMCIJ"

packages/pancake-uikit/src/__tests__/widgets/walletModal.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ it("renders ConnectModal correctly", () => {
99
expect(asFragment()).toMatchInlineSnapshot(`
1010
<DocumentFragment>
1111
<div
12-
class="sc-fubCfw bVmofg"
12+
class="sc-fubCfw cNFQaY"
1313
>
1414
<div
15-
class="sc-pFZIQ QVCVy"
15+
class="sc-pFZIQ fDnVSK"
1616
>
1717
<div
1818
class="sc-eCssSg sc-jSgupP sc-jrAGrp jnvqfy cjuMmG eYDuGd"
@@ -465,10 +465,10 @@ it("renders AccountModal correctly", () => {
465465
expect(asFragment()).toMatchInlineSnapshot(`
466466
<DocumentFragment>
467467
<div
468-
class="sc-fubCfw bVmofg"
468+
class="sc-fubCfw cNFQaY"
469469
>
470470
<div
471-
class="sc-pFZIQ QVCVy"
471+
class="sc-pFZIQ fDnVSK"
472472
>
473473
<div
474474
class="sc-eCssSg sc-jSgupP sc-jrAGrp jnvqfy cjuMmG eYDuGd"

packages/pancake-uikit/src/widgets/Modal/Modal.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ interface Props extends InjectedProps {
1111
hideCloseButton?: boolean;
1212
onBack?: () => void;
1313
bodyPadding?: string;
14+
headerBackground?: string;
15+
minWidth?: string;
1416
}
1517

16-
const StyledModal = styled.div`
18+
const StyledModal = styled.div<{ minWidth: string }>`
1719
background: ${({ theme }) => theme.modal.background};
1820
box-shadow: 0px 20px 36px -8px rgba(14, 14, 44, 0.1), 0px 1px 1px rgba(0, 0, 0, 0.05);
1921
border: 1px solid ${({ theme }) => theme.colors.borderColor};
@@ -23,17 +25,18 @@ const StyledModal = styled.div`
2325
overflow-y: auto;
2426
${({ theme }) => theme.mediaQueries.xs} {
2527
width: auto;
26-
min-width: 360px;
28+
min-width: ${({ minWidth }) => minWidth};
2729
max-width: 100%;
2830
}
2931
`;
3032

31-
const ModalHeader = styled.div`
33+
const ModalHeader = styled.div<{ background: string }>`
3234
display: flex;
3335
align-items: center;
3436
border-bottom: 1px solid #e9eaeb;
3537
align-items: center;
3638
padding: 12px 24px;
39+
background: ${({ background }) => background};
3740
`;
3841

3942
const ModalTitle = styled(Flex)`
@@ -48,9 +51,11 @@ const Modal: React.FC<Props> = ({
4851
children,
4952
hideCloseButton = false,
5053
bodyPadding = "24px",
54+
headerBackground = "transparent",
55+
minWidth = "360px",
5156
}) => (
52-
<StyledModal>
53-
<ModalHeader>
57+
<StyledModal minWidth={minWidth}>
58+
<ModalHeader background={headerBackground}>
5459
<ModalTitle>
5560
{onBack && (
5661
<IconButton variant="text" onClick={onBack} area-label="go back" mr="8px">

0 commit comments

Comments
 (0)