feat: Add preferences page

This commit is contained in:
Jesse Wierzbinski 2024-12-02 21:48:12 +01:00
parent a6635bc888
commit 5203f47409
No known key found for this signature in database
7 changed files with 135 additions and 7 deletions

View file

@ -1,6 +1,7 @@
<template>
<div ref="container" :class="['overflow-y-hidden relative duration-200']" :style="{
maxHeight: collapsed ? '18rem' : `${container?.scrollHeight}px` }">
maxHeight: collapsed ? '18rem' : `${container?.scrollHeight}px`
}">
<div :class="['prose prose-sm block relative dark:prose-invert duration-200 !max-w-full break-words prose-a:no-underline prose-a:hover:underline', $style.content]"
v-html="content">
</div>

View file

@ -0,0 +1,31 @@
<template>
<Card class="grid grid-cols-[1fr,auto] items-center p-6">
<CardHeader class="space-y-0.5 p-0">
<CardTitle class="text-base">
{{ setting.title }}
</CardTitle>
<CardDescription>
{{ setting.description }}
</CardDescription>
</CardHeader>
<CardFooter class="p-0">
<Switch :disabled="setting.notImplemented" :checked="setting.value" @update:checked="v => { setting.value = v }" />
</CardFooter>
</Card>
</template>
<script lang="ts" setup>
import {
Card,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "~/components/ui/card";
import { Switch } from "~/components/ui/switch";
import type { BooleanSetting } from "~/settings.ts";
defineModel<BooleanSetting>("setting", {
required: true,
});
</script>

View file

@ -61,25 +61,25 @@ import ThemeSwitcher from "./theme-switcher.vue";
const data = {
navMain: [
{
title: "Settings",
url: "#",
title: "Preferences",
url: "/preferences",
icon: Settings2,
items: [
{
title: "Appearance",
url: "#",
url: "/preferences/appearance",
},
{
title: "Behaviour",
url: "#",
url: "/preferences/behaviour",
},
{
title: "Emojis",
url: "#",
url: "/preferences/emojis",
},
{
title: "Roles",
url: "#",
url: "/preferences/roles",
},
],
},

View file

@ -0,0 +1,41 @@
<script setup lang="ts">
import { cn } from "@/lib/utils";
import {
SwitchRoot,
type SwitchRootEmits,
type SwitchRootProps,
SwitchThumb,
useForwardPropsEmits,
} from "radix-vue";
import { type HTMLAttributes, computed } from "vue";
const props = defineProps<
SwitchRootProps & { class?: HTMLAttributes["class"] }
>();
const emits = defineEmits<SwitchRootEmits>();
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props;
return delegated;
});
const forwarded = useForwardPropsEmits(delegatedProps, emits);
</script>
<template>
<SwitchRoot
v-bind="forwarded"
:class="cn(
'peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',
props.class,
)"
>
<SwitchThumb
:class="cn('pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5')"
>
<slot name="thumb" />
</SwitchThumb>
</SwitchRoot>
</template>

View file

@ -0,0 +1 @@
export { default as Switch } from "./Switch.vue";