This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathindex.tsx
184 lines (169 loc) · 4.82 KB
/
index.tsx
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
179
180
181
182
183
184
import React, { ReactElement } from 'react';
import { injectIntl, WrappedComponentProps } from 'react-intl';
import { graphql } from 'gatsby';
import { IoLogoNodejs, IoMdGitPullRequest, IoMdRocket } from 'react-icons/io';
import DefaultLayout from '../layouts/default';
import { CommonComponents, DownloadComponents } from '../components';
import { connectGraphQlCustom } from '../connectGraphQlArticle';
import { HomepageData, BannersIndex, NodeReleaseData } from '../types';
import { ReactComponent as LeafsIllustrationFront } from '../images/illustrations/leafs-front.svg';
import { ReactComponent as LeafsIllustrationMiddle } from '../images/illustrations/leafs-middle.svg';
import { ReactComponent as LeafsIllustrationBack } from '../images/illustrations/leafs-back.svg';
import { ReactComponent as DotsIllustration } from '../images/illustrations/dots.svg';
import styles from './index.module.scss';
interface NodeFeatureProps {
icon?: ReactElement;
heading: string;
description: string;
}
const styled = (icon: ReactElement): ReactElement =>
React.cloneElement(icon, {
alt: 'Node Feature',
className: styles.featureIcon,
});
const features = [
{
icon: styled(<IoLogoNodejs />),
heading: 'pages.index.features.javascript.title',
description: 'pages.index.features.javascript.description',
},
{
icon: styled(<IoMdGitPullRequest />),
heading: 'pages.index.features.openSource.title',
description: 'pages.index.features.openSource.description',
},
{
icon: styled(<IoMdRocket />),
heading: 'pages.index.features.everywhere.title',
description: 'pages.index.features.everywhere.description',
},
];
const NodeFeature = ({
icon,
heading,
description,
}: NodeFeatureProps): JSX.Element => (
<div className={styles.nodeFeaturesFeature}>
{icon}
<h2 className="t-subheading2">{heading}</h2>
<p>{description}</p>
</div>
);
const Index = ({
data: {
article: {
frontmatter: { displayTitle, subTitle, description },
},
nodeReleases: { nodeReleasesData },
banners: { bannersIndex },
},
intl,
}: HomepageProps & WrappedComponentProps): JSX.Element => (
<DefaultLayout
title={displayTitle}
description={description}
showRandomContributor
>
<main className="home-container">
<CommonComponents.Banner bannersIndex={bannersIndex} />
<CommonComponents.Hero
title={displayTitle}
subTitle={subTitle}
nodeReleaseData={nodeReleasesData}
/>
<section className={styles.nodeDemoContainer}>
<div className={styles.nodeDemo}>
<DownloadComponents.InstallTabs />
</div>
<LeafsIllustrationFront className={`${styles.leafsFront} animations`} />
<LeafsIllustrationMiddle className={`${styles.leafsMid} animations`} />
<LeafsIllustrationBack className={`${styles.leafsBack} animations`} />
<DotsIllustration className={styles.dots} />
</section>
<section className={styles.nodeFeatures}>
{features.map(feature => (
<NodeFeature
key={feature.heading}
icon={feature.icon}
heading={intl.formatMessage({ id: feature.heading })}
description={intl.formatMessage({ id: feature.description })}
/>
))}
</section>
</main>
</DefaultLayout>
);
export default connectGraphQlCustom(injectIntl(Index));
export interface HomeNodeReleases {
nodeReleases: {
nodeReleasesData: NodeReleaseData[];
};
}
export interface HomeBannersIndex {
banners: {
bannersIndex: BannersIndex;
};
}
interface HomepageProps {
data: HomepageData & HomeNodeReleases & HomeBannersIndex;
}
export const query = graphql`
query ($locale: String!, $defaultLocale: String!) {
articleCurrentLanguage: mdx(
fields: { slug: { eq: "homepage" }, locale: { eq: $locale } }
) {
frontmatter {
displayTitle
subTitle
description
learnLinkText
nodeFeatureHeader1
nodeFeatureHeader2
nodeFeatureHeader3
nodeFeature1
nodeFeature2
nodeFeature3
nodeFeatureAltText
}
}
articleDefaultLanguage: mdx(
fields: { slug: { eq: "homepage" }, locale: { eq: $defaultLocale } }
) {
frontmatter {
displayTitle
subTitle
description
learnLinkText
nodeFeatureHeader1
nodeFeatureHeader2
nodeFeatureHeader3
nodeFeature1
nodeFeature2
nodeFeature3
nodeFeatureAltText
}
}
nodeReleases {
nodeReleasesData {
fullVersion
version
codename
isLts
status
initialRelease
ltsStart
maintenanceStart
endOfLife
}
}
banners {
bannersIndex: index {
endDate
link
text
html
startDate
}
}
}
`;