index.js 6.79 KB
Newer Older
Amy Lam's avatar
Amy Lam committed
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
/**
 * Copyright (c) 2017-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const React = require('react');

const CompLibrary = require('../../core/CompLibrary.js');

const Container = CompLibrary.Container;
const GridBlock = CompLibrary.GridBlock;

const siteConfig = require(`${process.cwd()}/siteConfig.js`);

function imgUrl(img) {
  return `${siteConfig.baseUrl}img/${img}`;
}

function docUrl(doc, language) {
  return `${siteConfig.baseUrl}docs/${language ? `${language}/` : ''}${doc}`;
}

class Button extends React.Component {
  render() {
    return (
      <div className="pluginWrapper buttonWrapper">
        <a className="button" href={this.props.href} target={this.props.target}>
          {this.props.children}
        </a>
      </div>
    );
  }
}

Button.defaultProps = {
  target: '_self',
};

const SplashContainer = props => (
  <div className="homeContainer">
    <div className="homeSplashFade">
      <div className="wrapper homeWrapper">{props.children}</div>
    </div>
  </div>
);

const Logo = props => (
  <div className="projectLogo">
    <img src={props.img_src} alt="Project Logo" />
  </div>
);

const ProjectTitle = () => (
  <h2 className="projectTitle">
    {siteConfig.title}
    <small>{siteConfig.tagline}</small>
  </h2>
);

const PromoSection = props => (
  <div className="section promoSection">
    <div className="promoRow">
      <div className="pluginRowBlock">{props.children}</div>
    </div>
  </div>
);

class HomeSplash extends React.Component {
  render() {
    const language = this.props.language || '';
    return (
      <SplashContainer>
75
        <Logo img_src={imgUrl('logo.svg')} />
Amy Lam's avatar
Amy Lam committed
76
77
78
        <div className="inner">
          <ProjectTitle />
          <PromoSection>
79
80
81
            <Button href={docUrl('getting-started', language)}>
              Get started
            </Button>
82
83
84
            <Button href={docUrl('documentation-intro', language)}>
              Documentation
            </Button>
Amy Lam's avatar
Amy Lam committed
85
86
87
88
89
90
91
92
93
          </PromoSection>
        </div>
      </SplashContainer>
    );
  }
}

const Block = props => (
  <Container
94
    padding={props.padding}
Amy Lam's avatar
Amy Lam committed
95
    id={props.id}
96
97
    background={props.background}
  >
98
99
100
101
102
    <GridBlock
      align={props.align}
      contents={props.children}
      layout={props.layout}
    />
Amy Lam's avatar
Amy Lam committed
103
104
  </Container>
);
105
106
107
Block.defaultProps = {
  padding: ['bottom', 'top'],
};
Amy Lam's avatar
Amy Lam committed
108

109
110
const Features = props => (
  <Block layout="threeColumn" {...props}>
Amy Lam's avatar
Amy Lam committed
111
112
    {[
      {
113
114
115
        content:
          'There is just one build dependency. It uses Webpack, Babel, ESLint, and other amazing projects, but provides a cohesive curated experience on top of them.',
        title: 'One dependency',
Amy Lam's avatar
Amy Lam committed
116
117
      },
      {
118
119
120
        content:
          "You don't need to configure anything. Reasonably good configuration of both development and production builds is handled for you so you can focus on writing code.",
        title: 'No configuration required',
Amy Lam's avatar
Amy Lam committed
121
122
      },
      {
123
124
125
        content:
          'You can “eject” to a custom setup at any time. Run a single command, and all the configuration and build dependencies will be moved directly into your project, so you can pick up right where you left off.',
        title: 'No lock-in',
Amy Lam's avatar
Amy Lam committed
126
127
128
129
130
      },
    ]}
  </Block>
);

131
132
133
134
135
136
const GetStarted = props => (
  <Block layout="twoColumn" background="light" {...props}>
    {[
      {
        title: 'Get started coding in a matter of seconds!',
        content: `With Create React App, you get to focus on **writing React, not boilerplate**.
Kristofer Selbekk's avatar
Kristofer Selbekk committed
137
All you need to do is run a command, install some dependencies, and decide what's for dinner.
138

Kristofer Selbekk's avatar
Kristofer Selbekk committed
139
140
141
142
\`\`\`sh
npx create-react-app my-app
\`\`\`
`,
143
144
145
146
147
148
149
150
151
152
      },
      {
        image:
          'https://camo.githubusercontent.com/29765c4a32f03bd01d44edef1cd674225e3c906b/68747470733a2f2f63646e2e7261776769742e636f6d2f66616365626f6f6b2f6372656174652d72656163742d6170702f323762343261632f73637265656e636173742e737667',
        imageAlign: 'right',
      },
    ]}
  </Block>
);

153
154
155
156
157
158
159
160
161
162
const Update = props => (
  <Block layout="twoColumn" {...props}>
    {[
      {
        image: imgUrl('update.png'),
        imageAlign: 'left',
      },
      {
        title: 'Easy-to-maintain toolchain',
        content: `Keeping a build toolchain up to date with the latest and greatest can be a daunting and time-consuming
Kristofer Selbekk's avatar
Kristofer Selbekk committed
163
task for even the most seasoned developer. Create React App extracts all of those concerns into a single
Kristofer Selbekk's avatar
Kristofer Selbekk committed
164
dependency, which are **easy to update** and **battle tested by thousands**.
165

Kristofer Selbekk's avatar
Kristofer Selbekk committed
166
167
168
\`\`\`sh
npm install react-scripts@latest
\`\`\``,
169
170
171
172
173
      },
    ]}
  </Block>
);

174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
const FineGrainedFeatures = props => (
  <Block layout="fourColumn" align="center" padding={['bottom']} {...props}>
    {[
      {
        title: 'Webpack 4',
        content:
          'Webpack 4 gives you lightning fast rebuilds and code-splitting out of the box',
      },
      {
        title: 'Babel 7',
        content:
          'Babel 7 transpiles your code faster than ever, now with support for the new Fragment syntax `</>`',
      },
      {
        title: 'ES2015+',
        content:
          'Create React App is set up for you to use the features of the future',
      },
      {
        title: 'Jest',
        content:
          'The best test runner in the business is set up for you by default',
      },
      {
        title: 'Dev-server',
        content:
          'No-hassle local development thanks to the built-in dev-server',
      },
      {
        title: 'PostCSS',
        content:
          'Prefixing of new CSS features are done for you through Autoprefixer',
      },
      {
        title: 'SASS',
        content: 'Now you can write your styles with the power of SASS',
      },
      {
        title: 'CSS Modules',
        content: 'CSS Modules are also supported out of the box',
      },
      {
        title: 'Babel Macros',
        content:
218
          'Need some extra Babel-power? Babel Macros gives you just that',
219
220
221
222
223
224
225
226
227
      },
      {
        title: 'SVGs in React',
        content:
          'Now you can import your SVGs and use them as React components',
      },
      {
        title: 'Progressive Web Apps',
        content:
228
          'Every app created by Create React App is a fully Lighthouse-compliant PWA - opt in',
229
230
231
232
233
234
235
236
237
238
      },
      {
        title: 'Great DX',
        content:
          "Create React App is made for you - the developer. And we've made your day-to-day so much better",
      },
    ]}
  </Block>
);

Amy Lam's avatar
Amy Lam committed
239
240
241
242
243
244
245
246
class Index extends React.Component {
  render() {
    const language = this.props.language || '';

    return (
      <div>
        <HomeSplash language={language} />
        <div className="mainContainer">
247
248
          <Features align="center" />
          <GetStarted align="left" />
249
          <Update align="left" />
250
          <FineGrainedFeatures align="center" />
Amy Lam's avatar
Amy Lam committed
251
252
253
254
255
256
257
        </div>
      </div>
    );
  }
}

module.exports = Index;