- Added poyraz-ui preset CSS import to globals.css for styling. - Created theme-switcher.md documentation for reactive-switcher usage. - Added usage-guide.md for comprehensive Poyraz UI instructions. - Updated package.json to include reactive-switcher as a dependency. - Modified pnpm-lock.yaml to reflect the addition of reactive-switcher. - Established themes.ts to export Poyraz UI themes for use in the application.
10 KiB
Poyraz UI - Usage Guide (Detayli)
Bu dokuman, d:/Poyraz/kodlama/poyraz-ui reposunun guncel kaynak kodu uzerinden hazirlandi.
Hedef: UI kitin hem kullanici (consumer) tarafini hem de bu repoyu gelistirme tarafini tek yerde toplamak.
Versiyon referansi: 2.0.1
1) Proje Ozeti
Poyraz UI, React tabanli, Tailwind CSS v4 ile calisan, atomic design yaklasimi kullanan bir UI kit. Repo iki ana amaca hizmet ediyor:
- npm paketi olarak dagitilan UI kutuphanesi (
src,components/ui,dist) - Next.js App Router ile yazilmis canli dokumantasyon sitesi (
app)
Temel karakter:
- clean border odakli, minimum shadow
rounded-smkullanimina dayali yalin gorunum- semantic token sistemi (
--poyraz-*) - dark mode uyumlu
- atoms -> molecules -> organisms katmanlamasi
2) Dizin Yapisi (Gercek Kod Yapisi)
poyraz-ui/
|- app/ # Next.js docs sitesi
| |- docs/ # component/template dokumantasyon sayfalari
| |- globals.css # docs sitesi global css + dark override
| |- layout.tsx # next-themes + Toaster entegrasyonu
| `- page.tsx # landing/showcase
|- bin/
| `- cli.mjs # npx poyraz-ui init
|- components/
| |- ui/
| | |- atoms/ # 17 atom dosyasi
| | |- molecules/ # 22 molecule dosyasi
| | `- organisms/ # 5 organism dosyasi
| |- theme-provider.tsx # docs sitesi next-themes wrapper
| `- theme-toggle.tsx # docs sitesi toggle
|- lib/
| `- navigation.ts # docs nav/registry merkezi config
|- src/
| |- index.ts # ana export
| |- atoms/index.ts # atom export map
| |- molecules/index.ts # molecule export map
| |- organisms/index.ts # organism export map
| |- themes/index.ts # poyrazLightTheme / poyrazDarkTheme
| |- preset.css # token layer + @theme bridge
| `- utils.ts # cn()
|- dist/ # tsup output (publish edilen paket)
|- tsup.config.ts # 5 entry point, esm+cjs, dts
`- package.json
3) Kullanici Tarafi Kurulum (Consumer App)
3.1 Paket kurulumu
pnpm add poyraz-ui
# veya
npm install poyraz-ui
# veya
yarn add poyraz-ui
3.2 Zorunlu peer dependencies
react >= 18react-dom >= 18tailwindcss >= 4
Opsiyonel peer dependencies:
react-hook-form,@hookform/resolvers,zod(Form molecule icin)reactive-switcher(hazir theme objectleriyle dinamik tema gecisi icin)
3.3 CSS import (kritik)
Root global stylesheet dosyana ekle:
@import "tailwindcss";
@import "poyraz-ui/preset.css";
preset.css olmadan renk/font tokenlari dogru resolve edilmez.
3.4 Hemen kullanim
import { Button, Card, CardContent } from "poyraz-ui/atoms";
export function Demo() {
return (
<Card>
<CardContent className="p-4">
<Button>Merhaba</Button>
</CardContent>
</Card>
);
}
4) Import Stratejisi ve Entry Pointler
Paket 5 entry point sunuyor:
poyraz-uipoyraz-ui/atomspoyraz-ui/moleculespoyraz-ui/organismspoyraz-ui/themes
Onerilen yaklasim:
- Uretim projelerinde alt path importlarini kullan (
/atoms,/molecules,/organisms) - Gecis surecinde hiz icin ana barrel (
poyraz-ui) kullanabilirsin
Ornek:
import { Button, Badge } from "poyraz-ui/atoms";
import { Dialog } from "poyraz-ui/molecules";
import { Navbar } from "poyraz-ui/organisms";
import { poyrazLightTheme, poyrazDarkTheme } from "poyraz-ui/themes";
5) Tema Sistemi (En Onemli Altyapi)
Tema zinciri su sekilde calisiyor:
- Component classlari
bg-background,text-foreground,border-bordergibi semantic utility kullaniyor. src/preset.css,@themeile bunlari--color-*tokenlarina bagliyor.--color-*tokenlari,var(--poyraz-*, fallback)ile semantic CSS variable'a mapleniyor.- Sen
--poyraz-*degistirdiginde tum kit yeni temaya gecer.
5.1 Token katmanlari
- Base semantic variables:
--poyraz-background,--poyraz-foreground,--poyraz-primary, ... - Tailwind v4 bridge:
--color-background,--color-foreground, ... - Utility kullanim:
bg-background,text-muted-foreground, ...
5.2 Dark mode (class tabanli)
Docs sitesi next-themes kullaniyor ve html.dark altinda --poyraz-* override ediyor (app/globals.css).
5.3 reactive-switcher entegrasyonu
src/themes/index.ts icinde hazir theme objectleri var:
poyrazLightThemepoyrazDarkThemepoyrazThemes
Ornek:
import { ThemeProvider } from "reactive-switcher";
import { poyrazThemes } from "poyraz-ui/themes";
export function AppTheme({ children }: { children: React.ReactNode }) {
return <ThemeProvider themes={poyrazThemes}>{children}</ThemeProvider>;
}
6) Component Katalogu
Bu bolum src/*/index.ts export maplerine gore hazirlandi.
6.1 Atoms (17 component dosyasi)
- Avatar
- Badge
- Button
- Card
- Checkbox
- Input
- Label
- Logo
- Radio Group
- Separator
- Skeleton
- Switch
- Textarea
- Typography
- Form Fields (
NumberInput,SearchInput,PhoneInput,PasswordInput,UrlInput) - BG Patterns (
PatternDots,PatternGrid,PatternLines,PatternDiagonal,PatternCross,PatternCheckerboard,PatternDiamond,PatternZigzag,PatternDashedGrid,PatternRadial) - ScrollArea
6.2 Molecules (22 component dosyasi)
Core molecules:
- Accordion
- Alert
- Autocomplete
- Breadcrumb
- Calendar
- Command Palette
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Form
- Hover Card
- Modal
- Pagination
- Popover
- Select
- Sheet
- Sonner (
Toaster,toast) - Tabs
- Tooltip
Template molecules (card-templates):
- ArticleCard
- ImageCard
- NewsCard
- StatsCard
- TestimonialCard
- PricingCard
- ProductCard
6.3 Organisms (5 component dosyasi)
- Navbar
- Sidebar
- Footer
- AnnouncementBar
- DataTable
7) Hazir Template Sayfalari (Docs Icinde)
app/docs/templates altinda 4 kopyalanabilir sayfa semasi var:
- Hero
- Pricing
- Dashboard
- Auth
Onemli not:
- Bunlar npm paketi icinde "template component" olarak export edilmiyor.
- Kaynagi kopyalayip projenin ihtiyacina gore duzenleme modeli kullaniliyor.
8) Dokumantasyon Sitesi Mimarisi
app/docs altinda:
- toplam
53adetpage.tsx - atoms:
18 - molecules:
22 - organisms:
6 - templates:
5
Merkezi nav/registry:
lib/navigation.ts- sidebardaki kategori sayilari ve slug donusumu burada yonetiliyor (
toSlug)
9) CLI: npx poyraz-ui init
CLI (bin/cli.mjs) su adimlari yapar:
- CSS dosyasini otomatik tespit eder (
app/globals.css,src/app/globals.cssvb.) @import "poyraz-ui/preset.css";satirini ekler- Opsiyonel olarak
reactive-switchertema dosyasi scaffold eder - Layout icin ThemeProvider snippet'i gosterir
Manual kurulum yerine hizli onboarding icin ideal.
10) Build, Bundle ve Publish Akisi
10.1 Scriptler
pnpm dev: docs sitesipnpm build: library + docs production buildpnpm build:lib: sadece library (tsup)pnpm start: next production servepnpm prepublishOnly: publish oncesi otomatikbuild:lib
10.2 tsup ozeti
tsup.config.ts:
- 5 entry point uretir (
index,atoms/index,molecules/index,organisms/index,themes/index) - format:
esm + cjs dts: truesplitting + treeshake + clean- build sonrasi
distdosyalarina"use client"directive inject eder
10.3 package export haritasi
package.json exports alani:
- alt path importlarini hem ESM hem CJS ile aciklar
./preset.cssdogrudansrc/preset.css'e yonlenir
11) Bu Repoda Yeni Component Ekleme Rehberi
11.1 Kod ekleme
- Component dosyasini
components/ui/<layer>/altina ekle - Gerekirse type exportlarini component dosyasinda tanimla
11.2 Export haritasi
src/<layer>/index.tsicine export satirlarini ekle- Gerekliyse
src/index.tsana barrel kontrol et
11.3 Docs entegrasyonu
app/docs/<layer>/<component>/page.tsxolustur- Kategori index sayfasina link ekle (
app/docs/<layer>/page.tsx) lib/navigation.tsicindekicomponentRegistrylistesine ekle
11.4 Dogrulama
pnpm build:libpnpm devile docs sayfasini ve importlarini test et
12) Sik Kullanilan Kullanim Patternleri
12.1 Form stack
- Atoms:
Input,Label,Checkbox,Button - Molecules:
Form,Select,DatePicker,Autocomplete
12.2 Overlay stack
Dialog,Modal,Drawer,Sheet,Popover,Tooltip- Her biri Radix/Vaul primitive uzerinden geldigi icin a11y ve keyboard destegi yuksek
12.3 Navigation stack
Navbar(desktop + mobile panel)Sidebar(collapsible/floating/mini varyantlar)Footer(layout varyantlari)
12.4 Data stack
DataTable+Badge+Pagination- dashboard tarzinda
StatsCard,Card,Avatarile birlikte kullaniliyor
13) Bilinen Durumlar / Dikkat Noktalari
Mermaiddokumantasyon sayfasi var (app/docs/molecules/mermaid/page.tsx) ancak su andasrc/molecules/index.tsicinden export edilmiyor.componentRegistrymolecules listesi ile molecules landing page listesi tam birebir degil (sidebar listesinde Mermaid yok).- Template sayfalari (Hero/Pricing/Dashboard/Auth) paket exportu degil; kopyala-ozellestir modeli.
- Rehber ve README metinlerinde bilesen sayilari bazen farkli geciyor; son karar noktasi her zaman
src/*/index.tsexport mapidir.
14) Hizli Referans
14.1 Consumer app checklist
poyraz-uipaketini kur@import "poyraz-ui/preset.css";eklepoyraz-ui/atomsveyapoyraz-ui/moleculesuzerinden import et- Tema gerekiyorsa
--poyraz-*override et veyapoyraz-ui/themeskullan
14.2 Repo contributor checklist
- component dosyasi ekle (
components/ui) - export map guncelle (
src/*/index.ts) - docs page ekle (
app/docs/...) - navigation registry guncelle (
lib/navigation.ts) pnpm build:libvepnpm devile dogrula
15) Ek Kaynaklar
- Paket genel tanitim:
README.md - Genis API referansi:
COMPONENTS.md - Theme switcher notlari:
theme-switcher.md - Kurulum sayfasi referansi:
app/docs/installation/page.tsx
Bu dokuman "proje ici operasyonel guide" amaciyla yazildi. Paketin public-facing README'sini sade tutup, bu dosyayi teknik detay merkezi olarak kullanman tavsiye edilir.