Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

14.4 KB
Raw Blame
<% # Style-Guide-Seite: Themes (Hell/Dunkel/Pop) + Token-Layer.
   # Bewusst auf semantischen Tokens gebaut -> rendert in allen drei Ansichten korrekt und
   # die Swatches flippen live beim Umschalten (Schalter unten in der Sidebar).
   # Quelle der Regeln: doc/design_system.md Teil G/I + doc/token_layer_*.md %>
<div class="container mx-auto px-8 py-8 max-w-7xl text-body">
  <!-- Header -->
  <div class="mb-8">
    <h1 class="text-4xl font-black text-heading uppercase mb-2">Themes</h1>
    <p class="text-muted">Eine Palette, drei Ansichten: <strong>Hell</strong>, <strong>Dunkel</strong> und <strong>Pop</strong> — über einen CSS-Variablen-Token-Layer.</p>
  </div>

  <!-- Intro -->
  <div class="border-l-4 border-edge-strong bg-surface-shell rounded-r-lg p-8 mb-12">
    <h2 class="text-2xl font-bold text-heading mb-4">Probier es aus</h2>
    <p class="text-lg mb-4">
      Schalte unten in der Sidebar zwischen <i class="bi bi-sun"></i> Hell, <i class="bi bi-moon-stars"></i> Dunkel
      und <i class="bi bi-palette"></i> Pop um — <strong>diese Seite und jede Komponente im Style Guide wechseln live mit</strong>.
      Die Auswahl wird pro Browser in <code class="bg-surface px-1 rounded">localStorage['lb-theme']</code> gemerkt.
    </p>
    <p class="text-muted">
      <strong>Pop</strong> ist der Default — wer noch nie umgeschaltet hat, sieht Pop. Die Umschaltung passiert
      vor dem ersten Paint (kein Flackern) über ein Inline-Script im <code class="bg-surface px-1 rounded">&lt;head&gt;</code>.
    </p>
  </div>

  <!-- The three views -->
  <section class="mb-12">
    <h2 class="text-2xl font-bold text-heading mb-6 pb-2 border-b border-edge-strong">Die drei Ansichten</h2>
    <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
      <% [
        { name: "Hell", icon: "sun", sel: ":root", char: "Warm-ruhig (Warm-Editorial). Off-White-Cremeflächen statt Reinweiß, leiser Tinten-Strich, gedämpfte Status-Töne.", use: "Default-Arbeitsmodus am Tag." },
        { name: "Dunkel", icon: "moon-stars", sel: ".dark", char: "Warm-dunkle Rampe. Elevation kehrt um: gehobene Flächen (Modal/Input) sind heller als der Grund. Schatten weg → Tiefe über Rahmen.", use: "Abends / dunkle Umgebung, lange Sessions." },
        { name: "Pop", icon: "palette", sel: ".theme-pop", char: "Reinweiß + harte schwarze Striche + lautes Lime. Brutalistischer, kontrastreicher Charakter — die Marken-Ansicht.", use: "Default. Maximale Klarheit & Wiedererkennung." }
      ].each do |t| %>
        <div class="bg-surface-raised border border-edge rounded-lg p-5 shadow-sm">
          <div class="flex items-center gap-2 mb-2">
            <i class="bi bi-<%= t[:icon] %> text-xl text-heading"></i>
            <h3 class="text-lg font-black text-heading"><%= t[:name] %></h3>
            <code class="ml-auto text-xs bg-surface-shell text-muted px-1.5 py-0.5 rounded"><%= t[:sel] %></code>
          </div>
          <p class="text-sm mb-3"><%= t[:char] %></p>
          <p class="text-xs text-muted"><strong>Wann:</strong> <%= t[:use] %></p>
        </div>
      <% end %>
    </div>
  </section>

  <!-- Live: semantic surface/stroke tokens -->
  <section class="mb-12">
    <h2 class="text-2xl font-bold text-heading mb-2 pb-2 border-b border-edge-strong">Semantische Tokens (live)</h2>
    <p class="text-muted text-sm mb-6">
      Views benutzen <strong>semantische Tokens</strong>, keine festen Farbwerte. Jeder Token ist eine CSS-Variable;
      ein Theme überschreibt nur die Variablen — darum flippen die Kacheln unten beim Umschalten.
    </p>
    <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
      <% [
        { cls: "bg-surface",        name: "surface",        var: "--cream-50",  desc: "Inhalts-/Tabellenfläche" },
        { cls: "bg-surface-shell",  name: "surface-shell",  var: "--cream-100", desc: "Shell / Sidebar" },
        { cls: "bg-surface-raised", name: "surface-raised", var: "--white",     desc: "Modal / Input (Dunkel: heller!)" },
        { cls: "bg-selected",       name: "selected",       var: "--cream-200", desc: "aktiv / ausgewählt" }
      ].each do |s| %>
        <div class="rounded-lg overflow-hidden border border-edge">
          <div class="h-20 <%= s[:cls] %> border-b border-edge"></div>
          <div class="p-3 bg-surface-raised">
            <p class="font-bold text-sm text-heading"><%= s[:name] %></p>
            <p class="text-xs font-mono text-muted"><%= s[:cls] %></p>
            <p class="text-[11px] text-faint mt-0.5"><%= s[:var] %> · <%= s[:desc] %></p>
          </div>
        </div>
      <% end %>
    </div>

    <!-- Stroke + text -->
    <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-4">
      <div class="bg-surface-raised border border-edge rounded-lg p-5">
        <p class="text-xs font-bold uppercase tracking-wide text-faint mb-3">Strich</p>
        <div class="flex items-center gap-3 mb-2">
          <span class="inline-block w-10 h-6 rounded border-2 border-edge-strong"></span>
          <span class="text-sm"><code class="text-muted">edge-strong</code> / <code class="text-muted">stroke</code> — Tinten-Strich (<span class="font-mono text-xs">--ink</span> / <span class="font-mono text-xs">--stroke</span>)</span>
        </div>
        <div class="flex items-center gap-3">
          <span class="inline-block w-10 h-6 rounded border border-edge"></span>
          <span class="text-sm"><code class="text-muted">edge</code> — leise Karten-/Tabellenkante (<span class="font-mono text-xs">--cream-300</span>)</span>
        </div>
      </div>
      <div class="bg-surface-raised border border-edge rounded-lg p-5">
        <p class="text-xs font-bold uppercase tracking-wide text-faint mb-3">Text</p>
        <p class="text-heading font-bold">heading — Überschriften (--cream-900)</p>
        <p class="text-body">body — Fließtext (--cream-800)</p>
        <p class="text-muted">muted — gedämpft / Caption (--cream-600)</p>
        <p class="text-faint">faint — sehr leise / Placeholder (--cream-500)</p>
      </div>
    </div>

    <!-- Accent / action -->
    <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mt-4">
      <div class="bg-surface-raised border border-edge rounded-lg p-4">
        <div class="h-10 rounded bg-btn-primary mb-2"></div>
        <p class="font-bold text-sm text-heading">btn-primary</p>
        <p class="text-xs text-muted">Primär-Button-Füllung (Lime, pro Theme einstellbar). Text darauf immer dunkel.</p>
      </div>
      <div class="bg-surface-raised border border-edge rounded-lg p-4">
        <div class="h-10 rounded bg-accent mb-2"></div>
        <p class="font-bold text-sm text-heading">accent</p>
        <p class="text-xs text-muted">Primäraktion / Hervorhebung. Per-Org inline überschreibbar.</p>
      </div>
      <div class="bg-surface-raised border border-edge rounded-lg p-4">
        <div class="h-10 rounded bg-info mb-2"></div>
        <p class="font-bold text-sm text-heading">info</p>
        <p class="text-xs text-muted">Daten / Links / Fokus (Cobalt).</p>
      </div>
    </div>
  </section>

  <!-- Status washes -->
  <section class="mb-12">
    <h2 class="text-2xl font-bold text-heading mb-2 pb-2 border-b border-edge-strong">Status-Töne (rationiert)</h2>
    <p class="text-muted text-sm mb-6">
      Farbe ist ein knapper Kanal: nur Bedeutung, kein Schmuck. Im Dunkel werden die hellen Tints automatisch
      zu gedämpften dunklen Washes (zentral über <code class="bg-surface-shell px-1 rounded">--wash-*</code>).
    </p>
    <div class="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
      <div class="rounded-lg p-4 bg-red-50 text-red-800 border border-edge">Danger / Fehler</div>
      <div class="rounded-lg p-4 bg-amber-50 text-amber-800 border border-edge">Warning / Hinweis</div>
      <div class="rounded-lg p-4 bg-green-50 text-green-800 border border-edge">Success / Erledigt</div>
      <div class="rounded-lg p-4 bg-cobalt-50 text-cobalt-900 border border-edge">Info / System</div>
    </div>
  </section>

  <!-- How it works -->
  <section class="mb-12">
    <h2 class="text-2xl font-bold text-heading mb-6 pb-2 border-b border-edge-strong">Wie es funktioniert</h2>
    <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
      <div class="bg-surface-raised border border-edge rounded-lg p-6">
        <h3 class="font-bold text-heading mb-3">Ein Theme = nur ein Variablen-Override</h3>
        <ol class="list-decimal list-inside space-y-2 text-sm">
          <li><code class="bg-surface-shell px-1 rounded">:root</code> hält die <strong>Hell</strong>-Palette als rohe RGB-Tripel.</li>
          <li><code class="bg-surface-shell px-1 rounded">.dark</code> bzw. <code class="bg-surface-shell px-1 rounded">.theme-pop</code> überschreiben <em>nur</em> dieselben Variablen.</li>
          <li><code class="bg-surface-shell px-1 rounded">tailwind.config.js</code> mappt jede Farbklasse auf <code class="bg-surface-shell px-1 rounded">rgb(var(--x) / &lt;alpha&gt;)</code> (<code class="bg-surface-shell px-1 rounded">darkMode:'class'</code>).</li>
          <li>Das Inline-Script setzt <code class="bg-surface-shell px-1 rounded">.dark</code>/<code class="bg-surface-shell px-1 rounded">.theme-pop</code> auf <code class="bg-surface-shell px-1 rounded">&lt;html&gt;</code> — <strong>keine View-Änderung nötig</strong>.</li>
        </ol>
        <p class="text-xs text-muted mt-3">Definiert in <code class="bg-surface-shell px-1 rounded">app/assets/stylesheets/application.tailwind.css</code> + <code class="bg-surface-shell px-1 rounded">config/tailwind.config.js</code>.</p>
      </div>
      <div class="bg-surface-raised border border-edge rounded-lg p-6 overflow-x-auto">
        <h3 class="font-bold text-heading mb-3">Beispiel</h3>
