Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(www): add Ecosystem section to Homepage #9783

Merged
merged 18 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion www/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ exports.onCreateNode = ({ node, actions, getNode, reporter }) => {

exports.onCreatePage = ({ page, actions }) => {
// add lists of featured items to Ecosystem page
if (page.path === `/ecosystem/`) {
if (page.path === `/ecosystem/` || page.path === `/`) {
const { createPage, deletePage } = actions
const oldPage = Object.assign({}, page)

Expand Down
2 changes: 1 addition & 1 deletion www/src/assets/ecosystem.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions www/src/components/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const Button = ({
small,
tiny,
secondary,
ondark,
...rest
}) => {
const Tag = components[tag || `link`]
Expand All @@ -36,6 +37,7 @@ const Button = ({
...(large && buttonStyles.large),
...(small && buttonStyles.small),
...(tiny && buttonStyles.tiny),
...(ondark && buttonStyles.ondark),
},
}

Expand Down
1 change: 1 addition & 0 deletions www/src/components/cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const Cards = ({ children }) => (
borderRadius: presets.radiusLg,
boxShadow: `0 5px 20px rgba(25, 17, 34, 0.1)`,
transform: `translateZ(0)`,
width: `100%`,
}}
>
{children}
Expand Down
70 changes: 9 additions & 61 deletions www/src/components/ecosystem/ecosystem-board.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import styled from "react-emotion"
import EcosystemSection from "./ecosystem-section"

import presets from "../../utils/presets"
import {
setupScrollersObserver,
unobserveScrollers,
} from "../../utils/scrollers-observer"

const EcosystemBoardRoot = styled(`div`)`
display: flex;
Expand All @@ -21,68 +25,12 @@ const EcosystemBoardRoot = styled(`div`)`
`

class EcosystemBoard extends Component {
observer
observerTargets = []

componentDidMount() {
if (typeof window.IntersectionObserver !== `undefined`) {
this.setupObserver()
}
setupScrollersObserver()
}

componentWillUnmount() {
if (typeof window.IntersectionObserver !== `undefined`) {
this.observerTargets.forEach(target => this.observer.unobserve(target))
}
}

setupObserver = () => {
const options = { rootMargin: `0px`, threshold: [1] }
this.observer = new IntersectionObserver(this.handleIntersect, options)
this.observerTargets = Array.from(
document.querySelectorAll(`.featuredItems`)
)

this.observerTargets.forEach(target => this.observer.observe(target))
}

handleIntersect = (entries, observer) => {
entries.forEach(entry => {
const target = entry.target

if (entry.intersectionRatio > 0) {
setTimeout(
() => this.turnOnLeadScroll({ target, duration: 1000, distance: 20 }),
250
)
this.observer.unobserve(target)
}
})
}

turnOnLeadScroll = ({ target, duration, distance }) => {
let startTime = null

function animation(currentTime) {
if (startTime === null) {
startTime = currentTime
}

const timeElapsed = currentTime - startTime
const getDistanceToScroll = ease(timeElapsed, 0, distance, duration)

target.scroll({ top: 0, left: getDistanceToScroll })

if (timeElapsed < duration) {
requestAnimationFrame(animation)
}
}

function ease(t, b, c, d) {
return -c * (t /= d) * (t - 2) + b
}

requestAnimationFrame(animation)
unobserveScrollers()
}

render() {
Expand All @@ -102,11 +50,11 @@ class EcosystemBoard extends Component {
links={[
{ label: `Browse Plugins`, to: `/plugins/` },
{
label: `Plugin Authoring`,
label: `Creating Plugins`,
to: `/docs/plugin-authoring/`,
secondary: true,
},
{ label: `Plugin Docs`, to: `/docs/plugins/`, secondary: true },
{ label: `Using Plugins`, to: `/docs/plugins/`, secondary: true },
]}
featuredItems={plugins}
/>
Expand All @@ -117,7 +65,7 @@ class EcosystemBoard extends Component {
icon={StartersIcon}
links={[
{ label: `Browse Starters`, to: `/starters/` },
{ label: `Starter Docs`, to: `/docs/starters/`, secondary: true },
{ label: `Using Starters`, to: `/docs/starters/`, secondary: true },
]}
featuredItems={starters}
/>
Expand Down
29 changes: 19 additions & 10 deletions www/src/components/ecosystem/ecosystem-featured-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ const MAX_DESCRIPTION_LENGTH = 100

const EcosystemFeaturedItemRoot = styled(`li`)`
flex-basis: ${props => `calc(100% / ${props.numberOfItems})`};
float: left;
margin: 0 2px 0 0;
padding: 5px;

${presets.Tablet} {
padding: 0;
border-bottom: 1px solid ${colors.gray.superLight};
margin: 0;
padding: 0;
}
`

const BlockLink = styled(Link)`
export const BlockLink = styled(Link)`
background: #fff;
border-radius: ${presets.radiusLg}px;
box-shadow: 0 1px 8px rgba(0, 0, 0, 0.2);
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
height: 100%;
Expand All @@ -37,28 +38,33 @@ const BlockLink = styled(Link)`
box-shadow: none;
transition: all ${presets.animation.speedDefault}
${presets.animation.curveDefault};
}

${presets.Desktop} {
:hover {
background: ${colors.ui.whisper};
}
}
`

const Header = styled(`header`)`
align-items: flex-start;
display: flex;
justify-content: space-between;

h3 {
color: ${colors.gatsbyDark};
font-size: 1rem;
margin: 0;
}

span {
align-items: center;
color: ${colors.lilac};
display: flex;
align-items: center;
font-size: 0.8125rem;
font-family: ${options.systemFontFamily.join(`,`)};
padding-left: 5px;

svg {
fill: ${colors.gray.light};
Expand All @@ -72,16 +78,15 @@ const Header = styled(`header`)`
const Digest = styled(`div`)`
display: flex;
flex-grow: 1;
justify-content: space-between;
height: 100%;
font-family: ${options.systemFontFamily.join(`,`)};
justify-content: space-between;
padding: ${rhythm(0.5)} 0 0;
`

const Thumbnail = styled(`div`)`
height: 64px;
padding-right: ${rhythm(2 / 3)};
margin-top: ${rhythm(1 / 12)};
height: 64px;

img {
border: 1px solid ${colors.gray.superLight};
Expand All @@ -95,7 +100,7 @@ const Description = styled(`p`)`
margin: 0;
`

const EcosystemFeaturedItem = ({ item, numberOfItems }) => {
const EcosystemFeaturedItem = ({ item, numberOfItems, className }) => {
const {
slug,
name,
Expand All @@ -114,7 +119,10 @@ const EcosystemFeaturedItem = ({ item, numberOfItems }) => {
}

return (
<EcosystemFeaturedItemRoot numberOfItems={numberOfItems}>
<EcosystemFeaturedItemRoot
numberOfItems={numberOfItems}
className={className}
>
<BlockLink to={slug}>
<Header>
<h3>{name}</h3>
Expand Down Expand Up @@ -146,6 +154,7 @@ const EcosystemFeaturedItem = ({ item, numberOfItems }) => {
EcosystemFeaturedItem.propTypes = {
item: PropTypes.object.isRequired,
numberOfItems: PropTypes.number.isRequired,
className: PropTypes.string,
}

export default EcosystemFeaturedItem
33 changes: 18 additions & 15 deletions www/src/components/ecosystem/ecosystem-featured-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import React from "react"
import PropTypes from "prop-types"
import styled from "react-emotion"

import EcosystemFeaturedItem from "./ecosystem-featured-item"

import presets, { colors } from "../../utils/presets"
import { rhythm, options } from "../../utils/typography"
import { scrollbarStyles } from "../../utils/styles"
import { SCROLLER_CLASSNAME } from "../../utils/scrollers-observer"

const EcosystemFeaturedItemsRoot = styled(`div`)`
export const EcosystemFeaturedItemsRootBase = styled(`div`)`
overflow-x: scroll;
margin: ${rhythm(0.1)} -${rhythm(options.blockMarginBottom)};
-webkit-overflow-scrolling: touch;
`

const EcosystemFeaturedItemsRoot = styled(EcosystemFeaturedItemsRootBase)`
${presets.Tablet} {
border-top: 1px solid ${colors.gray.superLight};
margin-top: ${rhythm(0.4)};
Expand All @@ -23,39 +24,41 @@ const EcosystemFeaturedItemsRoot = styled(`div`)`
}
`

const List = styled(`ul`)`
export const ListBase = styled(`ul`)`
display: flex;
list-style: none;
margin: 0;
padding: 0 calc(${rhythm(options.blockMarginBottom)} - 5px) 4px;
width: ${props => `calc(80vw * ${props.numberOfItems})`};
width: ${props => `calc(85vw * ${props.numberOfItems})`};
`

const List = styled(ListBase)`
${presets.Tablet} {
flex-direction: column;
padding: 0;
width: 100%;
}
`

const EcosystemFeaturedItems = ({ items }) => (
<EcosystemFeaturedItemsRoot className="featuredItems">
const EcosystemFeaturedItems = ({
items,
itemComponent: Item,
className = ``,
}) => (
<EcosystemFeaturedItemsRoot className={`${SCROLLER_CLASSNAME} ${className}`}>
<List numberOfItems={items.length}>
{items.map(item => {
const { slug } = item
return (
<EcosystemFeaturedItem
key={slug}
item={item}
numberOfItems={items.length}
/>
)
return <Item key={slug} item={item} numberOfItems={items.length} />
})}
</List>
</EcosystemFeaturedItemsRoot>
)

EcosystemFeaturedItems.propTypes = {
items: PropTypes.array,
items: PropTypes.array.isRequired,
itemComponent: PropTypes.func.isRequired,
className: PropTypes.string,
}

export default EcosystemFeaturedItems
Loading