DefinitelyTyped/types/styled-react-modal/styled-react-modal-tests.tsx
Greg c8739bc0d6 [styled-react-modal] update and export ModalProps interface (#35090)
* add missing prop to styled-react-modal

* fix lint errors
2019-05-06 01:20:17 -07:00

66 lines
2.0 KiB
TypeScript

import * as React from 'react';
import Modal, { ModalProvider, BaseModalBackground as BackgroundComponent } from 'styled-react-modal';
import styled from 'styled-components';
const background = styled.div`
background: rgba(0,0,0,.3);
`;
// Padding through a custom backgroundComponent
const test1 = (
<ModalProvider backgroundComponent={background}>
<Modal
isOpen={true}
onBackgroundClick={() => console.log('Background click!')}
onEscapeKeydown={() => console.log('Background click!')}
afterOpen={() => console.log('After Open!')}
afterClose={() => console.log('After Close!')}
beforeOpen={() => console.log('Before Open!')}
beforeClose={() => console.log('Before Close!')}
allowScroll={true}
>
Modal Content!
</Modal>
</ModalProvider>
);
// Passing through the default component
const test2 = (
<ModalProvider backgroundComponent={BackgroundComponent}>
<Modal
isOpen={true}
backgroundProps={{style: {padding: "20px"}}}
onBackgroundClick={() => console.log('Background click!')}
onEscapeKeydown={() => console.log('Background click!')}
afterOpen={() => console.log('After Open!')}
afterClose={() => console.log('After Close!')}
beforeOpen={() => console.log('Before Open!')}
beforeClose={() => console.log('Before Close!')}
allowScroll={true}
>
Modal Content!
</Modal>
</ModalProvider>
);
// Minimal Setup
const test3 = (
<ModalProvider>
<Modal isOpen={true}>
Modal Content!
</Modal>
</ModalProvider>
);
const StyledModal = Modal.styled`
background: red;
`;
const test4 = (
<ModalProvider>
<StyledModal isOpen={true} onBackgroundClick={() => console.log('Background click!')}>
Modal Content!
</StyledModal>
</ModalProvider>
);