Skip to content

Commit f7382ae

Browse files
gillkyleGatsbyJS Bot
authored and
GatsbyJS Bot
committedAug 22, 2019
feat(www): add code snippet with install command to starters (#16972)
1 parent 3299192 commit f7382ae

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
 

‎www/src/templates/template-starter-page.js

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import StarterHeader from "../views/starter/header"
99
import StarterMeta from "../views/starter/meta"
1010
import StarterScreenshot from "../views/starter/screenshot"
1111
import StarterSource from "../views/starter/source"
12+
import StarterInstallation from "../views/starter/installation"
1213
import StarterDetails from "../views/starter/details"
1314
import FooterLinks from "../components/shared/footer-links"
1415

@@ -115,6 +116,7 @@ class StarterTemplate extends React.Component {
115116
<StarterScreenshot imageSharp={screenshot} repoName={repoName} />
116117
</div>
117118
<StarterSource repoUrl={repoUrl} startersYaml={startersYaml} />
119+
<StarterInstallation repoName={repoName} repoUrl={repoUrl} />
118120
<StarterDetails
119121
startersYaml={startersYaml}
120122
allDeps={allDeps}

‎www/src/views/starter/installation.js

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import React from "react"
2+
import Copy from "../../components/copy"
3+
import {
4+
colors,
5+
space,
6+
radii,
7+
mediaQueries,
8+
fontSizes,
9+
} from "../../utils/presets"
10+
11+
const StarterInstallation = ({ repoName, repoUrl }) => {
12+
const content = `gatsby new ${repoName || `my-gatsby-project`} ${repoUrl}`
13+
return (
14+
<div
15+
css={{
16+
padding: `0px ${space[6]}`,
17+
[mediaQueries.lg]: {
18+
padding: `0px ${space[8]}`,
19+
display: `grid`,
20+
gridTemplateRows: `auto auto`,
21+
gridRowGap: space[2],
22+
},
23+
}}
24+
>
25+
<div css={{ fontSize: fontSizes[1], color: colors.text.secondary }}>
26+
Install this starter locally:
27+
</div>
28+
<pre
29+
css={{
30+
padding: 0,
31+
background: colors.code.bg,
32+
}}
33+
>
34+
<code
35+
css={{
36+
display: `flex`,
37+
alignItems: `center`,
38+
justifyContent: `space-between`,
39+
padding: space[2],
40+
overflowWrap: `break-word`,
41+
[mediaQueries.lg]: {
42+
padding: space[3],
43+
},
44+
"&:before": {
45+
display: `none`,
46+
},
47+
"&:after": {
48+
display: `none`,
49+
},
50+
}}
51+
>
52+
{content}
53+
<Copy
54+
fileName="Install command"
55+
content={content}
56+
css={{ borderRadius: `${radii[1]}px` }}
57+
/>
58+
</code>
59+
</pre>
60+
</div>
61+
)
62+
}
63+
64+
export default StarterInstallation

0 commit comments

Comments
 (0)
Please sign in to comment.