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: add caption to user links #1075

Merged
merged 4 commits into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 0 deletions v1/lib/core/CompLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
const MarkdownBlock = require('./MarkdownBlock.js');
const Container = require('./Container.js');
const GridBlock = require('./GridBlock.js');
const Showcase = require('./Showcase.js');
goksu marked this conversation as resolved.
Show resolved Hide resolved

// A collection of components to provide to users
module.exports = {
MarkdownBlock,
Container,
GridBlock,
Showcase,
};
51 changes: 51 additions & 0 deletions v1/lib/core/Showcase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* 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');

class UserLink extends React.Component {
goksu marked this conversation as resolved.
Show resolved Hide resolved
render() {
const {infoLink, image, caption} = this.props;

return (
<a className="link" href={infoLink} key={infoLink}>
<img src={image} alt={caption} title={caption} />
<span className="caption">{caption}</span>
</a>
);
}
}

UserLink.propTypes = {
infoLink: PropTypes.string.isRequired,
image: PropTypes.string.isRequired,
caption: PropTypes.string.isRequired,
};

class Showcase extends React.Component {
goksu marked this conversation as resolved.
Show resolved Hide resolved
render() {
const {users} = this.props;
return (
<div className="showcase">
{users.map(user => (
<UserLink key={user.infoLink} {...user} />
))}
</div>
);
}
}

Showcase.propTypes = {
users: PropTypes.array.isRequired,
};

Showcase.defaultProps = {
users: [],
};

module.exports = Showcase;
54 changes: 28 additions & 26 deletions v1/lib/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -2173,29 +2173,52 @@ input::placeholder {
padding: 0.8em 0;
}

.productShowcaseSection .logos {
/* Start of Showcase */
.showcase {
align-items: center;
display: flex;
flex-flow: row wrap;
justify-content: center;
padding: 20px;
margin-bottom: 20px;
}

.productShowcaseSection .logos img {
.showcase .link {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 170px;
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) {
.productShowcaseSection .logos img {
.showcase .link {
height: 134px;
}

.showcase .link img {
max-height: 64px;
padding: 20px;
width: 64px;
}
}

/* Start of Showcase */
.showcaseSection {
margin: 0 auto;
max-width: 900px;
Expand All @@ -2211,27 +2234,6 @@ input::placeholder {
max-width: 560px;
text-align: center;
}

.showcaseSection .logos {
align-items: center;
display: flex;
flex-flow: row wrap;
justify-content: center;
}

.showcaseSection .logos img {
max-height: 128px;
padding: 20px;
width: 128px;
}

@media only screen and (max-width: 735px) {
.showcaseSection .logos img {
max-height: 64px;
padding: 20px;
width: 64px;
}
}
/* End of Showcase */

/* Start of Footer */
Expand Down
9 changes: 3 additions & 6 deletions v1/website/pages/en/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const CompLibrary = require('../../core/CompLibrary.js');

const Container = CompLibrary.Container;
const GridBlock = CompLibrary.GridBlock;
const Showcase = CompLibrary.Showcase;
const siteConfig = require(`${process.cwd()}/siteConfig.js`);
const translate = require('../../server/translate.js').translate;

Expand Down Expand Up @@ -74,11 +75,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 => (
<a href={user.infoLink} key={user.infoLink}>
<img src={user.image} alt={user.caption} title={user.caption} />
</a>
));
const pinnedUsersToShowcase = siteConfig.users.filter(user => user.pinned);

return (
<div>
Expand Down Expand Up @@ -234,7 +231,7 @@ class Index extends React.Component {
Docusaurus is building websites for these projects...
</translate>
</p>
<div className="logos">{showcase}</div>
<Showcase users={pinnedUsersToShowcase} />
<div className="more-users">
<a
className="button"
Expand Down
31 changes: 16 additions & 15 deletions v1/website/pages/en/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,27 @@ const React = require('react');
const CompLibrary = require('../../core/CompLibrary.js');

const Container = CompLibrary.Container;
const Showcase = CompLibrary.Showcase;
const siteConfig = require(`${process.cwd()}/siteConfig.js`);
const translate = require('../../server/translate.js').translate;

class Users extends React.Component {
renderUser(user) {
return (
<a href={user.infoLink} key={user.infoLink}>
<img src={user.image} alt={user.caption} title={user.caption} />
</a>
);
getUsersToShowcase() {
goksu marked this conversation as resolved.
Show resolved Hide resolved
const fbUsersToShowcase = [];
const restToShowcase = [];
siteConfig.users.forEach(user => {
if (user.fbOpenSource) fbUsersToShowcase.push(user);
else restToShowcase.push(user);
});

return {
fbUsersToShowcase,
restToShowcase,
};
}

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, restToShowcase} = this.getUsersToShowcase();

return (
<div className="mainContainer">
Expand All @@ -46,15 +47,15 @@ class Users extends React.Component {
.
</p>
</div>
<div className="logos">{fbShowcase}</div>
<Showcase users={fbUsersToShowcase} />
<div className="prose">
<p>
<translate>
Docusaurus is also used by open source projects of all sizes.
</translate>
</p>
</div>
<div className="logos">{showcase}</div>
<Showcase users={restToShowcase} />
<div className="prose">
<p>
<translate>Is your project using Docusaurus?</translate>
Expand Down