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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
import { colors } from '@0xproject/react-shared';
import { ObjectMap } from '@0xproject/types';
import * as _ from 'lodash';
import * as React from 'react';
import { DropDown } from 'ts/components/ui/drop_down';
import { Link } from 'ts/components/ui/link';
import { Deco, Key, WebsitePaths } from 'ts/types';
import { constants } from 'ts/utils/constants';
import { Translate } from 'ts/utils/translate';
interface LinkInfo {
link: string;
shouldOpenInNewTab?: boolean;
}
const gettingStartedKeyToLinkInfo1: ObjectMap<LinkInfo> = {
[Key.BuildARelayer]: {
link: `${WebsitePaths.Wiki}#Build-A-Relayer`,
},
[Key.OrderBasics]: {
link: `${WebsitePaths.Wiki}#Create,-Validate,-Fill-Order`,
},
};
const gettingStartedKeyToLinkInfo2: ObjectMap<LinkInfo> = {
[Key.DevelopOnEthereum]: {
link: `${WebsitePaths.Wiki}#Ethereum-Development`,
},
[Key.UseSharedLiquidity]: {
link: `${WebsitePaths.Wiki}#Find,-Submit,-Fill-Order-From-Relayer`,
},
};
const popularDocsToLinkInfos: ObjectMap<LinkInfo> = {
[Key.ZeroExJs]: {
link: WebsitePaths.ZeroExJs,
},
[Key.Connect]: {
link: WebsitePaths.Connect,
},
[Key.SmartContract]: {
link: WebsitePaths.SmartContracts,
},
};
const usefulLinksToLinkInfo: ObjectMap<LinkInfo> = {
[Key.Github]: {
link: constants.URL_GITHUB_ORG,
shouldOpenInNewTab: true,
},
[Key.Whitepaper]: {
link: WebsitePaths.Whitepaper,
shouldOpenInNewTab: true,
},
[Key.Sandbox]: {
link: constants.URL_SANDBOX,
shouldOpenInNewTab: true,
},
};
interface DevelopersDropDownProps {
translate: Translate;
menuItemStyles: React.CSSProperties;
menuIconStyle: React.CSSProperties;
}
interface DevelopersDropDownState {}
export class DevelopersDropDown extends React.Component<DevelopersDropDownProps, DevelopersDropDownState> {
public render(): React.ReactNode {
const activeNode = (
<div className="flex relative" style={{ color: this.props.menuIconStyle.color }}>
<div style={{ paddingRight: 10 }}>{this.props.translate.get(Key.Developers, Deco.Cap)}</div>
</div>
);
return (
<DropDown
activeNode={activeNode}
popoverContent={this._renderDropdownMenu()}
anchorOrigin={{ horizontal: 'left', vertical: 'bottom' }}
targetOrigin={{ horizontal: 'left', vertical: 'top' }}
style={this.props.menuItemStyles}
popoverStyle={{ borderRadius: 4, width: 427, height: 373, marginTop: 10 }}
/>
);
}
private _renderDropdownMenu(): React.ReactNode {
const dropdownMenu = (
<div>
<div style={{ padding: '1.75rem' }}>
{this._renderTitle('Getting started')}
<div className="flex">
<div className="pr4 mr2">{this._renderLinkSection(gettingStartedKeyToLinkInfo1)}</div>
<div>{this._renderLinkSection(gettingStartedKeyToLinkInfo2)}</div>
</div>
</div>
<div
style={{
width: '100%',
height: 1,
backgroundColor: colors.grey300,
}}
/>
<div className="flex" style={{ padding: '1.75rem' }}>
<div className="pr4 mr2">
<div>{this._renderTitle('Popular docs')}</div>
<div>{this._renderLinkSection(popularDocsToLinkInfos)}</div>
</div>
<div>
<div>{this._renderTitle('Useful links')}</div>
<div>{this._renderLinkSection(usefulLinksToLinkInfo)}</div>
</div>
</div>
<div
style={{
padding: '1.125rem',
textAlign: 'center',
backgroundColor: colors.lightBgGrey,
borderBottomLeftRadius: 4,
borderBottomRightRadius: 4,
}}
>
<Link
to={WebsitePaths.Docs}
className="text-decoration-none"
style={{
color: colors.lightBlueA700,
fontWeight: 'bold',
fontSize: 14,
}}
>
{this.props.translate.get(Key.ViewAllDocumentation, Deco.Upper)}
</Link>
</div>
</div>
);
return dropdownMenu;
}
private _renderTitle(title: string): React.ReactNode {
return (
<div
style={{
color: colors.linkSectionGrey,
fontSize: 14,
paddingBottom: 12,
fontWeight: 600,
letterSpacing: 1,
}}
>
{title.toUpperCase()}
</div>
);
}
private _renderLinkSection(keyToLinkInfo: ObjectMap<LinkInfo>): React.ReactNode {
const linkStyle: React.CSSProperties = {
color: colors.lightBlueA700,
fontFamily: 'Roboto, Roboto Mono',
};
const numLinks = _.size(keyToLinkInfo);
let i = 0;
const links = _.map(keyToLinkInfo, (linkInfo: LinkInfo, key: string) => {
i++;
const isLast = i === numLinks;
const linkText = this.props.translate.get(key as Key, Deco.Cap);
return (
<div className={`pr1 pt1 ${!isLast && 'pb1'}`} key={`dev-dropdown-link-${key}`}>
<Link
to={linkInfo.link}
isExternal={!!linkInfo.shouldOpenInNewTab}
shouldOpenInNewTab={linkInfo.shouldOpenInNewTab}
className="text-decoration-none"
style={linkStyle}
>
{linkText}
</Link>
</div>
);
});
return <div>{links}</div>;
}
}
|