Skip to content

Latest commit

 

History

History
816 lines (592 loc) · 28 KB

DESIGN.md

File metadata and controls

816 lines (592 loc) · 28 KB

DESIGN.md — Particle Theme

Agent Instructions: This document is the single source of truth for all UI decisions in this project. All generated components, styling, and layouts must follow the tokens, patterns, and rules defined here. Never invent colors, spacing values, or component structures. When in doubt, reference a token from this file.


General Rules: Agents may request permission to modify token values in the CSS files or improve primitive components when necessary to enhance consistency, accessibility, or overall UI quality.


1. Theme Identity

Property Value
Theme Name Particle
CSS Framework Tailwind CSS v4 (@import "tailwindcss")
Animation Library tw-animate-css
Component Library shadcn-vue (CSS: @import "tailwindcss" / @import "tw-animate-css")
Dark Mode Class-based via @custom-variant dark (&:is(.dark *))
Color Model OKLCH throughout (perceptually uniform, wide gamut)
Font — Sans Inter, sans-serif
Font — Serif Source Serif 4, serif
Font — Mono Fira Code, monospace
Base Radius 0.65rem (~10.4px)
Letter Spacing 0em (no tracking adjustment by default)

2. Full CSS Source

The complete CSS source and token definitions are located at:

./app/assets/css/tailwind.css

This file is the canonical source of all design tokens.


3. Token Reference

3.1 Color Tokens

Every token maps to a Tailwind utility through --color-{token} in @theme inline.

Rules

  • Always use Tailwind utility classes.
  • Never use raw OKLCH, RGB, HEX, or arbitrary color values in component code.
  • Never use default Tailwind color utilities such as text-gray-500 or bg-blue-100.

Core Surface & Text

Token Tailwind Class Light Dark Usage
background bg-background White Near-black oklch(0.20) Page background
foreground text-foreground Dark gray oklch(0.32) Off-white oklch(0.92) Primary body text
card bg-card White oklch(0.27) Card surfaces
card-foreground text-card-foreground Dark gray Off-white Text on cards
muted bg-muted Near-white blue tint Very dark Subtle backgrounds, table headers
muted-foreground text-muted-foreground Mid blue-gray Light gray Placeholder text, secondary labels
border border-border Light blue-gray Dark gray oklch(0.37) Borders and dividers
input Internal Same as border Same as border Input borders
ring ring-ring Primary blue Primary blue Focus rings

Brand

Token Tailwind Class Value (Light) Usage
primary bg-primary / text-primary Blue oklch(0.62 0.19 260) CTAs, active nav, links
primary-foreground text-primary-foreground White Text/icons on primary
secondary bg-secondary Light blue-gray Secondary buttons, chips
secondary-foreground text-secondary-foreground Blue-gray Text on secondary
accent bg-accent Pale blue Hover states, selected rows
accent-foreground text-accent-foreground Deep blue Text on accent

Semantic / Status

success, warning, and info are custom extensions added to the base shadcn theme and defined in this project's :root and .dark blocks.

Token Tailwind Class Meaning Usage
destructive bg-destructive / text-destructive Error / danger Delete actions, validation errors
destructive-foreground text-destructive-foreground — Text on destructive backgrounds
success bg-success / text-success Success / passing Published results, Grade A
success-foreground text-success-foreground — Text on success
warning bg-warning / text-warning Caution / pending Pending review, borderline grades
warning-foreground text-warning-foreground — Text on warning
info bg-info / text-info Informational Submitted results, banners
info-foreground text-info-foreground — Text on info

Sidebar

Sidebar tokens are completely independent. Never substitute bg-muted or bg-accent within the sidebar.

Token Tailwind Class Usage
sidebar bg-sidebar Sidebar surface
sidebar-foreground text-sidebar-foreground Sidebar text
sidebar-primary bg-sidebar-primary Active nav item
sidebar-primary-foreground text-sidebar-primary-foreground Text on active item
sidebar-accent bg-sidebar-accent Hovered nav item
sidebar-accent-foreground text-sidebar-accent-foreground Text on hovered item
sidebar-border border-sidebar-border Sidebar dividers
sidebar-ring ring-sidebar-ring Sidebar focus rings

