aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/ui/animation.tsx
blob: 943e3bf287b8f373db044754cbf9d3e37c14270a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import * as React from 'react';
import { keyframes, styled } from 'ts/style/theme';

export type AnimationType = 'easeUpFromBottom';

export interface AnimationProps {
    type: AnimationType;
}

const PlainAnimation: React.StatelessComponent<AnimationProps> = props => <div {...props} />;

const appearFromBottomFrames = keyframes`
    from {
        position: fixed;
        bottom: -500px;
        left: 0px;
        right: 0px;
    }

    to {
        position: fixed;
        bottom: 0px;
        left: 0px;
        right: 0px;
    }
`;

const stylesForAnimation: { [K in AnimationType]: string } = {
    // Needed for safari
    easeUpFromBottom: `position: fixed`,
};

const animations: { [K in AnimationType]: string } = {
    easeUpFromBottom: `${appearFromBottomFrames} 1s ease 0s 1 forwards`,
};

export const Animation = styled(PlainAnimation)`
    animation: ${props => animations[props.type]};
    ${props => stylesForAnimation[props.type]};
`;

Animation.displayName = 'Animation';