feat: add personal project list, add project settings, etc

This commit is contained in:
2024-02-24 03:55:50 +00:00
parent 49b80a2f4c
commit 751210c819
31 changed files with 877 additions and 148 deletions
+30
View File
@@ -0,0 +1,30 @@
import { ucfirst } from "~/lib/utils";
export const visibilityList = ["public", "private", "unlisted"].map(
(value) => ({
value,
label: ucfirst(value),
})
);
export const cssPreprocessorList = [
{
label: "None",
value: "",
},
{
label: "PostCSS",
value: "postcss",
},
];
export const jsTranspilerList = [
{
label: "None",
value: "",
},
{
label: "SWC",
value: "swc",
},
];
+35
View File
@@ -0,0 +1,35 @@
import { z } from "zod";
export const projectSettingsSchema = z
.object({
title: z.string().min(6),
// slug: z.string().min(8),
visibility: z.enum(["public", "private", "unlisted"]),
settings: z.object({
css: z.object({
preprocessor: z.enum(["", "postcss"]).optional().nullable(),
tailwindcss: z.boolean().optional().nullable(),
}),
js: z.object({
transpiler: z.enum(["", "swc"]).optional().nullable(),
packages: z
.object({ name: z.string().min(1), url: z.string().min(1).url() })
.array(),
}),
}),
})
.superRefine((val, ctx) => {
const { settings } = val;
if (settings.css.tailwindcss && settings.css.preprocessor !== "postcss") {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "Preprocessor need to be set to PostCSS to use tailwindcss.",
path: ["settings.css.preprocessor"],
});
}
});
export type ProjectSettingsSchema = z.infer<typeof projectSettingsSchema>;