- Alle inline styles wurden zu Tailwind-Klassen konvertiert
- Verwendet Standard-Tailwind-Klassen ohne Prefix
- Funktioniert in allen Projekten (Maluhia, Utopia-Map, etc.)
- Einfacher zu überschreiben und wartungsfreundlicher
interface TurtleProps {
className?: string; // Zusätzliche CSS-Klassen
scale?: number; // Größenskalierung (z.B. 0.5 = 50%)
images?: { // Eigene Bildpfade
body?: string;
head?: string;
flipperLeft?: string;
flipperRight?: string;
flipperBack?: string;
};
animationSpeed?: number; // Animation schneller/langsamer (default: 1)
}<Turtle /><Turtle
images={{
body: '/assets/my-turtle-body.png',
head: '/assets/my-turtle-head.png',
flipperLeft: '/assets/my-turtle-left.png',
flipperRight: '/assets/my-turtle-right.png',
flipperBack: '/assets/my-turtle-back.png',
}}
/><Turtle
scale={0.5} // Halbe Größe
animationSpeed={2} // Doppelt so schnell
className="opacity-80" // Standard Tailwind ohne Prefix
/>{
"name": "@your-org/turtle-animation",
"version": "1.0.0",
"description": "Animated turtle component for React with Tailwind CSS",
"private": false,
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"files": [
"dist",
"README.md"
],
"scripts": {
"build": "tsc && vite build",
"prepublishOnly": "npm run build"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0",
"framer-motion": "^12.0.0",
"tailwindcss": "^4.0.0"
},
"devDependencies": {
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.3",
"tailwindcss": "^4.1.17",
"typescript": "^5.6.2",
"vite": "^5.4.10"
},
"keywords": [
"react",
"turtle",
"animation",
"tailwind",
"framer-motion",
"component"
],
"repository": {
"type": "git",
"url": "https://github.com/your-org/turtle-animation"
},
"license": "MIT"
}{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"jsx": "react-jsx",
"declaration": true,
"declarationMap": true,
"outDir": "./dist",
"rootDir": "./src",
"moduleResolution": "bundler",
"allowImportingTsExtensions": false,
"resolveJsonModule": true,
"isolatedModules": true,
"skipLibCheck": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { resolve } from 'path';
export default defineConfig({
plugins: [react()],
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'TurtleAnimation',
fileName: 'index',
formats: ['es']
},
rollupOptions: {
external: ['react', 'react-dom', 'framer-motion', 'tailwindcss'],
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'framer-motion': 'FramerMotion'
}
}
}
}
});export { Turtle } from './Turtle';
export type { TurtleProps } from './Turtle';module.exports = {
// KEIN prefix nötig - Komponente verwendet Standard-Tailwind
content: [
'./src/**/*.{js,jsx,ts,tsx}',
'./node_modules/@your-org/turtle-animation/dist/**/*.js' // Dein Package
],
// ... rest
}Hinweis für Projekte mit Prefix:
Wenn dein Projekt einen Prefix verwendet (z.B. tw:), musst du die Komponente wrappen oder die className-Prop verwenden, um Prefix-spezifische Klassen hinzuzufügen.
Die Turtle-Komponente erwartet folgende Bilder im selben Verzeichnis:
turtle_body.pngturtle_head.pngturtle_flipper_left.pngturtle_flipper_right.pngturtle_flipper_back.png
Optionen für Consumer:
- Bilder ins
public/Verzeichnis legen - Eigene Pfade via
imagesprop übergeben - Als Base64 einbetten (erhöht Bundle-Size)
Consumer müssen selbst installieren:
npm install react react-dom framer-motion tailwindcss- Framer Motion ist relativ groß (~50KB)
- Tailwind CSS wird nur Tree-Shaken wenn Consumer Tailwind nutzt
- Bilder sollten optimiert sein (WebP, komprimiert)
# 1. Build erstellen
npm run build
# 2. Test lokal (optional)
npm pack
npm install ./turtle-animation-1.0.0.tgz -D
# 3. Auf npm veröffentlichen
npm login
npm publish --access publicErstelle eine README.md mit:
- Installation instructions
- Usage examples
- Props documentation
- Image requirements
- Tailwind setup instructions
- Live demo (CodeSandbox/StackBlitz)
- Storybook für Dokumentation
- Unit Tests mit Vitest
- ESLint Config für Code Quality
- Prettier für Code Formatting
- GitHub Actions für automatische Releases
- Changeset für Version Management