From 3250662e7378eba67c1e6533acd7fb78bfbb4a46 Mon Sep 17 00:00:00 2001 From: Goksu Toprak Date: Fri, 2 Nov 2018 10:20:25 -0700 Subject: [PATCH] feat: add caption to user links (#1075) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add caption to users links created a shared component `Showcase` * Cleans linter * revert main.css changes — update custom.css * Move Showcase comp to website out of lib - fix layout --- v1/website/core/Showcase.js | 40 ++++++++++++++++++++++++++++ v1/website/pages/en/index.js | 10 +++---- v1/website/pages/en/users.js | 24 +++++------------ v1/website/static/css/custom.css | 45 ++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 23 deletions(-) create mode 100644 v1/website/core/Showcase.js diff --git a/v1/website/core/Showcase.js b/v1/website/core/Showcase.js new file mode 100644 index 000000000000..55cc63b33fb4 --- /dev/null +++ b/v1/website/core/Showcase.js @@ -0,0 +1,40 @@ +/** + * 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 PropTypes = require('prop-types'); + +const UserLink = ({infoLink, image, caption}) => ( + + {caption} + {caption} + +); + +UserLink.propTypes = { + infoLink: PropTypes.string.isRequired, + image: PropTypes.string.isRequired, + caption: PropTypes.string.isRequired, +}; + +const Showcase = ({users}) => ( +
+ {users.map(user => ( + + ))} +
+); + +Showcase.propTypes = { + users: PropTypes.array.isRequired, +}; + +Showcase.defaultProps = { + users: [], +}; + +module.exports = Showcase; diff --git a/v1/website/pages/en/index.js b/v1/website/pages/en/index.js index 65519b6a9bf8..0fd8ff5ed677 100755 --- a/v1/website/pages/en/index.js +++ b/v1/website/pages/en/index.js @@ -6,10 +6,12 @@ */ const React = require('react'); + const CompLibrary = require('../../core/CompLibrary.js'); const Container = CompLibrary.Container; const GridBlock = CompLibrary.GridBlock; +const Showcase = require(`${process.cwd()}/core/Showcase.js`); const siteConfig = require(`${process.cwd()}/siteConfig.js`); const translate = require('../../server/translate.js').translate; @@ -74,11 +76,7 @@ class HomeSplash extends React.Component { class Index extends React.Component { render() { const language = this.props.language || 'en'; - const showcase = siteConfig.users.filter(user => user.pinned).map(user => ( - - {user.caption} - - )); + const pinnedUsersToShowcase = siteConfig.users.filter(user => user.pinned); return (
@@ -234,7 +232,7 @@ class Index extends React.Component { Docusaurus is building websites for these projects...

-
{showcase}
+
- {user.caption} - - ); - } - render() { - const fbShowcase = siteConfig.users - .filter(user => user.fbOpenSource) - .map((user, i) => this.renderUser(user, i)); - - const showcase = siteConfig.users - .filter(user => !user.fbOpenSource) - .map((user, i) => this.renderUser(user, i)); + const fbUsersToShowcase = siteConfig.users.filter( + user => user.fbOpenSource, + ); + const restToShowcase = siteConfig.users.filter(user => !user.fbOpenSource); return (
@@ -46,7 +36,7 @@ class Users extends React.Component { .

-
{fbShowcase}
+

@@ -54,7 +44,7 @@ class Users extends React.Component {

-
{showcase}
+

Is your project using Docusaurus? diff --git a/v1/website/static/css/custom.css b/v1/website/static/css/custom.css index 3356af39ee28..63660eb610aa 100644 --- a/v1/website/static/css/custom.css +++ b/v1/website/static/css/custom.css @@ -12,3 +12,48 @@ table td:first-child > code { white-space: nowrap; } + +.showcase { + align-items: center; + display: flex; + flex-flow: row wrap; + justify-content: center; + margin-bottom: 20px; +} + +.showcase .link { + display: flex; + flex-direction: column; + justify-content: space-between; + height: 180px; + margin: 5px; + padding: 5px; +} + +.showcase .link:hover { + text-decoration: underline; +} + +.showcase .link .caption { + line-height: 20px; + height: 20px; +} + +.showcase .link img { + max-height: 110px; + padding: 20px; + width: 110px; + align-self: center; +} + +@media only screen and (max-width: 735px) { + .showcase .link { + height: 134px; + } + + .showcase .link img { + max-height: 64px; + padding: 20px; + width: 64px; + } +}