Skip to content

Commit 7a90994

Browse files
committed
feat: color resource card based on remote connection type
1 parent aab9cf3 commit 7a90994

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/app/(outerbase)/local/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default function LocalConnectionPage() {
3838
id: conn.id,
3939
type: conn.content.driver,
4040
status: "",
41+
color: conn.content.label || "default",
4142
} as ResourceItemProps;
4243
});
4344
}, [localBases]);

src/app/(outerbase)/resource-item-helper.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Input } from "@/components/orbit/input";
22
import { MenuBar } from "@/components/orbit/menu-bar";
33
import ResourceCard from "@/components/resource-card";
44
import {
5+
getDatabaseColor,
56
getDatabaseFriendlyName,
67
getDatabaseIcon,
78
getDatabaseVisual,
@@ -36,6 +37,7 @@ export interface ResourceItemProps {
3637
href: string;
3738
status?: string;
3839
lastUsed: number;
40+
color?: string;
3941
}
4042

4143
export function getResourceItemPropsFromBase(
@@ -46,6 +48,7 @@ export function getResourceItemPropsFromBase(
4648
id: base.id,
4749
type: base.sources[0]?.type ?? "database",
4850
name: base.name,
51+
color: getDatabaseColor(base.sources[0]?.type ?? "database"),
4952
href: `/w/${workspace.short_name}/${base.short_name}`,
5053
lastUsed: base.last_analytics_event?.created_at
5154
? new Date(base.last_analytics_event?.created_at).getTime()
@@ -243,7 +246,7 @@ export function ResourceItemList({
243246
<ResourceCard
244247
key={resource.id}
245248
className="w-full"
246-
color="default"
249+
color={resource.color ?? "default"}
247250
icon={getDatabaseIcon(resource.type)}
248251
href={resource.href}
249252
title={resource.name}

src/components/resource-card/utils.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
PostgreIcon,
55
RqliteIcon,
66
SQLiteIcon,
7+
TursoIcon,
78
} from "../icons/outerbase-icon";
89
import { CloudflareIcon, StarbaseIcon, ValTownIcon } from "./icon";
910
import {
@@ -41,8 +42,9 @@ export function getDatabaseIcon(type: string) {
4142
if (type === "cloudflare" || type === "cloudflare-d1") return CloudflareIcon;
4243
if (type === "valtown") return ValTownIcon;
4344
if (type === "starbasedb" || type === "starbase") return StarbaseIcon;
44-
if (type === "libsql" || type === "turso") return SQLiteIcon;
45+
if (type === "libsql" || type === "turso") return TursoIcon;
4546
if (type === "rqlite") return RqliteIcon;
47+
if (type === "sqlite") return SQLiteIcon;
4648
if (type === "board") return ChartBar;
4749

4850
return Database;
@@ -56,3 +58,10 @@ export function getDatabaseVisual(type: string) {
5658

5759
return GeneralVisual;
5860
}
61+
62+
export function getDatabaseColor(type: string) {
63+
if (type === "cloudflare" || type === "cloudflare-d1") return "yellow";
64+
if (type === "starbasedb" || type === "starbase") return "rainbow";
65+
if (type === "libsql" || type === "turso") return "green";
66+
return "default";
67+
}

0 commit comments

Comments
 (0)