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
|
import { colors } from '@0xproject/react-shared';
import * as React from 'react';
import * as _ from 'lodash';
import { Button } from 'ts/components/ui/button';
import { Container } from 'ts/components/ui/container';
import { IconButton } from 'ts/components/ui/icon_button';
import { Island } from 'ts/components/ui/island';
import { Text, Title } from 'ts/components/ui/text';
export type ContinueButtonDisplay = 'enabled' | 'disabled';
export interface OnboardingCardProps {
title?: string;
shouldCenterTitle?: boolean;
content: React.ReactNode;
isLastStep: boolean;
onClose: () => void;
onClickNext: () => void;
onClickBack: () => void;
onContinueButtonClick?: () => void;
continueButtonDisplay?: ContinueButtonDisplay;
shouldHideBackButton?: boolean;
shouldHideNextButton?: boolean;
continueButtonText?: string;
borderRadius?: string;
// Used for super-custom content.
shouldRemoveExtraSpacing?: boolean;
}
export const OnboardingCard: React.StatelessComponent<OnboardingCardProps> = ({
title,
shouldCenterTitle,
content,
continueButtonDisplay,
continueButtonText,
onContinueButtonClick,
onClickNext,
onClickBack,
onClose,
shouldHideBackButton,
shouldHideNextButton,
borderRadius,
shouldRemoveExtraSpacing,
}) => {
const padding = shouldRemoveExtraSpacing
? {}
: {
paddingRight: '30px',
paddingLeft: '30px',
paddingTop: '15px',
paddingBottom: '15px',
};
const closeIconPositioning = shouldRemoveExtraSpacing
? { right: '15px', bottom: '3px' }
: { bottom: '20px', left: '15px' };
return (
<Island borderRadius={borderRadius}>
<Container {...padding}>
<div className="flex flex-column">
<Container className="flex justify-between">
<Container width="100%">
<Title center={shouldCenterTitle}>{title}</Title>
</Container>
<Container position="relative" {...closeIconPositioning}>
<IconButton color={colors.grey} iconName="zmdi-close" onClick={onClose}>
Close
</IconButton>
</Container>
</Container>
<Container marginBottom={shouldRemoveExtraSpacing ? undefined : '15px'}>
<Text>{content}</Text>
</Container>
{continueButtonDisplay && (
<Button
isDisabled={continueButtonDisplay === 'disabled'}
onClick={!_.isUndefined(onContinueButtonClick) ? onContinueButtonClick : onClickNext}
fontColor={colors.white}
fontSize="15px"
backgroundColor={colors.mediumBlue}
>
{continueButtonText}
</Button>
)}
{!(shouldHideBackButton && shouldHideNextButton) && (
<Container className="clearfix" marginTop="15px">
<div className="left">
{!shouldHideBackButton && (
<Text fontColor={colors.grey} onClick={onClickBack}>
Back
</Text>
)}
</div>
<div className="right">
{!shouldHideNextButton && (
<Text fontColor={colors.grey} onClick={onClickNext}>
Skip
</Text>
)}
</div>
</Container>
)}
</div>
</Container>
</Island>
);
};
OnboardingCard.defaultProps = {
continueButtonText: 'Continue',
shouldCenterTitle: false,
shouldRemoveExtraSpacing: false,
};
OnboardingCard.displayName = 'OnboardingCard';
|