Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
41 changes: 41 additions & 0 deletions src/sections/Community/Handbook/BadgeRow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from "react";
import PropTypes from "prop-types";

const cell = { padding: "12px", verticalAlign: "middle" };
const badgeImg = { height: "50px", width: "50px", verticalAlign: "middle" };

const BadgeRow = ({ image, name, title, badgeKey, keycode, keyProp, description }) => {
const displayName = name || title || "—";
const displayKey = badgeKey || keycode || keyProp || "—";

return (
<tr>
<td style={cell}>
{typeof image === "string" ? (
<img src={image} style={badgeImg} alt={displayName} />
) : (
image
)}
</td>
<td style={cell}>
<b>{displayName}</b>
</td>
<td style={cell}>
<code>{displayKey}</code>
</td>
<td style={cell}>{description || "—"}</td>
</tr>
);
};

BadgeRow.propTypes = {
image: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
name: PropTypes.string,
title: PropTypes.string,
badgeKey: PropTypes.string,
keycode: PropTypes.string,
keyProp: PropTypes.string,
description: PropTypes.node,
};

export default BadgeRow;
57 changes: 57 additions & 0 deletions src/sections/Community/Handbook/badge-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from "react";
import PropTypes from "prop-types";

const imgStyle = {
height: "50px",
width: "50px",
verticalAlign: "middle",
marginRight: "1rem",
};


const BadgeItem = ({ title, description, image, href, to }) => {
const content = (
<>
{typeof image === "string" ? (
<img src={image} alt={title} style={imgStyle} />
) : (
image
)}
<b>{title}</b>
{description ? <> — {description}</> : null}
</>
);

if (href) {
return (
<li style={{ marginBottom: "0.5rem" }}>
<a href={href} target="_blank" rel="noopener noreferrer">
{content}
</a>
</li>
);
}

if (to) {
return (
<li style={{ marginBottom: "0.5rem" }}>
<a href={to}>{content}</a>
</li>
);
}

return <li style={{ marginBottom: "0.5rem" }}>{content}</li>;
};

BadgeItem.propTypes = {
title: PropTypes.string.isRequired,
description: PropTypes.node,
image: PropTypes.oneOfType([
PropTypes.string,
PropTypes.node,
]),
href: PropTypes.string,
to: PropTypes.string,
};

export default BadgeItem;
103 changes: 103 additions & 0 deletions src/sections/Community/Handbook/badges-data.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading