diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-11-02 05:33:43 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-11-02 05:33:43 +0800 |
commit | f341626e290a5c8241400b8dd0d9cce2dcfeb405 (patch) | |
tree | 08fc761936e7c8d620087ac6b4c83ac6aa1f3864 /packages/instant/src/components/sliding_panel.tsx | |
parent | 7858dafce4c9441c8205fa6ed607ca50851cc4ba (diff) | |
parent | 0955feb0234bc90b7dcf5ad3a308570c9fa5d490 (diff) | |
download | dexon-sol-tools-f341626e290a5c8241400b8dd0d9cce2dcfeb405.tar.gz dexon-sol-tools-f341626e290a5c8241400b8dd0d9cce2dcfeb405.tar.zst dexon-sol-tools-f341626e290a5c8241400b8dd0d9cce2dcfeb405.zip |
Merge branch 'development' into feature/instant/simulated-progress-bar
Diffstat (limited to 'packages/instant/src/components/sliding_panel.tsx')
-rw-r--r-- | packages/instant/src/components/sliding_panel.tsx | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/packages/instant/src/components/sliding_panel.tsx b/packages/instant/src/components/sliding_panel.tsx new file mode 100644 index 000000000..9219ad1f1 --- /dev/null +++ b/packages/instant/src/components/sliding_panel.tsx @@ -0,0 +1,59 @@ +import * as React from 'react'; + +import { ColorOption } from '../style/theme'; +import { zIndex } from '../style/z_index'; + +import { PositionAnimationSettings } from './animations/position_animation'; +import { SlideAnimation, SlideAnimationState } from './animations/slide_animation'; +import { Button, Container, Text } from './ui'; + +export interface PanelProps { + onClose?: () => void; +} + +export const Panel: React.StatelessComponent<PanelProps> = ({ children, onClose }) => ( + <Container backgroundColor={ColorOption.white} width="100%" height="100%" zIndex={zIndex.panel}> + <Button onClick={onClose}> + <Text fontColor={ColorOption.white}>Close </Text> + </Button> + {children} + </Container> +); + +export interface SlidingPanelProps extends PanelProps { + animationState: SlideAnimationState; +} + +export const SlidingPanel: React.StatelessComponent<SlidingPanelProps> = props => { + if (props.animationState === 'none') { + return null; + } + const { animationState, ...rest } = props; + const slideAmount = '100%'; + const slideUpSettings: PositionAnimationSettings = { + duration: '0.3s', + timingFunction: 'ease-in-out', + top: { + from: slideAmount, + to: '0px', + }, + }; + const slideDownSettings: PositionAnimationSettings = { + duration: '0.3s', + timingFunction: 'ease-out', + top: { + from: '0px', + to: slideAmount, + }, + }; + return ( + <SlideAnimation + position="absolute" + slideInSettings={slideUpSettings} + slideOutSettings={slideDownSettings} + animationState={animationState} + > + <Panel {...rest} /> + </SlideAnimation> + ); +}; |