odevbutton
v1.0.0
Published
_**Bu proje patika.dev react ödevleri kapsamında geliştirilmiştir.**_
Readme
odevbutton
Bu proje patika.dev react ödevleri kapsamında geliştirilmiştir.
odevbutton, farklı stillerde butonlar sunan, hafif ve yeniden kullanılabilir bir React Button component kütüphanesidir.
Bu kütüphane ESM (ES Module) tabanlıdır ve React projelerinde kolayca kullanılabilir.
Kurulum
npm install odevbuttonKullanım
Önemli:
Stil dosyası (index.css) kullanıcı tarafından manuel olarak import edilmelidir.
import { Button } from "odevbutton";
import "odevbutton/dist/index.css";
function App() {
return (
<div>
<Button type='primary'>Primary</Button>
<Button type='default'>Default</Button>
<Button type='dashed'>Dashed</Button>
<Button type='text'>Text</Button>
<Button type='link'>Link</Button>
</div>
);
}
export default App;Props
Button Props
| Prop | Tip | Varsayılan | Açıklama |
| -------- | ------ | ---------- | ------------------------------------------------------------ |
| type | string | default | Button tipi (primary, default, dashed, text, link) |
| children | node | - | Button içeriği |
| ...props | - | - | Tüm standart HTML button attributeleri desteklenir |
Runtime Validation
Bu component, type prop’u için runtime validation içerir.
Eğer type prop’una desteklenmeyen bir değer gönderilirse:
- Uygulama hata vermez
- Button render edilmeye devam eder
- Console’da uyarı (warning) basılır
- Otomatik olarak
defaulttipe düşülür
Örnek
<Button type='invalidType'>Test</Button>Console çıktısı:
[odevbutton] Invalid button type "invalidType". Falling back to "default".Desteklenen Button Tipleri
primarydefaultdashedtextlink
React Uyumluluğu
Bu paket React’i peer dependency olarak kullanır.
Desteklenen sürümler:
- React
>= 18
Geliştirme
Projeyi build etmek için:
npm run buildTeknolojiler
- React
- JavaScript (JSX)
- tsup
- ESM (ES Module)
Lisans
MIT
