feat(ui): add TagGroup component

Introduces a new `TagGroup` component for rendering grouped tags with optional inverted styling.
This commit is contained in:
Brian McGee
2025-06-20 09:49:59 +01:00
parent 1b5d2bc538
commit 57c77e039d
3 changed files with 67 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
div.tag-group {
@apply flex flex-wrap gap-x-1.5 gap-y-2;
}

View File

@@ -0,0 +1,43 @@
import { TagGroup, TagGroupProps } from "@/src/components/v2/TagGroup/TagGroup";
import { Meta, StoryObj } from "@kachurun/storybook-solid";
const meta: Meta<TagGroupProps> = {
title: "Components/TagGroup",
component: TagGroup,
decorators: [
(Story: StoryObj) => (
/* for some reason w-x from tailwind was not working */
<div style="width: 196px">
<Story />
</div>
),
],
};
export default meta;
type Story = StoryObj<TagGroupProps>;
export const Default: Story = {
args: {
labels: [
"Tag 1",
"Tag 2",
"Tag 3",
"Tag 4",
"Tag 5",
"Tag 6",
"Tag 7",
"Tag 8",
"Tag 9",
"Tag 10",
],
},
};
export const Inverted: Story = {
args: {
...Default.args,
inverted: true,
},
};

View File

@@ -0,0 +1,21 @@
import "./TagGroup.css";
import cx from "classnames";
import { For } from "solid-js";
import { Tag } from "@/src/components/v2/Tag/Tag";
export interface TagGroupProps {
labels: string[];
inverted?: boolean;
}
export const TagGroup = (props: TagGroupProps) => {
const inverted = () => props.inverted || false;
return (
<div class={cx("tag-group", { inverted: inverted() })}>
<For each={props.labels}>
{(label) => <Tag label={label} inverted={inverted()} />}
</For>
</div>
);
};