aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/components/sliding_error.tsx
blob: 17643fd7d21baa41d860d7191834d3388d1e1059 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import * as React from 'react';

import { ColorOption } from '../style/theme';

import { PositionAnimationSettings } from './animations/position_animation';
import { SlideAnimation, SlideAnimationState } from './animations/slide_animation';

import { Container, Flex, Text } from './ui';

export interface ErrorProps {
    icon: string;
    message: string;
}

export const Error: React.StatelessComponent<ErrorProps> = props => (
    <Container
        padding="10px"
        border={`1px solid ${ColorOption.darkOrange}`}
        backgroundColor={ColorOption.lightOrange}
        width="100%"
        borderRadius="6px"
        marginBottom="10px"
    >
        <Flex justify="flex-start">
            <Container marginRight="5px" display="inline" top="3px" position="relative">
                <Text fontSize="20px">{props.icon}</Text>
            </Container>
            <Text fontWeight="500" fontColor={ColorOption.darkOrange}>
                {props.message}
            </Text>
        </Flex>
    </Container>
);

export interface SlidingErrorProps extends ErrorProps {
    animationState: SlideAnimationState;
}
export const SlidingError: React.StatelessComponent<SlidingErrorProps> = props => {
    const slideAmount = '120px';
    const slideUpSettings: PositionAnimationSettings = {
        timingFunction: 'ease-in',
        top: {
            from: slideAmount,
            to: '0px',
        },
    };
    const slideDownSettings: PositionAnimationSettings = {
        timingFunction: 'cubic-bezier(0.25, 0.1, 0.25, 1)',
        top: {
            from: '0px',
            to: slideAmount,
        },
    };
    return (
        <SlideAnimation
            position="relative"
            slideInSettings={slideUpSettings}
            slideOutSettings={slideDownSettings}
            animationState={props.animationState}
        >
            <Error icon={props.icon} message={props.message} />
        </SlideAnimation>
    );
};