Chart Palette

Multi-hue accent ramp. The canonical values live in app/assets/css/tailwind.css; the table below mirrors them.

Always assign chart-1 to the most important data series.

Token Light Dark
chart-1 0.6460 0.2220 41.12 0.4880 0.2430 264.38
chart-2 0.6000 0.1180 184.70 0.6960 0.1700 162.48
chart-3 0.3980 0.0700 227.39 0.7690 0.1880 70.08
chart-4 0.8280 0.1890 84.43 0.6270 0.2650 303.90
chart-5 0.7690 0.1880 70.08 0.6450 0.2460 16.44

3.2 Border Radius Tokens

Token Tailwind Class Value Usage
radius-sm rounded-sm calc(var(--radius) - 4px) Small badges, inline tags
radius-md rounded-md calc(var(--radius) - 2px) Buttons, inputs
radius-lg rounded-lg var(--radius) (0.65rem) Cards, modals, popovers
radius-xl rounded-xl calc(var(--radius) + 4px) Large overlays, sheets
Utility rounded-full 9999px Pills, avatars

All radius tokens derive from the single --radius: 0.65rem custom property in tailwind.css.


3.3 Shadow Tokens

All shadows use low-opacity black and are designed to work in both light and dark modes.

Token Tailwind Class Usage
shadow-2xs shadow-2xs Minimal hover elevation
shadow-xs shadow-xs Subtle surfaces
shadow-sm shadow-sm Default card elevation
shadow shadow Dropdowns, popovers
shadow-md shadow-md Floating actions
shadow-lg shadow-lg Dialogs, modals
shadow-xl shadow-xl Sheets
shadow-2xl shadow-2xl Reserved for critical UI only

3.4 Typography Tokens

Token Value Usage
font-sans Inter, sans-serif Default UI text
font-serif Source Serif 4, serif Long-form content
font-mono Fira Code, monospace IDs, codes, score values
font-heading Same as font-sans Headings

Type Scale

Class Size Weight Line Height Usage
text-4xl 2.25rem 700 1.1 School name on report card
text-3xl 1.875rem 600 1.2 Page titles
text-2xl 1.5rem 600 1.3 Section headings
text-xl 1.25rem 500 1.4 Modal titles
text-lg 1.125rem 500 1.5 Emphasized labels
text-base 1rem 400 1.6 Default body text
text-sm 0.875rem 400 1.5 Table cells
text-xs 0.75rem 400 1.4 Captions, badges

3.5 Spacing

Base spacing unit:

--spacing: 0.25rem;

Standard Tailwind spacing scale applies.

Class Value Usage
p-1 0.25rem Icon padding
p-2 0.5rem Compact badges
p-3 0.75rem Compact inputs
p-4 1rem Default component padding
p-6 1.5rem Card padding
p-8 2rem Page section padding
gap-2 0.5rem Icon/text spacing
gap-4 1rem Form spacing
gap-6 1.5rem Grid spacing

4. Component Patterns

Components use shadcn-vue (Reka UI) primitives located in:

app/components/ui

Component Architecture Rules

  • Extract large or reusable sections into dedicated components.
  • Prefer reusable composition over duplicated markup.
  • Use props extensively for customization and reuse.
  • Shared wrappers around shadcn components are encouraged.
  • Examples include:
    • Confirm dialogs
    • Empty states
    • Data tables
    • Dashboard stat cards
    • Section headers

Naming Conventions

