aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/onboarding/onboarding_tooltip.tsx
blob: eb34a87f2e94c94e4fda69df6fe076890e29717a (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
import * as React from 'react';

import { colors } from '@0xproject/react-shared';
import { Container } from 'ts/components/ui/container';
import { Island } from 'ts/components/ui/island';

export type ContinueButtonDisplay = 'enabled' | 'disabled';

export interface OnboardingTooltipProps {
    title?: string;
    content: React.ReactNode;
    isLastStep: boolean;
    onClose: () => void;
    onClickNext: () => void;
    onClickBack: () => void;
    continueButtonDisplay?: ContinueButtonDisplay;
    hideBackButton?: boolean;
    hideNextButton?: boolean;
}

// TODO: Make this more general button.
export interface ContinueButtonProps {
    display: ContinueButtonDisplay;
    children?: string;
    onClick: () => void;
}

export const ContinueButton: React.StatelessComponent<ContinueButtonProps> = (props: ContinueButtonProps) => {
    const isDisabled = props.display === 'disabled';
    return (
        <button disabled={isDisabled} onClick={isDisabled ? undefined : props.onClick}>
            {props.children}
        </button>
    );
};

export const OnboardingTooltip: React.StatelessComponent<OnboardingTooltipProps> = (props: OnboardingTooltipProps) => (
    <Island>
        <Container paddingRight="30px" paddingLeft="30px" maxWidth={350} paddingTop="15px" paddingBottom="15px">
            <div className="flex flex-column">
                {props.title}
                {props.content}
                {props.continueButtonDisplay && (
                    <ContinueButton onClick={props.onClickNext} display={props.continueButtonDisplay}>
                        Continue
                    </ContinueButton>
                )}
                {!props.hideBackButton && <button onClick={props.onClickBack}>Back</button>}
                {!props.hideNextButton && <button onClick={props.onClickNext}>Skip</button>}
                <button onClick={props.onClose}>Close</button>
            </div>
        </Container>
    </Island>
);

OnboardingTooltip.displayName = 'OnboardingTooltip';