refactor: remove unnecessary edge case handling
This commit is contained in:
parent
db05a792df
commit
a3c0990804
1 changed files with 3 additions and 11 deletions
|
@ -6,33 +6,25 @@ interface BadgeProps {
|
||||||
slug: string
|
slug: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const sharedBadgeStyles = "flex w-fit items-center px-2 py-1 text-xs"
|
|
||||||
const sharedInnerBadgeStyles = "badge mr-1 inline-block w-6 align-middle"
|
|
||||||
|
|
||||||
export default async function Badge({ slug }: BadgeProps) {
|
export default async function Badge({ slug }: BadgeProps) {
|
||||||
const badgeData: BadgeType = await import(
|
const badgeData: BadgeType = await import(
|
||||||
`@developomp-site/content/dist/icons/${slug}.json`
|
`@developomp-site/content/dist/icons/${slug}.json`
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!badgeData)
|
if (!badgeData)
|
||||||
return (
|
throw `"@developomp-site/content/dist/icons/${slug}.json" does not exist`
|
||||||
<div className={sharedBadgeStyles}>
|
|
||||||
<div className={sharedInnerBadgeStyles} />
|
|
||||||
<span>Loading...</span>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{ backgroundColor: badgeData.hex }}
|
style={{ backgroundColor: badgeData.hex }}
|
||||||
className={`${sharedBadgeStyles} ${
|
className={`flex w-fit items-center px-2 py-1 text-xs ${
|
||||||
badgeData.isDark
|
badgeData.isDark
|
||||||
? "text-dark-text-default"
|
? "text-dark-text-default"
|
||||||
: "text-light-text-default"
|
: "text-light-text-default"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={`${sharedInnerBadgeStyles} ${
|
className={`badge mr-1 inline-block w-6 align-middle ${
|
||||||
badgeData.isDark ? "dark-badge" : "light-badge"
|
badgeData.isDark ? "dark-badge" : "light-badge"
|
||||||
}`}
|
}`}
|
||||||
dangerouslySetInnerHTML={{ __html: badgeData.svg }}
|
dangerouslySetInnerHTML={{ __html: badgeData.svg }}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue