forked from styled-components/styled-components-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
231 lines (199 loc) · 5.47 KB
/
index.js
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
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import React, { PureComponent } from 'react';
import NextLink from '../components/Link';
import styled, { css } from 'styled-components';
import { LiveProvider, LiveEditor, LivePreview } from 'react-live-runner';
import rem from '../utils/rem';
import { blmGrey, blmMetal, blmBlack } from '../utils/colors';
import { editorMixin, StyledError } from '../components/LiveEdit';
import Link from '../components/Link';
import { Content } from '../components/Layout';
import SeoHead from '../components/SeoHead';
import HomepageGettingStarted from '../sections/homepage/getting-started.md';
import WithIsScrolled from '../components/WithIsScrolled';
import Footer from '../components/Footer';
import Nav from '../components/Nav';
import { sortedCompanies, sortedProjects } from '../companies-manifest';
import UsersLogos from '../components/UsersLogos';
import SmallShowcase from '../components/SmallShowcase';
import baseScope from '../utils/scope';
const Tagline = styled.h1`
font-weight: 600;
font-size: 1.3rem;
`;
const SupportingTagline = styled.h2`
font-size: 1.1rem;
font-weight: 400;
`;
const headerCode = `
const Button = styled.a\`
/* This renders the buttons above... Edit me! */
display: inline-block;
border-radius: 3px;
padding: 0.5rem 0;
margin: 0.5rem 1rem;
width: 11rem;
background: transparent;
color: white;
border: 2px solid white;
/* The GitHub button is a primary button
* edit this to target it specifically! */
\${props => props.primary && css\`
background: white;
color: black;
\`}
\`
render(
<div>
<Button
href="https://github.com/styled-components/styled-components"
target="_blank"
rel="noopener"
primary
>
GitHub
</Button>
<Button as={Link} href="/docs">
Documentation
</Button>
</div>
)
`.trim();
const Title = styled.div`
margin: 2rem 0;
h1,
h2 {
margin: 0;
}
`;
const Logo = styled.img.attrs((/* props */) => ({
alt: 'styled-components Logo',
src: '/logo.png',
}))`
width: ${rem(125)};
height: ${rem(125)};
`;
const UsersHeading = styled.p`
text-transform: uppercase;
color: #fff;
font-size: 0.8rem;
font-weight: 600;
margin: 2.5rem 0 0.5rem;
opacity: 0.8;
`;
const ShowcaseHeading = styled(UsersHeading)`
margin: 2rem 0 0.5rem;
`;
const Wrapper = styled.div.attrs((/* props */) => ({
className: 'hero-header', // for integration tests
}))`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
color: white;
background: linear-gradient(20deg, ${blmGrey}, ${blmMetal});
box-shadow: 0 2px 20px rgba(0, 0, 0, 0.17);
box-sizing: border-box;
min-height: 100vh;
margin-bottom: 160px;
`;
const EditorContainer = styled.div`
display: inline-block;
box-shadow: ${rem(1)} ${rem(1)} ${rem(20)} rgba(20, 20, 20, 0.27);
margin: ${rem(35)} 0;
text-align: left;
width: 100%;
max-width: 34rem;
`;
const Editor = styled(LiveEditor)`
${editorMixin};
height: 24rem;
white-space: pre;
width: 100%;
`;
const Links = styled.div`
margin: ${rem(36)} 0;
`;
const ShowcaseLink = styled(NextLink)`
display: block;
max-width: 100%;
width: 196px;
background: red;
line-height: 48px;
text-align: center;
color: white;
font-family: Avenir Next;
border-radius: 4px;
margin: 0 auto;
background-color: ${blmGrey};
transition: background-color 0.2s ease-in-out;
&:hover {
background-color: ${blmBlack};
}
`;
class Index extends PureComponent {
state = {
isMobileNavFolded: true,
};
toggleMobileNav = () => {
this.setState((prevState) => ({
isMobileNavFolded: !prevState.isMobileNavFolded,
}));
};
onRouteChange = () => {
this.setState({
isMobileNavFolded: true,
});
};
render() {
const { isMobileNavFolded } = this.state;
return (
<div>
<SeoHead title="styled-components">
<meta name="robots" content="noodp" />
</SeoHead>
<WithIsScrolled>
{({ isScrolled }) => (
<Nav
showSideNav={false}
transparent={!isScrolled}
isMobileNavFolded={isMobileNavFolded}
onMobileNavToggle={this.toggleMobileNav}
onRouteChange={this.onRouteChange}
/>
)}
</WithIsScrolled>
<Wrapper>
<Content hero>
<LiveProvider code={headerCode} scope={{ styled: baseScope.styled, css, rem, Link }}>
<Logo />
<Title>
<Tagline>Visual primitives for the component age.</Tagline>
<SupportingTagline>
Use the best bits of ES6 and CSS to style your apps without stress 💅🏾
</SupportingTagline>
</Title>
<Links>
<LivePreview />
</Links>
<EditorContainer>
<Editor />
<StyledError />
</EditorContainer>
</LiveProvider>
<UsersHeading>Used by folks at</UsersHeading>
</Content>
<UsersLogos users={sortedCompanies.filter((v, i) => i % 2)} />
<UsersLogos reverse users={sortedCompanies.filter((v, i) => !(i % 2))} />
<ShowcaseHeading>To create beautiful websites like these</ShowcaseHeading>
<SmallShowcase projects={sortedProjects} />
</Wrapper>
<ShowcaseLink href="/showcase">Discover more</ShowcaseLink>
<HomepageGettingStarted />
<Footer />
</div>
);
}
}
export default Index;