All components inside app/components/ui/** are automatically prefixed with Ui.

Examples:

File Usage
components/ui/button/Button.vue <UiButton />
components/form/FormField.vue <FormField />

This behavior relies on Nuxt's pathPrefix component configuration.


4.1 Button

Rules

  • Primary buttons are reserved for the main action on a page or section.
  • Avoid multiple primary buttons in the same visual area.
  • Icon-only buttons must include aria-label.
<!-- Primary -->
<UiButton>Save Result</UiButton>

<!-- Secondary -->
<UiButton variant="secondary">
  View Scoresheet
</UiButton>

<!-- Outline -->
<UiButton variant="outline">
  Export PDF
</UiButton>

<!-- Ghost -->
<UiButton variant="ghost" :icon="ICONS.edit" aria-label="Edit result" />

<!-- Icon left -->
<UiButton variant="destructive" :icon="ICONS.delete">
  Delete Student
</UiButton>

<!-- Icon right -->
<UiButton :icon-right="ICONS.forward">
  Go to Dashboard
</UiButton>

<!-- Loading -->
<UiButton loading>
  Saving...
</UiButton>

4.2 Card

Create reusable card wrappers where appropriate.

<UiCard class="shadow-sm">
  <UiCardHeader>
    <UiCardTitle>JSS1A — 1st Term Result</UiCardTitle>

    <UiCardDescription>
      2025/2026 Academic Session
    </UiCardDescription>
  </UiCardHeader>

  <UiCardContent>
    <!-- content -->
  </UiCardContent>

  <UiCardFooter
    class="flex justify-end gap-3 border-t border-border pt-4"
  >
    <Button variant="outline">
      Review
    </Button>

    <Button>
      Approve & Publish
    </Button>
  </UiCardFooter>
</UiCard>

4.3 Status Badge

Use these exact class combinations for result lifecycle states.

<!-- Draft -->
<UiBadge variant="outline" class="border-border text-muted-foreground">
  Draft
</UiBadge>

<!-- Submitted -->
<UiBadge class="border border-info/30 bg-info/15 text-info">
  Submitted
</UiBadge>

<!-- Pending -->
<UiBadge class="border border-warning/30 bg-warning/15 text-warning">
  Pending Review
</UiBadge>

<!-- Published -->
<UiBadge class="border border-success/30 bg-success/15 text-success">
  Published
</UiBadge>

<!-- Rejected -->
<UiBadge class="border border-destructive/30 bg-destructive/15 text-destructive">
  Rejected
</UiBadge>

4.4 Forms

All forms are built on FormKit (@formkit/nuxt with autoImport: true). Config lives in app/formkit.config.ts, custom inputs are registered there with createInput, and FormKit's default styling is themed to shadcn-vue in app/assets/css/formkit-shadcn.css. This provides:

  • Consistent styling
  • Validation handling
  • Accessibility support (labels, help text, error messaging)
  • Shared layouts and spacing
  • Tight integration with shadcn-vue primitives

Form Architecture Rules

  • Always wrap forms in <FormKit type="form">
  • Pass initial values with :value (or v-model for a local writable copy) — never bind v-model directly to TanStack Query data, which is wrapped in readonly()
  • Use FormKit input types and the registered custom inputs (_select, _tags, <FormKitPassword />) instead of raw inputs
  • Client-side validation should be handled through FormKit's validation prop and custom rules registered in app/formkit.config.ts
  • Derive payload types from the shared Zod schemas in shared/validators/** with z.infer; the same schemas are enforced server-side by oRPC
  • Never manually wire labels, help text, or errors — FormKit renders them from the label / help props and validation state
  • All form spacing should use space-y-6 unless a tighter layout is explicitly needed
  • Use gap-4 for grouped form controls
  • Disable fields during submission with <fieldset :disabled="isSubmitting"> and reflect loading on the submit <UiButton>

Standard Form Setup

Use FormKit for all forms and the shared Zod schemas in shared/validators/** as the source of truth for payload shapes. Always check that folder first: if a schema (and its z.infer type) already exists for the form, import the type rather than redefining it. If it needs changing, edit the existing schema after user approval.

<script setup lang="ts">
import { type UpsertStudentInput } from "~~/shared/validators/academic"

const isSubmitting = ref(false)

async function onSubmit(payload: UpsertStudentInput) {
  isSubmitting.value = true
  try {
    await createStudent.mutateAsync(payload)
  } finally {
    isSubmitting.value = false
  }
}

const classOptions = [
  { label: "JSS1A", value: "jss1a" },
  { label: "JSS1B", value: "jss1b" }
]
</script>

<template>
  <FormKit type="form" class="space-y-6" :actions="false" @submit="onSubmit">
    <fieldset :disabled="isSubmitting">
      <FormKit
        name="name"
        label="Student Name *"
        placeholder="Ahmed Musa"
        :prefix-icon="ICONS.student"
        validation="required"
      />

      <FormKit
        name="studentId"
        label="Student ID *"
        placeholder="STU-2026-001"
        :prefix-icon="ICONS.credentials"
        validation="required"
      />

      <FormKit
        type="_select"
        name="classId"
        label="Class *"
        placeholder="Select class"
        :options="classOptions"
        :prefix-icon="ICONS.class"
        validation="required"
      />

      <div class="flex justify-end">
        <UiButton type="submit" :loading="isSubmitting"> Add Student </UiButton>
      </div>
    </fieldset>
  </FormKit>
</template>

Supported Form Components

FormKit ships all native input types; use the type that matches the data and the registered custom inputs for shadcn-vue controls.

Type / Component Purpose
form Form wrapper; handles submit and validation
text Text
email Email
password Password (use <FormKitPassword /> for the toggle)
number Numeric values
textarea Long-form text
checkbox Boolean agreement/input
select Native select dropdown
_select shadcn-vue select dropdown (custom input)
_tags Array/tag input (custom input)

Field Conventions

Labels

  • Labels should be concise and sentence-cased
  • Required fields should include *
<FormKit type="email" name="email" label="Email address *" />

Descriptions

Descriptions should provide context, constraints, or guidance.

<FormKitPassword
  name="password"
  label="Password"
  help="Use a mix of letters, numbers, and symbols."
/>

Placeholders

  • Use realistic examples
  • Avoid generic placeholders like "Enter value"
placeholder="Ada Lovelace"

Icons

All icons must come from the shared ICONS constant.

Never hardcode icon names inline.

<FormKit type="email" name="email" :prefix-icon="ICONS.email" />

Custom Inputs

Custom inputs are registered centrally in app/formkit.config.ts with createInput, so they can be used anywhere as a FormKit type.

_select

app/components/FormKit/Select.vue wraps UiSelect. Accepts options ({ label, value, disabled? }[]), placeholder, multiple, and disabled.

<FormKit
  type="_select"
  name="classId"
  label="Class"
  placeholder="Select a class for the student"
  :options="classes"
  validation="required"
/>

_tags

app/components/FormKit/Tags.vue wraps UiTagsInput. Accepts addOnKeys, placeholder, and disabled.

<FormKit
  type="_tags"
  name="subjectTags"
  label="Subject Tags"
  placeholder="Create tags for subjects"
  help="Subject tags are used to filter and manage subjects"
/>

FormKitPassword

app/components/FormKit/Password.vue is a thin wrapper used directly as <FormKitPassword />. It renders a password field with a visibility toggle.

<FormKitPassword name="password" label="Password" validation="required" />

Validation Rules

  • Validation messages must use:

    text-destructive text-xs

    FormKit's themed message styling in app/assets/css/formkit-shadcn.css (.formkit-message) already applies --destructive and text-xs; only add this class when building custom message markup.

  • Client-side validation should occur through FormKit's validation prop or custom rules registered in app/formkit.config.ts

  • Prefer the shared Zod schemas in shared/validators/** for complex forms — derive payload types with z.infer and let oRPC enforce them server-side

  • Async validation should show loading indicators when necessary


Form Layout Rules

Scenario Recommended Layout
Simple forms space-y-6
Compact forms space-y-4
Two-column forms grid md:grid-cols-2 gap-4
Inline controls flex items-center gap-2
Form actions flex justify-end gap-3

Submit Actions

  • The primary submit button should usually be the right-most action
  • Destructive actions must use confirmation dialogs
  • Loading states should disable submission
<UiButton type="submit" loading>
  Saving...
</UiButton>

Accessibility Rules

  • Every form field must have:

    • a label
    • accessible error messaging
    • keyboard support
  • Icon-only controls require aria-label

  • Required fields should be communicated both:

    • visually
    • semantically
  • Forms must remain fully usable on mobile devices


4.5 Confirm Dialogs

Create reusable confirm dialog wrappers for destructive or irreversible actions.


4.6 Empty States

<UiEmptyState
  :icon="ICONS.empty"
  title="No students to display"
  description="You have not created any students yet."
/>

4.7 Dashboard Stat Cards

Create reusable stat cards for analytics and dashboard metrics.

Recommended structure:

  • Icon
  • Label
  • Value
  • Trend indicator (optional)

5. Color Usage Rules

Agents must consult this table before assigning any color classes.

Never use arbitrary Tailwind colors.

Scenario Classes
Primary CTA bg-primary text-primary-foreground
Page background bg-background
Card surface bg-card text-card-foreground shadow-sm
Table header bg-muted/50
Table row hover hover:bg-accent/40 transition-colors duration-150
Selected row bg-accent text-accent-foreground
Sidebar background bg-sidebar text-sidebar-foreground
Active sidebar item bg-sidebar-primary text-sidebar-primary-foreground rounded-md
Hovered sidebar item bg-sidebar-accent text-sidebar-accent-foreground rounded-md
Secondary text text-muted-foreground
IDs / usernames font-mono text-xs text-muted-foreground tabular-nums
Validation error text-destructive text-xs
Destructive action bg-destructive text-destructive-foreground
Focus ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2

6. Layout Architecture

6.1 Content Width Constraints

Context Max Width Padding
Dashboard pages max-w-7xl px-4 sm:px-6 lg:px-8 py-8
Settings pages max-w-3xl px-4 py-8
Auth pages max-w-sm px-4 py-8
Default modal sm:max-w-lg Handled by shadcn
Wide modal sm:max-w-2xl Handled by shadcn
Report card preview max-w-3xl px-4 sm:px-0

7. Report Card Layout

The report card must render cleanly in A4 portrait print format.

Requirements

  • Must remain readable at 100% zoom.
  • Must avoid horizontal overflow.
  • Print output must prioritize clarity over visual effects.

8. Icon Conventions

Use Lucide and Tabler icons through nuxt-icon.

Rules

  • Inline icons: size-4

  • Sidebar/navigation icons: size-5

  • Never hardcode icon names directly in components.

  • Always reference icons through:

    ICONS.someKey

Icons are defined in:

shared/constants/icons.ts

The ICONS constant is auto-imported by Nuxt, so explicit imports are unnecessary.

<Icon :name="ICONS.class" />

<UiButton text="Add Student" :icon="ICONS.add" />

9. Accessibility Requirements

  • All interactive elements must include:

    focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2
  • Never rely solely on color to communicate status.

  • Every <UiTable> must include:

    • aria-label
    • or a <caption>
  • Icon-only buttons must include aria-label.

  • Minimum tap target:

    min-h-9 min-w-9
  • Report cards must remain readable without zooming or horizontal scrolling.


10. Responsive Breakpoints

Breakpoint Min Width Behavior
Default 0px Single-column layout
sm 640px Minor layout improvements
md 768px Two-column forms
lg 1024px Full sidebar and tables
xl 1280px 4-column dashboard stats

11. File & Folder Structure

app
├── assets/
│   └── css/
│       ├── tailwind.css          # CSS entry (imported by nuxt.config.ts)
│       └── formkit-shadcn.css    # FormKit styling
│
├── components/
│   ├── Ui/            # shadcn-vue primitives (Ui prefix)
│   ├── FormKit/       # FormKit custom inputs
│   ├── App/           # shared application components
│   ├── Page/
│   ├── Sidebar/
│   └── ...            # domain folders: Class, Session, Subject, Student, Teacher,
│                      # Result, Scoresheet, ReportCard, Settings, Dashboard

Rules

  • Do not manually modify generated shadcn components unless necessary.
  • Shared application-level components belong in components/App.
  • Domain-specific components belong in namespaced folders.

12. Do / Don't

✅ Do ❌ Don't
Use design tokens via Tailwind utilities Hardcode colors
Use text-muted-foreground for secondary text Use arbitrary gray utilities
Use font-mono tabular-nums for numeric data Mix font families randomly
Confirm destructive actions with dialogs Delete immediately
Use sidebar-specific tokens in sidebars Use generic background tokens
Use shadow-sm for resting cards Use excessive shadows/glows
Use transition-colors duration-150 Use JS for simple hover transitions
Use rounded-lg as the default radius Use oversized radii like rounded-3xl
Keep icon sizing consistent Scale icons inconsistently

DESIGN.md — Particle Theme v1.0 | Tailwind CSS v4 + shadcn-vue (Reka UI) | 2026