Files
archie/ui/src/settings/InstructionsPage.vue
T

52 lines
1.7 KiB
Vue

<script setup lang="ts">
import ApplyStatusRows from "./ApplyStatusRows.vue";
import { computed, onMounted } from "vue";
import { storeToRefs } from "pinia";
import PageHeader from "@/base/PageHeader.vue";
import { Textarea } from "@/components/ui/textarea";
import { resourcesForPage, useSettingsStore } from "@/stores/settings";
import ConfigCard from "./ConfigCard.vue";
import DraftHint from "./DraftHint.vue";
import HistoryLink from "./HistoryLink.vue";
const KIND = "soul";
const store = useSettingsStore();
const { catalog, catalogError } = storeToRefs(store);
onMounted(store.load);
const resources = computed(() => resourcesForPage(catalog.value, "soul"));
const soul = computed(() => store.drafts[KIND]?.value as { text: string } | undefined);
const error = computed(() => store.pageErrorFor(KIND));
const chars = computed(() => soul.value?.text.length ?? 0);
</script>
<template>
<div>
<PageHeader title="Instructions">
<HistoryLink :kinds="resources.map((r) => r.kind)" />
</PageHeader>
<ApplyStatusRows v-for="resource in resources" :key="resource.kind" :kind="resource.kind" class="mb-4" />
<p v-if="catalogError || error" class="mb-4 text-sm text-danger" role="alert">
{{ catalogError || error }}
</p>
<ConfigCard v-if="soul">
<div class="flex justify-end">
<DraftHint :kind="KIND" path="text" />
</div>
<Textarea
id="soul-text"
v-model="soul.text"
:rows="18"
class="mt-1 font-mono text-[13px]"
aria-label="Instructions"
/>
<p class="mt-1.5 text-xs text-fg-subtle">
{{ chars.toLocaleString() }} chars · ~{{ Math.round(chars / 4).toLocaleString() }} tokens</p>
</ConfigCard>
</div>
</template>