diff --git a/packages/pancake-uikit/src/__tests__/widgets/menu.test.tsx b/packages/pancake-uikit/src/__tests__/widgets/menu.test.tsx index d2dc849bd..feca1704e 100644 --- a/packages/pancake-uikit/src/__tests__/widgets/menu.test.tsx +++ b/packages/pancake-uikit/src/__tests__/widgets/menu.test.tsx @@ -46,10 +46,10 @@ it("renders correctly", () => { expect(asFragment()).toMatchInlineSnapshot(`
{
body
diff --git a/packages/pancake-uikit/src/__tests__/widgets/modal.test.tsx b/packages/pancake-uikit/src/__tests__/widgets/modal.test.tsx index 8c84b8e25..7e2b19409 100644 --- a/packages/pancake-uikit/src/__tests__/widgets/modal.test.tsx +++ b/packages/pancake-uikit/src/__tests__/widgets/modal.test.tsx @@ -12,13 +12,13 @@ it("renders correctly", () => { expect(asFragment()).toMatchInlineSnapshot(`

{

body
diff --git a/packages/pancake-uikit/src/__tests__/widgets/walletModal.test.tsx b/packages/pancake-uikit/src/__tests__/widgets/walletModal.test.tsx index b2734200a..a5a44859d 100644 --- a/packages/pancake-uikit/src/__tests__/widgets/walletModal.test.tsx +++ b/packages/pancake-uikit/src/__tests__/widgets/walletModal.test.tsx @@ -9,13 +9,13 @@ it("renders ConnectModal correctly", () => { expect(asFragment()).toMatchInlineSnapshot(`

{

{ expect(asFragment()).toMatchInlineSnapshot(`

{

{
@@ -550,7 +550,7 @@ it("renders AccountModal correctly", () => { />
Copied
diff --git a/packages/pancake-uikit/src/widgets/Modal/Modal.tsx b/packages/pancake-uikit/src/widgets/Modal/Modal.tsx index b207a12a5..3b1ade440 100644 --- a/packages/pancake-uikit/src/widgets/Modal/Modal.tsx +++ b/packages/pancake-uikit/src/widgets/Modal/Modal.tsx @@ -1,50 +1,9 @@ import React from "react"; -import styled from "styled-components"; import Heading from "../../components/Heading/Heading"; -import Flex from "../../components/Box/Flex"; -import { ArrowBackIcon, CloseIcon } from "../../components/Svg"; -import { IconButton } from "../../components/Button"; -import { InjectedProps } from "./types"; +import { ModalBody, ModalHeader, ModalTitle, ModalContainer, ModalCloseButton, ModalBackButton } from "./styles"; +import { ModalProps } from "./types"; -interface Props extends InjectedProps { - title: string; - hideCloseButton?: boolean; - onBack?: () => void; - bodyPadding?: string; - headerBackground?: string; - minWidth?: string; -} - -const StyledModal = styled.div<{ minWidth: string }>` - background: ${({ theme }) => theme.modal.background}; - box-shadow: 0px 20px 36px -8px rgba(14, 14, 44, 0.1), 0px 1px 1px rgba(0, 0, 0, 0.05); - border: 1px solid ${({ theme }) => theme.colors.borderColor}; - border-radius: 32px; - width: 100%; - z-index: ${({ theme }) => theme.zIndices.modal}; - overflow-y: auto; - ${({ theme }) => theme.mediaQueries.xs} { - width: auto; - min-width: ${({ minWidth }) => minWidth}; - max-width: 100%; - } -`; - -const ModalHeader = styled.div<{ background: string }>` - display: flex; - align-items: center; - align-items: center; - padding: 12px 24px; - border-bottom: 1px solid ${({ theme }) => theme.colors.borderColor}; - background: ${({ background }) => background}; -`; - -const ModalTitle = styled(Flex)` - align-items: center; - flex: 1; -`; - -const Modal: React.FC = ({ +const Modal: React.FC = ({ title, onDismiss, onBack, @@ -53,27 +12,18 @@ const Modal: React.FC = ({ bodyPadding = "24px", headerBackground = "transparent", minWidth = "360px", + ...props }) => ( - + - {onBack && ( - - - - )} + {onBack && } {title} - {!hideCloseButton && ( - - - - )} + {!hideCloseButton && } - - {children} - - + {children} + ); export default Modal; diff --git a/packages/pancake-uikit/src/widgets/Modal/index.tsx b/packages/pancake-uikit/src/widgets/Modal/index.tsx index 841822124..b2ada4f78 100644 --- a/packages/pancake-uikit/src/widgets/Modal/index.tsx +++ b/packages/pancake-uikit/src/widgets/Modal/index.tsx @@ -1,4 +1,5 @@ export { default as Modal } from "./Modal"; export { default as ModalProvider } from "./ModalContext"; export { default as useModal } from "./useModal"; -export type { InjectedProps as InjectedModalProps } from "./types"; +export * from "./styles"; +export type { ModalProps, InjectedProps as InjectedModalProps } from "./types"; diff --git a/packages/pancake-uikit/src/widgets/Modal/styles.tsx b/packages/pancake-uikit/src/widgets/Modal/styles.tsx new file mode 100644 index 000000000..2b34d79e5 --- /dev/null +++ b/packages/pancake-uikit/src/widgets/Modal/styles.tsx @@ -0,0 +1,55 @@ +import React from "react"; +import styled from "styled-components"; +import Flex from "../../components/Box/Flex"; +import { Box } from "../../components/Box"; +import { ArrowBackIcon, CloseIcon } from "../../components/Svg"; +import { IconButton } from "../../components/Button"; +import { ModalProps } from "./types"; + +export const ModalHeader = styled.div<{ background?: string }>` + align-items: center; + background: ${({ background }) => background || "transparent"}; + border-bottom: 1px solid ${({ theme }) => theme.colors.borderColor}; + display: flex; + padding: 12px 24px; +`; + +export const ModalTitle = styled(Flex)` + align-items: center; + flex: 1; +`; + +export const ModalBody = styled(Flex)` + flex-direction: column; +`; + +export const ModalCloseButton: React.FC<{ onDismiss: ModalProps["onDismiss"] }> = ({ onDismiss }) => { + return ( + + + + ); +}; + +export const ModalBackButton: React.FC<{ onBack: ModalProps["onBack"] }> = ({ onBack }) => { + return ( + + + + ); +}; + +export const ModalContainer = styled(Box)<{ minWidth: string }>` + background: ${({ theme }) => theme.modal.background}; + box-shadow: 0px 20px 36px -8px rgba(14, 14, 44, 0.1), 0px 1px 1px rgba(0, 0, 0, 0.05); + border: 1px solid ${({ theme }) => theme.colors.borderColor}; + border-radius: 32px; + width: 100%; + z-index: ${({ theme }) => theme.zIndices.modal}; + + ${({ theme }) => theme.mediaQueries.xs} { + width: auto; + min-width: ${({ minWidth }) => minWidth}; + max-width: 100%; + } +`; diff --git a/packages/pancake-uikit/src/widgets/Modal/types.ts b/packages/pancake-uikit/src/widgets/Modal/types.ts index e7e6fb02e..8d934f2fa 100644 --- a/packages/pancake-uikit/src/widgets/Modal/types.ts +++ b/packages/pancake-uikit/src/widgets/Modal/types.ts @@ -1,3 +1,5 @@ +import { BoxProps } from "../../components/Box"; + export interface ModalTheme { background: string; } @@ -7,3 +9,12 @@ export type Handler = () => void; export interface InjectedProps { onDismiss?: Handler; } + +export interface ModalProps extends InjectedProps, BoxProps { + title: string; + hideCloseButton?: boolean; + onBack?: () => void; + bodyPadding?: string; + headerBackground?: string; + minWidth?: string; +}