index.js 4.8 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
            <Button href={docUrl('getting-started', language)}>
Amy Lam's avatar
Amy Lam committed
80
              Getting Started
81
            </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
    {[
      {
Sophie Alpert's avatar
Sophie Alpert committed
113
        title: 'Less to Learn',
114
        content:
Sophie Alpert's avatar
Sophie Alpert committed
115
          "You don't need to learn and configure many build tools. Instant reloads help you focus on development. When it's time to deploy, your bundles are optimized automatically.",
Amy Lam's avatar
Amy Lam committed
116
117
      },
      {
Sophie Alpert's avatar
Sophie Alpert committed
118
        title: 'Only One Dependency',
119
        content:
Sophie Alpert's avatar
Sophie Alpert committed
120
          'Your app only needs one build dependency. We test Create React App to make sure that all of its underlying pieces work together seamlessly – no complicated version mismatches.',
Amy Lam's avatar
Amy Lam committed
121
122
      },
      {
Sophie Alpert's avatar
Sophie Alpert committed
123
        title: 'No Lock-In',
124
        content:
Sophie Alpert's avatar
Sophie Alpert committed
125
          'Under the hood, we use Webpack, Babel, ESLint, and other amazing projects to power your app. If you ever want an advanced configuration, you can ”eject” from Create React App and edit their config files directly.',
Amy Lam's avatar
Amy Lam committed
126
127
128
129
130
      },
    ]}
  </Block>
);

131
132
133
134
const GetStarted = props => (
  <Block layout="twoColumn" background="light" {...props}>
    {[
      {
Sophie Alpert's avatar
Sophie Alpert committed
135
136
137
138
        title: 'Get started in seconds',
        content: `Whether you’re using React or another library, Create React App lets you **focus on code, not build tools**.

To create a project called \`my-app\`, run this command:
139

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

154
155
156
157
158
159
160
161
const Update = props => (
  <Block layout="twoColumn" {...props}>
    {[
      {
        image: imgUrl('update.png'),
        imageAlign: 'left',
      },
      {
Sophie Alpert's avatar
Sophie Alpert committed
162
163
        title: 'Easy to maintain',
        content: `Updating your build tooling is typically a daunting and time-consuming task. When new versions of Create React App are released, you can upgrade using a single command:
164

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

Amy Lam's avatar
Amy Lam committed
173
174
175
176
177
178
179
180
class Index extends React.Component {
  render() {
    const language = this.props.language || '';

    return (
      <div>
        <HomeSplash language={language} />
        <div className="mainContainer">
Sophie Alpert's avatar
Sophie Alpert committed
181
          <Features align="left" />
182
          <GetStarted align="left" />
183
          <Update align="left" />
Amy Lam's avatar
Amy Lam committed
184
185
186
187
188
189
190
        </div>
      </div>
    );
  }
}

module.exports = Index;