Skip to content

Commit 643cec1

Browse files
Merge pull request #7084 from KatalKavya96/feat/recognition-refactor-clean
fix: update recognition badges layout and data integration
2 parents 5db029f + 8293fd0 commit 643cec1

File tree

4 files changed

+299
-349
lines changed

4 files changed

+299
-349
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from "react";
2+
import PropTypes from "prop-types";
3+
4+
const cell = { padding: "12px", verticalAlign: "middle" };
5+
const badgeImg = { height: "50px", width: "50px", verticalAlign: "middle" };
6+
7+
const BadgeRow = ({ image, name, title, badgeKey, keycode, keyProp, description }) => {
8+
const displayName = name || title || "—";
9+
const displayKey = badgeKey || keycode || keyProp || "—";
10+
11+
return (
12+
<tr>
13+
<td style={cell}>
14+
{typeof image === "string" ? (
15+
<img src={image} style={badgeImg} alt={displayName} />
16+
) : (
17+
image
18+
)}
19+
</td>
20+
<td style={cell}>
21+
<b>{displayName}</b>
22+
</td>
23+
<td style={cell}>
24+
<code>{displayKey}</code>
25+
</td>
26+
<td style={cell}>{description || "—"}</td>
27+
</tr>
28+
);
29+
};
30+
31+
BadgeRow.propTypes = {
32+
image: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
33+
name: PropTypes.string,
34+
title: PropTypes.string,
35+
badgeKey: PropTypes.string,
36+
keycode: PropTypes.string,
37+
keyProp: PropTypes.string,
38+
description: PropTypes.node,
39+
};
40+
41+
export default BadgeRow;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from "react";
2+
import PropTypes from "prop-types";
3+
4+
const imgStyle = {
5+
height: "50px",
6+
width: "50px",
7+
verticalAlign: "middle",
8+
marginRight: "1rem",
9+
};
10+
11+
12+
const BadgeItem = ({ title, description, image, href, to }) => {
13+
const content = (
14+
<>
15+
{typeof image === "string" ? (
16+
<img src={image} alt={title} style={imgStyle} />
17+
) : (
18+
image
19+
)}
20+
<b>{title}</b>
21+
{description ? <>{description}</> : null}
22+
</>
23+
);
24+
25+
if (href) {
26+
return (
27+
<li style={{ marginBottom: "0.5rem" }}>
28+
<a href={href} target="_blank" rel="noopener noreferrer">
29+
{content}
30+
</a>
31+
</li>
32+
);
33+
}
34+
35+
if (to) {
36+
return (
37+
<li style={{ marginBottom: "0.5rem" }}>
38+
<a href={to}>{content}</a>
39+
</li>
40+
);
41+
}
42+
43+
return <li style={{ marginBottom: "0.5rem" }}>{content}</li>;
44+
};
45+
46+
BadgeItem.propTypes = {
47+
title: PropTypes.string.isRequired,
48+
description: PropTypes.node,
49+
image: PropTypes.oneOfType([
50+
PropTypes.string,
51+
PropTypes.node,
52+
]),
53+
href: PropTypes.string,
54+
to: PropTypes.string,
55+
};
56+
57+
export default BadgeItem;

src/sections/Community/Handbook/badges-data.js

Lines changed: 103 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)