aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/@next/components/definition.tsx
blob: d203151b9b94983a245bbc8dfa0a8d18a4057549 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import * as React from 'react';
import styled from 'styled-components';

import { Button } from 'ts/@next/components/button';
import { Icon } from 'ts/@next/components/icon';
import { Heading, Paragraph } from 'ts/@next/components/text';

interface Action {
    label: string;
    url?: string;
    onClick?: () => void;
    useAnchorTag?: boolean;
}

interface Props {
    isInline?: boolean;
    isInlineIcon?: boolean;
    isCentered?: boolean;
    isWithMargin?: boolean;
    icon: string;
    iconSize?: 'medium' | 'large' | number;
    title: string;
    titleSize?: 'small' | 'default' | number;
    description: React.ReactNode | string;
    actions?: Action[];
}

export const Definition = (props: Props) => (
    <Wrap {...props}>
        <Icon name={props.icon} size={props.iconSize || 'medium'} margin={[0, 0, 'default', 0]} />

        <TextWrap {...props}>
            <Heading
                asElement="h2"
                fontWeight="400"
                marginBottom={props.titleSize === 'small' ? '7px' : '15px'}
                size={props.titleSize || 'default'}
            >
                {props.title}
            </Heading>

            {typeof props.description === 'string' ? (
                <Paragraph isMuted={true}>{props.description}</Paragraph>
            ) : (
                <>{props.description}</>
            )}

            {props.actions && (
                <LinkWrap>
                    {props.actions.map((item, index) => (
                        <Button
                            key={`dlink-${index}`}
                            href={item.url}
                            onClick={item.onClick}
                            isWithArrow={true}
                            isAccentColor={true}
                            useAnchorTag={item.useAnchorTag}
                            target="_blank"
                        >
                            {item.label}
                        </Button>
                    ))}
                </LinkWrap>
            )}
        </TextWrap>
    </Wrap>
);

const Wrap =
    styled.div <
    Props >
    `
    max-width: ${props => props.isInline && '354px'};

    & + & {
        margin-top: ${props => props.isInlineIcon && '120px'};
        margin-top: ${props => props.isWithMargin && '60px'};
    }

    @media (min-width: 768px) {
        width: ${props => (props.isInline ? 'calc(33.3333% - 30px)' : '100%')};
        display: ${props => props.isInlineIcon && 'flex'};
        justify-content: ${props => props.isInlineIcon && 'space-between'};
        align-items: ${props => props.isInlineIcon && 'center'};
        text-align: ${props => (props.isInlineIcon || !props.isCentered) && 'left'};
    }

    @media (max-width: 768px) {
        margin: 0 auto;

        & + & {
            margin-top: ${props => props.isInline && '60px'};
        }
    }
`;

const TextWrap =
    styled.div <
    Props >
    `
    width: 100%;
    max-width: 560px;

    ul {
        padding-top: 10px;
        padding-left: 1rem;
    }

    li {
        list-style: disc;
        opacity: 0.75;
        line-height: 1.444444444;
        margin-bottom: 1rem;
    }

    @media (min-width: 768px) {
        margin-left: ${props => props.isInlineIcon && '60px'};
    }
`;

const LinkWrap = styled.div`
    margin-top: 60px;

    @media (min-width: 768px) {
        display: inline-flex;

        a + a {
            margin-left: 60px;
        }
    }

    @media (max-width: 768px) {
        max-width: 250px;

        a + a {
            margin-top: 15px;
        }
    }
`;