<pre class="text-xs font-mono text-body leading-relaxed"><code>:root      { --cream-50: 250 248 245; --ink: 20 17 12; }
.dark      { --cream-50:  26  23  20; --ink: 196 188 172; }
.theme-pop { --cream-50: 255 255 255; --ink:   0   0   0; }

/* tailwind.config.js */
surface: 'rgb(var(--cream-50) / &lt;alpha-value&gt;)'

&lt;!-- View bleibt gleich --&gt;
&lt;div class="bg-surface text-heading"&gt;…&lt;/div&gt;</code></pre>
      </div>
    </div>
  </section>

  <!-- Comparison table -->
  <section class="mb-12">
    <h2 class="text-2xl font-bold text-heading mb-6 pb-2 border-b border-edge-strong">Vergleich</h2>
    <div class="border border-edge rounded-lg overflow-hidden">
      <table class="w-full text-sm">
        <thead>
          <tr class="bg-surface-shell text-heading text-left">
            <th class="px-4 py-3 font-bold border-b border-edge">Token / Rolle</th>
            <th class="px-4 py-3 font-bold border-b border-edge"><i class="bi bi-sun"></i> Hell</th>
            <th class="px-4 py-3 font-bold border-b border-edge"><i class="bi bi-moon-stars"></i> Dunkel</th>
            <th class="px-4 py-3 font-bold border-b border-edge"><i class="bi bi-palette"></i> Pop</th>
          </tr>
        </thead>
        <tbody>
          <% [
            ["surface (Grund)", "warmes Off-White", "warm-dunkel", "reinweiß"],
            ["ink / stroke (Strich)", "leiser Tinten-Strich", "heller warmer Strich", "hartes Schwarz"],
            ["Elevation", "Schatten + Rahmen", "Rahmen, raised heller (Schatten weg)", "harte Schatten + Rahmen"],
            ["btn-primary", "gefälliges Lime", "gefälliges Lime", "lautes Lime"],
            ["Status-Töne", "gedämpfte helle Tints", "dunkle Washes", "laute helle Tints"],
            ["Charakter", "ruhig / editorial", "ruhig / dunkel", "laut / brutalistisch"]
          ].each_with_index do |(role, hell, dunkel, pop), i| %>
            <tr class="<%= 'bg-surface' if i.odd? %>">
              <td class="px-4 py-3 font-mono font-bold text-heading border-b border-divider"><%= role %></td>
              <td class="px-4 py-3 border-b border-divider"><%= hell %></td>
              <td class="px-4 py-3 border-b border-divider"><%= dunkel %></td>
              <td class="px-4 py-3 border-b border-divider"><%= pop %></td>
            </tr>
          <% end %>
        </tbody>
      </table>
    </div>
  </section>

  <!-- Rules / invariants -->
  <section class="mb-12">
    <h2 class="text-2xl font-bold text-heading mb-6 pb-2 border-b border-edge-strong">Regeln & Invarianten</h2>
    <ul class="space-y-3 text-sm">
      <li class="flex items-start gap-3">
        <i class="bi bi-check-circle-fill text-info mt-0.5"></i>
        <span><strong>Semantische Tokens statt Hardcodes:</strong> <code class="bg-surface-shell px-1 rounded">bg-surface</code> statt <code class="bg-surface-shell px-1 rounded">bg-white</code>, <code class="bg-surface-shell px-1 rounded">border-edge</code> statt <code class="bg-surface-shell px-1 rounded">border-black</code>, <code class="bg-surface-shell px-1 rounded">text-heading/body/muted</code> statt <code class="bg-surface-shell px-1 rounded">text-gray-*</code>. Nur so flippt eine neue View automatisch mit.</span>
      </li>
      <li class="flex items-start gap-3">
        <i class="bi bi-check-circle-fill text-info mt-0.5"></i>
        <span><strong>Theme-unabhängig:</strong> <code class="bg-surface-shell px-1 rounded">scrim</code> (Modal-Backdrop) bleibt in <em>jedem</em> Theme dunkel; <code class="bg-surface-shell px-1 rounded">on-fill</code> (Text auf Farbe/Dunkel) bleibt in jedem Theme hell.</span>
      </li>
      <li class="flex items-start gap-3">
        <i class="bi bi-check-circle-fill text-info mt-0.5"></i>
        <span><strong>Aktions-Lime:</strong> Lime-Flächen (Primär-Button) sind in allen Themes hell → Text/Icons darauf immer dunkel & scharf (nie hell-auf-lime).</span>
      </li>
      <li class="flex items-start gap-3">
        <i class="bi bi-check-circle-fill text-info mt-0.5"></i>
        <span><strong>Dunkel-Elevation kehrt um:</strong> gehobene Flächen sind <em>heller</em> als der Grund (<code class="bg-surface-shell px-1 rounded">surface-raised</code> &gt; <code class="bg-surface-shell px-1 rounded">surface</code>); harte <code class="bg-surface-shell px-1 rounded">#000</code>-Schatten werden im Dunkel ausgeblendet, Tiefe kommt über Rahmen.</span>
      </li>
    </ul>

    <%= render 'style_guide/shared/rationale',
        title: "Warum ein Token-Layer",
        principles: ["G1", "G2", "G3"],
        body: "Eine einzige Palette als CSS-Variablen, drei Overrides — statt drei parallel gepflegter Stylesheets oder hunderter <code>dark:</code>-Varianten je Element. Neue Views erben Dark/Pop gratis, solange sie semantische Tokens nutzen. Vollständige Spec inkl. Begründung: doc/design_system.md Teil G (Farbsystem) und Teil I (Themes & Dark-Mode)." %>
  </section>
</div>