Skip to content

Commit

Permalink
Astro/Fix Tag Component (#1188)
Browse files Browse the repository at this point in the history
Fix Tag component:
- so hrefs work.
- uses the correct 'nix blue' value.
- so the background fits the contents. Without the `w-fit` class it
looks like the bottom tag instead of the top.

![Screenshot 2023-12-08 at 19-46-50
Explore](https://github.com/NixOS/nixos-homepage/assets/7043297/3a608302-d025-4625-b786-43cec87c45e4)
  • Loading branch information
djacu authored Dec 9, 2023
1 parent 72a95e2 commit e87a27b
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/components/ui/Tag.astro
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
---
interface Props {
color?: "orange" | "darkgreen" | "lightblue" | "semidarkblue";
color?: "orange" | "darkgreen" | "lightblue" | "darkblue";
classList?: string[];
href?: string | null;
}
const colorMap = {
"orange": "bg-nixorange",
"lightblue": "bg-nixlightblue",
"semidarkblue": "bg-nixsemidarkblue",
"darkblue": "bg-nixdarkblue",
"darkgreen": "bg-nixdarkgreen"
}
const {
color = "semidarkblue",
color = "darkblue",
classList = [],
href = null,
} = Astro.props;
const localClassList = `${colorMap[color]} rounded-lg font-bold text-white text-sm px-[0.5rem] py-[0.25rem]`;
const localClassList = `${colorMap[color]} w-fit rounded-lg font-bold !text-white !no-underline text-sm px-[0.5rem] py-[0.25rem]`;
---

<span class:list={[localClassList, classList]}>
<slot/>
</span>
{href
?
<a href={href} class:list={[localClassList, classList]}>
<slot/>
</a>
:
<span href={href} class:list={[localClassList, classList]}>
<slot/>
</span>
}

0 comments on commit e87a27b

Please sign in to comment.