first commit
This commit is contained in:
commit
b7b0f253ce
85 files changed
+7560
No files matched your search
@@ -0,0 +1,56 @@
|
||||
import type { EntityKind } from "@prisma/client";
|
||||
|
||||
export type KindInfo = {
|
||||
kind: EntityKind;
|
||||
slug: string;
|
||||
color: string;
|
||||
};
|
||||
|
||||
// Ordningen styr menyer och översikt.
|
||||
export const KINDS: KindInfo[] = [
|
||||
{ kind: "CHARACTER", slug: "characters", color: "blue" },
|
||||
{ kind: "PET", slug: "pets", color: "orange" },
|
||||
{ kind: "HOME", slug: "homes", color: "green" },
|
||||
{ kind: "PLACE", slug: "places", color: "red" },
|
||||
{ kind: "COMPANY", slug: "companies", color: "purple" },
|
||||
{ kind: "PREMISES", slug: "premises", color: "teal" },
|
||||
{ kind: "EDUCATION", slug: "education", color: "cyan" },
|
||||
{ kind: "SCENARIO", slug: "scenarios", color: "pink" },
|
||||
];
|
||||
|
||||
export const KIND_BY_SLUG = new Map(KINDS.map((k) => [k.slug, k]));
|
||||
export const KIND_INFO = Object.fromEntries(KINDS.map((k) => [k.kind, k])) as Record<EntityKind, KindInfo>;
|
||||
|
||||
export function parseKind(value: unknown): EntityKind | null {
|
||||
return typeof value === "string" && value in KIND_INFO ? (value as EntityKind) : null;
|
||||
}
|
||||
|
||||
// Mallar finns för alla typer och dessutom för relationer.
|
||||
export type TemplateKind = EntityKind | "RELATION";
|
||||
export const RELATION_SLUG = "relations";
|
||||
|
||||
export function parseTemplateKind(value: unknown): TemplateKind | null {
|
||||
return value === "RELATION" ? "RELATION" : parseKind(value);
|
||||
}
|
||||
|
||||
export function templateSlug(kind: TemplateKind): string {
|
||||
return kind === "RELATION" ? RELATION_SLUG : KIND_INFO[kind].slug;
|
||||
}
|
||||
|
||||
export function templateKindFromSlug(slug: string): TemplateKind | null {
|
||||
return slug === RELATION_SLUG ? "RELATION" : (KIND_BY_SLUG.get(slug)?.kind ?? null);
|
||||
}
|
||||
|
||||
// Typer som kan ha arbetsplats i scheman
|
||||
export const WORKPLACE_KINDS: EntityKind[] = ["COMPANY", "PREMISES", "PLACE", "EDUCATION"];
|
||||
|
||||
export const MARKER_COLORS: Record<string, string> = {
|
||||
blue: "#206bc4",
|
||||
red: "#d63939",
|
||||
green: "#2fb344",
|
||||
orange: "#f76707",
|
||||
purple: "#ae3ec9",
|
||||
pink: "#d6336c",
|
||||
teal: "#0ca678",
|
||||
yellow: "#f59f00",
|
||||
};
|
||||
Reference in new issue
Block a user