Skip to content

Commit c752809

Browse files
authored
Merge pull request #709 from devforth/update-agent-instructions-for-vue-components
fix: edit CLI app agent instructions for generating a vue component. …
2 parents cb92157 + 6fb5f66 commit c752809

1 file changed

Lines changed: 77 additions & 5 deletions

File tree

  • adminforth/commands/createApp/templates/.agents/skills/adminforth-custom-vue

adminforth/commands/createApp/templates/.agents/skills/adminforth-custom-vue/SKILL.md.hbs

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: adminforth-custom-vue
3-
description: "Use when implementing AdminForth custom Vue UI: field components, page injections, login or global injections, meta-driven component declarations, and frontend packages inside custom/."
3+
description: "Use when implementing AdminForth custom Vue UI: AFCL components, theme colors and dark mode, field components, page injections, login or global injections, meta-driven component declarations, and frontend packages inside custom/."
44
user-invocable: true
55
---
66

@@ -13,6 +13,68 @@ user-invocable: true
1313
- Adding resource page injections, login injections, or global layout injections.
1414
- Passing `meta` into reusable Vue components.
1515
- Installing frontend packages used only by custom AdminForth Vue code.
16+
- Any task that produces visible UI in an AdminForth app, even when the task says nothing about how it should look.
17+
18+
## Adminforth UI Defaults
19+
20+
Apply all of these to every piece of UI you write under `custom/`, especially when the user gave no design
21+
instructions at all. These are the defaults, not options — do not ask whether the user wants them, and do
22+
not wait for a follow-up prompt about styling or dark mode.
23+
24+
1. **Build from AFCL first.** AFCL (AdminForth Components Library) is imported from `@/afcl` and is always
25+
available in `custom/` without installing anything. Reach for a raw HTML control only when no AFCL
26+
component covers the case.
27+
2. **Buttons come from AFCL with an explicit intent.** Primary/confirming action is the default filled
28+
accent `<Button>`. Secondary, cancel, and "back" actions are stroked `<Button variant="secondary">`.
29+
Destructive actions are `<Button variant="danger">`.
30+
3. **Form controls come from AFCL.** `Input`, `Textarea`, `Select`, `Checkbox`, `Toggle`, `DatePicker`,
31+
`Dropzone`. Preferably not a bare `<input>`, `<select>`, or `<textarea>` styled by hand — that is the main way
32+
custom pages end up looking foreign.
33+
4. **Accents use `lightPrimary` / `darkPrimary`.** Anything that carries brand or "this is the important
34+
one" meaning — accent fills, highlighted values, active states, links, focus emphasis, the main chart
35+
series — should use `bg-lightPrimary dark:bg-darkPrimary`, `text-lightPrimary dark:text-darkPrimary`,
36+
`text-lightPrimaryContrast dark:text-darkPrimaryContrast`.
37+
5. **Everything else may use Tailwind's stock palette.** `bg-white`, `bg-gray-50`, `text-gray-700`,
38+
`text-red-600`, `border-gray-200`, `bg-pink-500`, and friends are all fine for neutrals, surfaces,
39+
borders, and semantic colors. The theme tokens in the table below are still the better choice when a
40+
block sits directly next to built-in AdminForth chrome and should match it exactly — but they are a
41+
recommendation, not a restriction.
42+
6. **Dark theme is part of writing the class, not a later pass.** Every color utility must be written as a
43+
light/dark pair: `bg-white dark:bg-gray-900`, `text-gray-700 dark:text-gray-300`.
44+
This matters most with stock Tailwind colors, which have no built-in
45+
dark behavior — a `bg-gray-50` with no `dark:` counterpart is a defect, fix it before finishing.
46+
`light*`/`dark*` token pairs satisfy this by construction. Dark mode is class-based
47+
(`darkMode: 'class'`), so `dark:` variants work everywhere in `custom/`.
48+
7. **Icons come from the prerendered Iconify packages** already present in the SPA:
49+
`@iconify-prerendered/vue-flowbite` (default), plus `-heroicons`, `-humbleicons`, and `-flag`.
50+
Do not add an icon dependency to `custom/package.json` for these.
51+
8. **Never build Tailwind class names dynamically.** `custom/` is copied into the SPA sources and scanned
52+
statically by Tailwind, so `` `text-${color}-600` `` produces no CSS. Write full class strings and pick
53+
between them.
54+
55+
## Dark Theme Self-Check
56+
57+
Run this over every file you touched before reporting the work as done:
58+
59+
- Search the file for `bg-`, `text-`, `border-`, `ring-`, `fill-`, `stroke-`, `divide-`, `placeholder-`,
60+
and `shadow-` color utilities.
61+
- Each one either has a `dark:` counterpart, comes from a `light*`/`dark*` token pair (which already is
62+
one), or belongs to an AFCL component that handles theming itself. This is the check that actually
63+
matters — a stock Tailwind color with no `dark:` twin is the single most common way custom UI breaks in
64+
dark mode.
65+
- Accents are `lightPrimary`/`darkPrimary`, not a hardcoded blue or indigo.
66+
- No raw `#hex` or `rgb()` in templates or `<style>` blocks.
67+
68+
```
69+
❌ <button class="bg-blue-600 text-white rounded px-4 py-2">Save</button>
70+
✅ <Button @click="save">Save</Button>
71+
72+
❌ <div class="bg-white border border-gray-200 text-gray-800">
73+
✅ <div class="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700
74+
text-gray-800 dark:text-gray-200">
75+
❌ <p class="text-red-600">\{{ error }}</p>
76+
✅ <p class="text-red-600 dark:text-red-400">\{{ error }}</p>
77+
```
1678
1779
## `custom/` Directory and `@@/`
1880
@@ -23,6 +85,10 @@ user-invocable: true
2385
2486
## Frontend Packages in `custom/`
2587
88+
- First check whether you need a package at all. These are already available to `custom/` components with
89+
no install step: `@/afcl` (AFCL components), `@/types/Common` (AdminForth types), `@/adminforth`
90+
(`useAdminforth`), `@/stores/core` (`useCoreStore`), `@/websocket`, Vue, Tailwind, and the
91+
`@iconify-prerendered/vue-*` icon sets. AFCL charts already wrap ApexCharts.
2692
- Install frontend-only dependencies inside `custom/`, not in the app root.
2793
2894
```bash
@@ -127,25 +193,27 @@ show: {
127193
<template>
128194
<div class="grid gap-2">
129195
<Input
196+
type="text"
197+
full-width
130198
:model-value="localValue"
131199
:readonly="readonly"
132200
:placeholder="meta?.placeholder || column.label"
133201
@update:model-value="onInput"
134202
/>
135203
136-
<p v-if="errorMessage" class="text-sm text-red-600">
204+
<p v-if="errorMessage" class="text-sm">
137205
\{{ errorMessage }}
138206
</p>
139207
140-
<p v-else-if="isEmpty" class="text-sm text-amber-600">
208+
<p v-else-if="isEmpty" class="text-sm">
141209
Value is currently empty
142210
</p>
143211
</div>
144212
</template>
145213
146214
<script setup lang="ts">
147215
import { computed, onMounted, ref } from 'vue';
148-
import Input from '@/afcl/Input.vue';
216+
import { Input } from '@/afcl';
149217
import type {
150218
AdminForthResourceColumnCommon,
151219
AdminForthResourceCommon,
@@ -337,4 +405,8 @@ options: {
337405
- Prefer simple string declarations until you actually need `meta`.
338406
- Reuse one component with multiple full declarations instead of cloning similar files.
339407
- Keep page injections small unless the layout intentionally becomes page-scrolling.
340-
- Keep custom edit and create components explicit about validity and emptiness if the default input heuristics are not enough.
408+
- Keep custom edit and create components explicit about validity and emptiness if the default input heuristics are not enough.
409+
- Reach for an AFCL component before writing markup; use `lightPrimary`/`darkPrimary` for accents; write
410+
the `dark:` variant in the same edit as the light one. These are defaults for every UI task, not polish
411+
to be added when someone asks for it.
412+
- When you are done, re-read your diff against the Dark Theme Self-Check above before reporting completion.

0 commit comments

Comments
 (0)