Gruppen-Plugin 1.0.0
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
5bdfb8a082
49 changed files with 4679 additions and 0 deletions
63
inhaus-sdk/theme.css
Normal file
63
inhaus-sdk/theme.css
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Automatisch erzeugt (scripts/generate-sdk-shims.mjs) – Design-Tokens des Portals.
|
||||
* In der style.css eines Plugins: @import "../../inhaus-sdk/theme.css";
|
||||
* Farben, Ecken und Schrift folgen so dem Erscheinungsbild der Installation.
|
||||
*
|
||||
* Tailwind-Klassen in Plugins tragen das Präfix „ih:“ (z. B. ih:grid, ih:lg:grid-cols-2, ih:bg-brand).
|
||||
* So kann das CSS eines Plugins nie die Klassen des Portals überschreiben.
|
||||
* Nur Hilfsklassen – Grundstile (Preflight) bringt das Portal selbst mit.
|
||||
*/
|
||||
@import "tailwindcss/theme" layer(theme) prefix(ih);
|
||||
@import "tailwindcss/utilities" layer(utilities);
|
||||
@custom-variant dark (&:is(.dark *));
|
||||
|
||||
@theme inline {
|
||||
--font-sans: var(--font-body);
|
||||
|
||||
--radius-sm: calc(var(--radius) - 4px);
|
||||
--radius-md: calc(var(--radius) - 2px);
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: calc(var(--radius) * 1.5);
|
||||
--radius-2xl: calc(var(--radius) * 2);
|
||||
/* „Pille“: voll gerundet – außer bei „Eckig“ im Erscheinungsbild (dann 0) */
|
||||
--radius-pill: calc(var(--radius) * 1000);
|
||||
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--color-card: var(--card);
|
||||
--color-card-foreground: var(--card-foreground);
|
||||
--color-popover: var(--popover);
|
||||
--color-popover-foreground: var(--popover-foreground);
|
||||
--color-primary: var(--primary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-destructive: var(--destructive);
|
||||
--color-border: var(--border);
|
||||
--color-input: var(--input);
|
||||
--color-ring: var(--ring);
|
||||
|
||||
--color-brand: var(--brand);
|
||||
--color-brand-foreground: var(--brand-foreground);
|
||||
--color-brand-text: var(--brand-text);
|
||||
--color-accent2: var(--accent2);
|
||||
--color-accent2-foreground: var(--accent2-foreground);
|
||||
--color-accent2-text: var(--accent2-text);
|
||||
--color-brand-soft: var(--brand-soft);
|
||||
--color-brand-soft-foreground: var(--brand-soft-foreground);
|
||||
--color-brand-50: var(--brand-50);
|
||||
--color-brand-100: var(--brand-100);
|
||||
--color-brand-200: var(--brand-200);
|
||||
--color-brand-300: var(--brand-300);
|
||||
--color-brand-400: var(--brand-400);
|
||||
--color-brand-500: var(--brand-500);
|
||||
--color-brand-600: var(--brand-600);
|
||||
--color-brand-700: var(--brand-700);
|
||||
--color-brand-800: var(--brand-800);
|
||||
--color-brand-900: var(--brand-900);
|
||||
--color-brand-950: var(--brand-950);
|
||||
}
|
||||
127
inhaus-sdk/vite.js
Normal file
127
inhaus-sdk/vite.js
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/**
|
||||
* Vite-Voreinstellung für Inhaus-Plugins (Plugin-SDK).
|
||||
*
|
||||
* // vite.config.js im Plugin
|
||||
* import { defineConfig } from 'vite';
|
||||
* import { inhausPlugin } from './inhaus-sdk/vite.js';
|
||||
* export default defineConfig(inhausPlugin());
|
||||
*
|
||||
* Baut jede Vue-Datei unter resources/js/{pages,widgets,blocks,profile,profile-panels,editorial,header}/
|
||||
* als eigenes ES-Modul nach dist/ und schreibt dist/inhaus.json. Vue, Inertia und @inhaus/ui
|
||||
* bleiben extern – das Portal stellt sie per Import Map bereit.
|
||||
*/
|
||||
import { existsSync, globSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import postcss from 'postcss';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
|
||||
export const KINDS = ['pages', 'widgets', 'blocks', 'profile', 'profile-panels', 'editorial', 'header'];
|
||||
export const EXTERNAL = ['vue', '@inertiajs/vue3', '@inhaus/ui'];
|
||||
|
||||
export function inhausPlugin({ root = process.cwd() } = {}) {
|
||||
const input = {};
|
||||
|
||||
for (const kind of KINDS) {
|
||||
for (const file of globSync(`resources/js/${kind}/**/*.vue`, { cwd: root })) {
|
||||
const name = file.replace(`resources/js/${kind}/`, '').replace(/\.vue$/, '');
|
||||
input[`${kind}/${name}`] = resolve(root, file);
|
||||
}
|
||||
}
|
||||
|
||||
if (existsSync(resolve(root, 'resources/css/style.css'))) {
|
||||
input.style = resolve(root, 'resources/css/style.css');
|
||||
}
|
||||
|
||||
if (Object.keys(input).length === 0) {
|
||||
throw new Error('Keine Oberfläche gefunden: Vue-Dateien gehören nach resources/js/<pages|widgets|blocks|profile|profile-panels|editorial|header>/.');
|
||||
}
|
||||
|
||||
return {
|
||||
plugins: [vue(), tailwindcss(), manifest(Object.keys(input)), strongerVariants()],
|
||||
// Plugins laufen unter /plugin-assets/<slug>/<version>/ – Pfade relativ halten
|
||||
base: './',
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
emptyOutDir: true,
|
||||
target: 'es2022',
|
||||
rollupOptions: {
|
||||
input,
|
||||
external: EXTERNAL,
|
||||
preserveEntrySignatures: 'strict',
|
||||
output: {
|
||||
format: 'es',
|
||||
entryFileNames: '[name].js',
|
||||
chunkFileNames: 'chunks/[name]-[hash].js',
|
||||
assetFileNames: 'assets/[name]-[hash][extname]',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** dist/inhaus.json: welche Komponente in welcher Datei steckt, welches CSS dazugehört */
|
||||
function manifest(entries) {
|
||||
return {
|
||||
name: 'inhaus-manifest',
|
||||
generateBundle(_, bundle) {
|
||||
const components = {};
|
||||
const css = [];
|
||||
|
||||
for (const file of Object.values(bundle)) {
|
||||
if (file.type === 'chunk' && file.isEntry && entries.includes(file.name) && file.name !== 'style') {
|
||||
components[file.name] = file.fileName;
|
||||
}
|
||||
|
||||
if (file.type === 'asset' && file.fileName.endsWith('.css')) {
|
||||
css.push(file.fileName);
|
||||
}
|
||||
}
|
||||
|
||||
// Leere Hülle des CSS-Einstiegs nicht ausliefern
|
||||
for (const [key, file] of Object.entries(bundle)) {
|
||||
if (file.type === 'chunk' && file.name === 'style') delete bundle[key];
|
||||
}
|
||||
|
||||
this.emitFile({ type: 'asset', fileName: 'inhaus.json', source: JSON.stringify({ components, css: [...new Set(css)] }, null, 4) });
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Mehrere Plugins bringen jeweils eigenes CSS mit, und dieselbe Hilfsklasse (z. B. ih:grid) kann in
|
||||
* mehreren Dateien stehen. Lädt ein anderes Plugin sein CSS später, würde dessen „ih:grid“ sonst
|
||||
* die Varianten dieses Plugins (ih:lg:hidden, ih:hover:…) überstimmen. Deshalb bekommen Regeln
|
||||
* mit Variante (Media Query, :hover …) eine doppelte Klasse – sie gewinnen so immer gegen
|
||||
* einfache Klassen, egal in welcher Reihenfolge die Dateien laden.
|
||||
*/
|
||||
export function strongerVariants() {
|
||||
const pseudo = /(?<!\\):/;
|
||||
const firstClass = /\.((?:\\.|[\w-])+)/;
|
||||
|
||||
return {
|
||||
name: 'inhaus-stronger-variants',
|
||||
enforce: 'post',
|
||||
generateBundle(_, bundle) {
|
||||
for (const file of Object.values(bundle)) {
|
||||
if (file.type !== 'asset' || !file.fileName.endsWith('.css')) continue;
|
||||
|
||||
const root = postcss.parse(String(file.source));
|
||||
|
||||
root.walkRules((rule) => {
|
||||
let conditional = false;
|
||||
|
||||
for (let parent = rule.parent; parent && parent.type !== 'root'; parent = parent.parent) {
|
||||
if (parent.type === 'atrule' && parent.name !== 'layer') conditional = true;
|
||||
}
|
||||
|
||||
rule.selectors = rule.selectors.map((selector) => (conditional || pseudo.test(selector.replace(/^[^.]*/, ''))) && firstClass.test(selector)
|
||||
? selector.replace(firstClass, (match) => match + match)
|
||||
: selector);
|
||||
});
|
||||
|
||||
file.source = root.toString();
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue