Skip to content

Commit

Permalink
validate patch images put at to level
Browse files Browse the repository at this point in the history
  • Loading branch information
leoigel committed Aug 8, 2020
1 parent fb6bd21 commit f3b2269
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions website-1.x/core/Showcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@

const React = require('react');
const PropTypes = require('prop-types');
const users = require('../data/users');

users.forEach((user) => {
if (!user.image.startsWith('/img/users')) {
throw new Error(
`User image should be self-hosted in /img/users folder. This was not the case for ${user.image}`,
);
}
});
const UserLink = ({infoLink, image, caption}) => (
<a className="link" href={infoLink} key={infoLink}>
<img src={image} alt={caption} title={caption} />
Expand All @@ -21,23 +29,13 @@ UserLink.propTypes = {
caption: PropTypes.string.isRequired,
};

const Showcase = ({users}) => {
users.forEach((user) => {
if (!user.image.startsWith('/img/users')) {
throw new Error(
'User image should be self-hosted in /img/users folder. This was not the case for ' +
user.image,
);
}
});
return (
<div className="showcase">
{users.map((user) => (
<UserLink key={user.infoLink} {...user} />
))}
</div>
);
};
const Showcase = ({users}) => (
<div className="showcase">
{users.map((user) => (
<UserLink key={user.infoLink} {...user} />
))}
</div>
);

Showcase.propTypes = {
users: PropTypes.array.isRequired,
Expand Down

0 comments on commit f3b2269

Please sign in to comment.