Skip to content

Commit c8990c2

Browse files
feat: richer empty states (#239)
* feat(alerts): tabs for filtering table * fix: header spacing bug * feat: richer empty states * refactor: tidy up pattern matching * chore: tidy ups * fix: tests
1 parent 9c11e42 commit c8990c2

12 files changed

+780
-286
lines changed

package-lock.json

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"tailwind-merge": "^2.5.5",
4545
"tailwind-variants": "^0.3.0",
4646
"tailwindcss-animate": "^1.0.7",
47+
"ts-pattern": "^5.6.2",
4748
"zod": "^3.24.1",
4849
"zustand": "^5.0.3"
4950
},

src/components/empty-state.tsx

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Heading } from "@stacklok/ui-kit";
2+
import { JSX, ReactNode, SVGProps } from "react";
3+
import { tv } from "tailwind-variants";
4+
5+
const actionsStyle = tv({
6+
base: "mx-auto mt-8",
7+
variants: {
8+
actions: {
9+
1: "",
10+
2: "grid grid-cols-2 gap-2",
11+
},
12+
},
13+
});
14+
15+
export function Actions({ actions }: { actions: [ReactNode, ReactNode?] }) {
16+
return (
17+
<div className={actionsStyle({ actions: actions.length })}>{actions}</div>
18+
);
19+
}
20+
21+
export function EmptyState({
22+
actions,
23+
body,
24+
illustration: Illustration,
25+
title,
26+
}: {
27+
illustration: (props: SVGProps<SVGSVGElement>) => JSX.Element;
28+
title: string;
29+
body: string;
30+
actions: [ReactNode, ReactNode?] | null;
31+
}) {
32+
return (
33+
<div className="max-w-[40rem] mx-auto py-20 flex items-center flex-col text-center text-balance">
34+
<Illustration className="size-28" />
35+
<Heading level={4} className="font-bold text-gray-900 mb-2">
36+
{title}
37+
</Heading>
38+
<p>{body}</p>
39+
{actions ? <Actions actions={actions} /> : null}
40+
</div>
41+
);
42+
}

0 commit comments

Comments
 (0)