Skip to content

Commit 766ea4c

Browse files
greglobinskiamberleyromo
authored andcommitted
feat(www): add Ecosystem section to Homepage (#9783)
* feat(www): add Ecosystem section to Homepage feat(www): homepage WIP wip feat(www): finish sections style for mobile feat(www): add Ecosystsem featured items to Hompage feat(www): homepage ecosystem section styling WIP feat(www): add arrow to action button * fix(www): fix code formating * fix(www): fix code formating and eslint errors * fix(www): fix hovering effect on Featured Item * fix(www): fix hovering effect sequel * fix(www): fix hover bug * fix(www): update texts (intro & link labels) * feat(www): add scroller observer to Home page * refactor(www): use imported scrollers observer * fix(www): change link labes on Ecosystem page * fix(www): fix some small style issues * refactor(www): refator combineEcosystemFeaturedItems and reorder some css properties * refactor(www): remove width setting from scroller container * fix(www): update featured starters * fix(www): update featured starters * refactor(www): add starter/plugins colors to the palette * fix(www): remove unused props * fix(www): fix color value in the palette
1 parent 15b08c2 commit 766ea4c

15 files changed

+641
-142
lines changed

www/gatsby-node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ exports.onCreateNode = ({ node, actions, getNode, reporter }) => {
620620

621621
exports.onCreatePage = ({ page, actions }) => {
622622
// add lists of featured items to Ecosystem page
623-
if (page.path === `/ecosystem/`) {
623+
if (page.path === `/ecosystem/` || page.path === `/`) {
624624
const { createPage, deletePage } = actions
625625
const oldPage = Object.assign({}, page)
626626

www/src/assets/ecosystem.svg

+1-1
Loading

www/src/components/button.js

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const Button = ({
1818
small,
1919
tiny,
2020
secondary,
21+
ondark,
2122
...rest
2223
}) => {
2324
const Tag = components[tag || `link`]
@@ -36,6 +37,7 @@ const Button = ({
3637
...(large && buttonStyles.large),
3738
...(small && buttonStyles.small),
3839
...(tiny && buttonStyles.tiny),
40+
...(ondark && buttonStyles.ondark),
3941
},
4042
}
4143

www/src/components/cards.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const Cards = ({ children }) => (
1111
borderRadius: presets.radiusLg,
1212
boxShadow: `0 5px 20px rgba(25, 17, 34, 0.1)`,
1313
transform: `translateZ(0)`,
14+
width: `100%`,
1415
}}
1516
>
1617
{children}

www/src/components/ecosystem/ecosystem-board.js

+9-61
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import styled from "react-emotion"
55
import EcosystemSection from "./ecosystem-section"
66

77
import presets from "../../utils/presets"
8+
import {
9+
setupScrollersObserver,
10+
unobserveScrollers,
11+
} from "../../utils/scrollers-observer"
812

913
const EcosystemBoardRoot = styled(`div`)`
1014
display: flex;
@@ -21,68 +25,12 @@ const EcosystemBoardRoot = styled(`div`)`
2125
`
2226

2327
class EcosystemBoard extends Component {
24-
observer
25-
observerTargets = []
26-
2728
componentDidMount() {
28-
if (typeof window.IntersectionObserver !== `undefined`) {
29-
this.setupObserver()
30-
}
29+
setupScrollersObserver()
3130
}
3231

3332
componentWillUnmount() {
34-
if (typeof window.IntersectionObserver !== `undefined`) {
35-
this.observerTargets.forEach(target => this.observer.unobserve(target))
36-
}
37-
}
38-
39-
setupObserver = () => {
40-
const options = { rootMargin: `0px`, threshold: [1] }
41-
this.observer = new IntersectionObserver(this.handleIntersect, options)
42-
this.observerTargets = Array.from(
43-
document.querySelectorAll(`.featuredItems`)
44-
)
45-
46-
this.observerTargets.forEach(target => this.observer.observe(target))
47-
}
48-
49-
handleIntersect = (entries, observer) => {
50-
entries.forEach(entry => {
51-
const target = entry.target
52-
53-
if (entry.intersectionRatio > 0) {
54-
setTimeout(
55-
() => this.turnOnLeadScroll({ target, duration: 1000, distance: 20 }),
56-
250
57-
)
58-
this.observer.unobserve(target)
59-
}
60-
})
61-
}
62-
63-
turnOnLeadScroll = ({ target, duration, distance }) => {
64-
let startTime = null
65-
66-
function animation(currentTime) {
67-
if (startTime === null) {
68-
startTime = currentTime
69-
}
70-
71-
const timeElapsed = currentTime - startTime
72-
const getDistanceToScroll = ease(timeElapsed, 0, distance, duration)
73-
74-
target.scroll({ top: 0, left: getDistanceToScroll })
75-
76-
if (timeElapsed < duration) {
77-
requestAnimationFrame(animation)
78-
}
79-
}
80-
81-
function ease(t, b, c, d) {
82-
return -c * (t /= d) * (t - 2) + b
83-
}
84-
85-
requestAnimationFrame(animation)
33+
unobserveScrollers()
8634
}
8735

8836
render() {
@@ -102,11 +50,11 @@ class EcosystemBoard extends Component {
10250
links={[
10351
{ label: `Browse Plugins`, to: `/plugins/` },
10452
{
105-
label: `Plugin Authoring`,
53+
label: `Creating Plugins`,
10654
to: `/docs/plugin-authoring/`,
10755
secondary: true,
10856
},
109-
{ label: `Plugin Docs`, to: `/docs/plugins/`, secondary: true },
57+
{ label: `Using Plugins`, to: `/docs/plugins/`, secondary: true },
11058
]}
11159
featuredItems={plugins}
11260
/>
@@ -117,7 +65,7 @@ class EcosystemBoard extends Component {
11765
icon={StartersIcon}
11866
links={[
11967
{ label: `Browse Starters`, to: `/starters/` },
120-
{ label: `Starter Docs`, to: `/docs/starters/`, secondary: true },
68+
{ label: `Using Starters`, to: `/docs/starters/`, secondary: true },
12169
]}
12270
featuredItems={starters}
12371
/>

www/src/components/ecosystem/ecosystem-featured-item.js

+22-12
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,26 @@ import presets, { colors } from "../../utils/presets"
1313
const MAX_DESCRIPTION_LENGTH = 100
1414

1515
const EcosystemFeaturedItemRoot = styled(`li`)`
16-
flex-basis: ${props => `calc(100% / ${props.numberOfItems})`};
17-
float: left;
16+
width: 85vw;
1817
margin: 0 2px 0 0;
1918
padding: 5px;
2019
20+
:last-child {
21+
margin-right: 0;
22+
}
23+
2124
${presets.Tablet} {
22-
padding: 0;
2325
border-bottom: 1px solid ${colors.gray.superLight};
26+
margin: 0;
27+
padding: 0;
28+
width: auto;
2429
}
2530
`
2631

27-
const BlockLink = styled(Link)`
32+
export const BlockLink = styled(Link)`
33+
background: #fff;
2834
border-radius: ${presets.radiusLg}px;
29-
box-shadow: 0 1px 8px rgba(0, 0, 0, 0.2);
35+
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
3036
display: flex;
3137
flex-direction: column;
3238
height: 100%;
@@ -37,28 +43,33 @@ const BlockLink = styled(Link)`
3743
box-shadow: none;
3844
transition: all ${presets.animation.speedDefault}
3945
${presets.animation.curveDefault};
46+
}
4047
48+
${presets.Desktop} {
4149
:hover {
4250
background: ${colors.ui.whisper};
4351
}
4452
}
4553
`
4654

4755
const Header = styled(`header`)`
56+
align-items: flex-start;
4857
display: flex;
4958
justify-content: space-between;
59+
5060
h3 {
5161
color: ${colors.gatsbyDark};
5262
font-size: 1rem;
5363
margin: 0;
5464
}
5565
5666
span {
67+
align-items: center;
5768
color: ${colors.lilac};
5869
display: flex;
59-
align-items: center;
6070
font-size: 0.8125rem;
6171
font-family: ${options.systemFontFamily.join(`,`)};
72+
padding-left: 5px;
6273
6374
svg {
6475
fill: ${colors.gray.light};
@@ -72,16 +83,15 @@ const Header = styled(`header`)`
7283
const Digest = styled(`div`)`
7384
display: flex;
7485
flex-grow: 1;
75-
justify-content: space-between;
76-
height: 100%;
7786
font-family: ${options.systemFontFamily.join(`,`)};
87+
justify-content: space-between;
7888
padding: ${rhythm(0.5)} 0 0;
7989
`
8090

8191
const Thumbnail = styled(`div`)`
92+
height: 64px;
8293
padding-right: ${rhythm(2 / 3)};
8394
margin-top: ${rhythm(1 / 12)};
84-
height: 64px;
8595
8696
img {
8797
border: 1px solid ${colors.gray.superLight};
@@ -95,7 +105,7 @@ const Description = styled(`p`)`
95105
margin: 0;
96106
`
97107

98-
const EcosystemFeaturedItem = ({ item, numberOfItems }) => {
108+
const EcosystemFeaturedItem = ({ item, className }) => {
99109
const {
100110
slug,
101111
name,
@@ -114,7 +124,7 @@ const EcosystemFeaturedItem = ({ item, numberOfItems }) => {
114124
}
115125

116126
return (
117-
<EcosystemFeaturedItemRoot numberOfItems={numberOfItems}>
127+
<EcosystemFeaturedItemRoot className={className}>
118128
<BlockLink to={slug}>
119129
<Header>
120130
<h3>{name}</h3>
@@ -145,7 +155,7 @@ const EcosystemFeaturedItem = ({ item, numberOfItems }) => {
145155

146156
EcosystemFeaturedItem.propTypes = {
147157
item: PropTypes.object.isRequired,
148-
numberOfItems: PropTypes.number.isRequired,
158+
className: PropTypes.string,
149159
}
150160

151161
export default EcosystemFeaturedItem

www/src/components/ecosystem/ecosystem-featured-items.js

+19-17
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ import React from "react"
22
import PropTypes from "prop-types"
33
import styled from "react-emotion"
44

5-
import EcosystemFeaturedItem from "./ecosystem-featured-item"
6-
75
import presets, { colors } from "../../utils/presets"
86
import { rhythm, options } from "../../utils/typography"
97
import { scrollbarStyles } from "../../utils/styles"
8+
import { SCROLLER_CLASSNAME } from "../../utils/scrollers-observer"
109

11-
const EcosystemFeaturedItemsRoot = styled(`div`)`
10+
export const EcosystemFeaturedItemsRootBase = styled(`div`)`
1211
overflow-x: scroll;
1312
margin: ${rhythm(0.1)} -${rhythm(options.blockMarginBottom)};
1413
-webkit-overflow-scrolling: touch;
14+
`
1515

16+
const EcosystemFeaturedItemsRoot = styled(EcosystemFeaturedItemsRootBase)`
1617
${presets.Tablet} {
1718
border-top: 1px solid ${colors.gray.superLight};
1819
margin-top: ${rhythm(0.4)};
@@ -23,39 +24,40 @@ const EcosystemFeaturedItemsRoot = styled(`div`)`
2324
}
2425
`
2526

26-
const List = styled(`ul`)`
27-
display: flex;
27+
export const ListBase = styled(`ul`)`
28+
display: inline-flex;
2829
list-style: none;
2930
margin: 0;
3031
padding: 0 calc(${rhythm(options.blockMarginBottom)} - 5px) 4px;
31-
width: ${props => `calc(80vw * ${props.numberOfItems})`};
32+
`
3233

34+
const List = styled(ListBase)`
3335
${presets.Tablet} {
3436
flex-direction: column;
3537
padding: 0;
3638
width: 100%;
3739
}
3840
`
3941

40-
const EcosystemFeaturedItems = ({ items }) => (
41-
<EcosystemFeaturedItemsRoot className="featuredItems">
42-
<List numberOfItems={items.length}>
42+
const EcosystemFeaturedItems = ({
43+
items,
44+
itemComponent: Item,
45+
className = ``,
46+
}) => (
47+
<EcosystemFeaturedItemsRoot className={`${SCROLLER_CLASSNAME} ${className}`}>
48+
<List>
4349
{items.map(item => {
4450
const { slug } = item
45-
return (
46-
<EcosystemFeaturedItem
47-
key={slug}
48-
item={item}
49-
numberOfItems={items.length}
50-
/>
51-
)
51+
return <Item key={slug} item={item} />
5252
})}
5353
</List>
5454
</EcosystemFeaturedItemsRoot>
5555
)
5656

5757
EcosystemFeaturedItems.propTypes = {
58-
items: PropTypes.array,
58+
items: PropTypes.array.isRequired,
59+
itemComponent: PropTypes.func.isRequired,
60+
className: PropTypes.string,
5961
}
6062

6163
export default EcosystemFeaturedItems

0 commit comments

Comments
 (0)