# @ocelot-social/ui - Projektdokumentation > Dieses Dokument dient als zentrale Planungs- und Statusübersicht für das UI-Library Subprojekt. > Es ermöglicht das Pausieren und Wiederaufnehmen der Arbeit zu jedem Zeitpunkt. --- ## 1. Projektziel & Vision **Kurzbeschreibung:** Neue Vue 3 Komponentenbibliothek aufbauen, die später die Vue 2 Komponenten in der Webapp ersetzen soll. **Hintergrund:** - Bestehendes Projekt nutzt Vue 2.6 mit Nuxt 2 (Upgrade auf Vue 2.7 erforderlich) - Existierender `styleguide` Ordner als Git-Submodul (Vue 2, Vue CLI 3) - Design-Token-System mit Theo vorhanden - Branding erfolgt über SCSS-Dateien mit Variablen-Overrides - **Problem:** Viele doppelte Komponenten, inkonsistente Styles, nicht konsequent genutztes Design-System **Vision:** Ein stark definiertes und flexibles Design-System, das den Branding-Anforderungen von ocelot.social gerecht wird und eine saubere, schrittweise Migration von Vue 2 nach Vue 3 ermöglicht. **Geplanter Ansatz:** Migration vorbereiten - schrittweise neue Komponenten in Vue 3 entwickeln, die das bestehende Design-System respektieren und flexible Branding-Optionen bieten. --- ## 2. Tech-Stack | Komponente | Entscheidung | Notizen | |------------|--------------|---------| | Framework | **Vue 3 + Vite** | Schnellstes Setup, modernes Tooling | | Build-Tool | **Vite** | Schnelles HMR, einfache Konfiguration | | Dokumentation | **Histoire** | Vite-native Storybook-Alternative | | Styling | **Tailwind CSS** | Mit CSS Custom Properties für Branding | | Testing | **Vitest** | Vite-nativ, Jest-kompatible API | | Paket-Name | **@ocelot-social/ui** | Unter ocelot-social npm Org | | Komponenten-Prefix | **Os** | OsButton, OsCard, etc. | | Vue 2 Kompatibilität | **vue-demi** | Library funktioniert in Vue 2 und Vue 3 | | Linting | **eslint-config-it4c** | Enthält: TypeScript, Vue, Prettier, weitere Regeln | | Release | **release-please** | Automatische Versionen und Changelogs | | Icons | **Hybrid-Architektur** | System-Icons in Library, Feature-Icons in App (siehe Abschnitt 15) | | Browser-Support | **Modern only** | Chrome, Firefox, Safari, Edge (letzte 2 Versionen) | | SSR | **Ja** | Nuxt-kompatibel | | Dark Mode | **Ja, von Anfang an** | Alle Komponenten mit Light/Dark Varianten | | Lizenz | **Apache 2.0** | Permissiv mit Patent-Schutz | | Repository | **Monorepo** | Ocelot-Social/packages/ui/ | ### Konventionen | Aspekt | Entscheidung | Notizen | |--------|--------------|---------| | Vue API | **` ``` ### Checkliste bei neuer Komponente Vor dem Erstellen einer Komponente diese Fragen beantworten: ``` [ ] Wo gehört die Komponente hin? (Entscheidungsbaum durchlaufen) [ ] Falls Library: Sind alle Texte via Props? [ ] Falls Library: Keine direkten Store/Router Imports? [ ] Falls Webapp: Welche Library-Komponenten werden genutzt? [ ] Falls Grenzfall: Kann sie aufgeteilt werden? ``` --- ## 18. Externe Abhängigkeiten ### Übersicht Einige Aufgaben in diesem Projekt sind von externen Projekten abhängig, die zuerst angepasst werden müssen. | Abhängigkeit | Status | Blockiert | Beschreibung | |--------------|--------|-----------|--------------| | **eslint-config-it4c** | ⚠️ Offen | Phase 2: Linting | Paket muss modularer werden | ### eslint-config-it4c **Repository:** [it4c/eslint-config-it4c](https://github.com/IT4Change/eslint-config-it4c) _(vermutlich)_ **Problem:** Das Paket ist aktuell nicht modular genug, um in der UI-Library eingesetzt zu werden. Es muss angepasst werden, um: - Einzelne Regelsets separat importierbar zu machen (TypeScript, Vue, Prettier, JSDoc) - Flexible Konfiguration für verschiedene Projekttypen zu ermöglichen - Kompatibel mit dem Flat Config Format (ESLint 9+) zu sein **Erforderliche Änderungen im externen Projekt:** ``` eslint-config-it4c/ ├── base.js # Basis-Regeln ├── typescript.js # TypeScript-Regeln (optional) ├── vue.js # Vue-Regeln (optional) ├── prettier.js # Prettier-Integration (optional) ├── jsdoc.js # JSDoc-Regeln (optional) └── index.js # Alles kombiniert (Vollversion) ``` **Gewünschte Nutzung in @ocelot-social/ui:** ```javascript // eslint.config.js import baseConfig from 'eslint-config-it4c/base' import typescriptConfig from 'eslint-config-it4c/typescript' import vueConfig from 'eslint-config-it4c/vue' import prettierConfig from 'eslint-config-it4c/prettier' import jsdocConfig from 'eslint-config-it4c/jsdoc' export default [ ...baseConfig, ...typescriptConfig, ...vueConfig, ...prettierConfig, ...jsdocConfig, { // Projekt-spezifische Overrides } ] ``` **Workaround bis Abhängigkeit erfüllt:** - Temporär eigene ESLint-Konfiguration in packages/ui erstellen - Nach Modularisierung von eslint-config-it4c migrieren **Tracking:** - [ ] Issue in eslint-config-it4c erstellen - [ ] Modulare Struktur implementieren - [ ] Neue Version releasen - [ ] In @ocelot-social/ui einbinden --- ## 19. Kompatibilitätstests (Vue 2/3 + Tailwind/CSS) ### Testmatrix Die Library muss in 4 Kombinationen funktionieren: ``` │ Tailwind │ CSS (vorkompiliert) ────────────────────┼───────────────────┼────────────────────── Vue 3.4+ │ ✓ Muss testen │ ✓ Muss testen Vue 2.7 │ ✓ Muss testen │ ✓ Muss testen ``` ### Werkzeuge & Strategien #### 1. vue-demi (Code-Ebene) Abstrahiert Vue 2/3 API-Unterschiede: ```typescript // Komponente importiert von vue-demi, nicht vue import { ref, computed, defineComponent } from 'vue-demi' ``` #### 2. Unit Tests mit Vitest (Vue 2/3 Matrix) ```typescript // vitest.config.ts export default defineConfig({ test: { alias: { 'vue': process.env.VUE_VERSION === '2' ? 'vue2.7' : 'vue' } } }) ``` #### 3. Example Apps (4 Kombinationen) ``` packages/ui/ ├── examples/ │ ├── vue3-tailwind/ # Vite + Vue 3 + Tailwind Preset │ │ ├── package.json │ │ ├── vite.config.ts │ │ ├── tailwind.config.js # Nutzt @ocelot-social/ui/tailwind.preset │ │ └── src/App.vue # Importiert alle Komponenten │ │ │ ├── vue3-css/ # Vite + Vue 3 + styles.css │ │ ├── package.json │ │ ├── vite.config.ts │ │ └── src/ │ │ ├── main.ts # import '@ocelot-social/ui/styles.css' │ │ └── App.vue │ │ │ ├── vue2-tailwind/ # Vue CLI / Nuxt 2 + Tailwind │ │ └── ... │ │ │ └── vue2-css/ # Vue CLI / Nuxt 2 + styles.css │ └── ... ``` **Jede Example App:** - Importiert `@ocelot-social/ui` via Workspace-Link - Rendert alle exportierten Komponenten - Kann lokal gestartet werden (`npm run dev`) - Wird in CI gebaut und getestet #### 4. Playwright E2E Tests ```typescript // e2e/compatibility.spec.ts import { test, expect } from '@playwright/test' const examples = [ { name: 'vue3-tailwind', port: 3001 }, { name: 'vue3-css', port: 3002 }, { name: 'vue2-tailwind', port: 3003 }, { name: 'vue2-css', port: 3004 }, ] for (const example of examples) { test.describe(example.name, () => { test('all components render', async ({ page }) => { await page.goto(`http://localhost:${example.port}`) // Prüfe dass alle Komponenten sichtbar sind await expect(page.locator('[data-testid="os-button"]')).toBeVisible() await expect(page.locator('[data-testid="os-card"]')).toBeVisible() await expect(page.locator('[data-testid="os-modal"]')).toBeVisible() }) test('styles are applied correctly', async ({ page }) => { await page.goto(`http://localhost:${example.port}`) const button = page.locator('[data-testid="os-button-primary"]') // Prüfe dass CSS korrekt angewendet wird await expect(button).toHaveCSS('background-color', /rgb/) }) test('visual regression', async ({ page }) => { await page.goto(`http://localhost:${example.port}`) await expect(page).toHaveScreenshot(`${example.name}.png`) }) }) } ``` #### 5. Package Validation | Tool | Zweck | |------|-------| | **publint** | Prüft package.json auf Export-Fehler | | **arethetypeswrong** | Prüft TypeScript-Typen für alle Entry Points | ```json { "scripts": { "check:exports": "publint && attw --pack .", "prepublishOnly": "npm run check:exports" } } ``` #### 6. package.json Exports (korrekte Struktur) ```json { "name": "@ocelot-social/ui", "type": "module", "exports": { ".": { "import": "./dist/index.mjs", "require": "./dist/index.cjs", "types": "./dist/index.d.ts" }, "./styles.css": "./dist/styles.css", "./tailwind.preset": { "import": "./dist/tailwind.preset.mjs", "require": "./dist/tailwind.preset.cjs", "types": "./dist/tailwind.preset.d.ts" } }, "peerDependencies": { "vue": "^2.7.0 || ^3.0.0" }, "peerDependenciesMeta": { "tailwindcss": { "optional": true } } } ``` ### CI Workflow: Compatibility Matrix ```yaml # .github/workflows/compatibility.yml name: Compatibility Tests on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '20' - run: npm ci - run: npm run build - uses: actions/upload-artifact@v4 with: name: dist path: packages/ui/dist test-unit: needs: build runs-on: ubuntu-latest strategy: fail-fast: false matrix: vue-version: ['2.7', '3.4'] steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: name: dist path: packages/ui/dist - run: npm ci - run: npm test env: VUE_VERSION: ${{ matrix.vue-version }} test-e2e: needs: build runs-on: ubuntu-latest strategy: fail-fast: false matrix: example: ['vue3-tailwind', 'vue3-css', 'vue2-tailwind', 'vue2-css'] steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: name: dist path: packages/ui/dist - name: Setup example app working-directory: packages/ui/examples/${{ matrix.example }} run: | npm ci npm run build - name: Start preview server working-directory: packages/ui/examples/${{ matrix.example }} run: npm run preview & - name: Wait for server run: npx wait-on http://localhost:4173 --timeout 30000 - name: Run Playwright tests working-directory: packages/ui run: npx playwright test --grep "${{ matrix.example }}" - uses: actions/upload-artifact@v4 if: failure() with: name: playwright-report-${{ matrix.example }} path: packages/ui/playwright-report/ validate-package: needs: build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: name: dist path: packages/ui/dist - run: npm ci - name: Validate exports run: | npx publint packages/ui npx @arethetypeswrong/cli packages/ui ``` ### Werkzeug-Übersicht | Werkzeug | Zweck | Phase | |----------|-------|-------| | **vue-demi** | Vue 2/3 API-Kompatibilität im Code | Phase 2 | | **Vitest + Matrix** | Unit Tests für Vue 2.7 und Vue 3.4 | Phase 2 | | **Example Apps (4x)** | Echte Projekte für jede Kombination | Phase 2 | | **Playwright** | E2E + Visual Regression für alle 4 | Phase 2 | | **publint** | Package.json Export-Validierung | Phase 2 | | **arethetypeswrong** | TypeScript Entry Points Check | Phase 2 | | **pkg-pr-new** | Preview-Releases in PRs (optional) | Optional | ### Checkliste für neue Komponenten ``` [ ] Unit Tests laufen mit VUE_VERSION=2.7 [ ] Unit Tests laufen mit VUE_VERSION=3.4 [ ] Komponente in allen 4 Example Apps hinzugefügt [ ] E2E Tests für Komponente geschrieben [ ] Visual Regression Baseline erstellt [ ] Keine Vue 3-only APIs verwendet (oder via vue-demi abstrahiert) ``` --- ## Wie dieses Dokument verwendet wird **Zum Fortsetzen der Arbeit:** > "Lass uns am @ocelot-social/ui Projekt weiterarbeiten" (packages/ui) **Nach jeder Session aktualisieren:** - Abschnitt 9: "Fortschritt" - Abschnitt 10: "Aktueller Stand" - Abschnitt 12: "Arbeitsprotokoll" - KATALOG.md (ab Phase 0) - Meilenstein-Checklisten in Abschnitt 8