Framework DOM JavaScript yang bisa dibaca seperti kalimat manusia. Tanpa build tool. Tanpa boilerplate. Langsung jalan.
Kobar bukan sekadar library β ini cara baru nulis JavaScript DOM. Setiap method dirancang agar bisa dibaca seperti instruksi biasa.
Method name otomatis diparse jadi aksi DOM. Tidak perlu hafal API β cukup tulis apa yang kamu mau.
Elemen belum ada di DOM? Tidak masalah. Aksi masuk antrian, dijalankan otomatis begitu elemen muncul.
Load HTML component secara async dan inject data ke template dengan satu perintah.
SPA routing dengan konfigurasi JSON. Tidak perlu setup apapun β tinggal isi route.json.
Hampir semua method bisa di-chain. Tulis logic panjang dalam satu ekspresi yang tetap rapi.
Tidak ada npm install yang panjang. Tidak ada node_modules 300MB. Satu file, langsung jalan.
Kode yang sama, cara baca yang jauh berbeda.
// β Dengan Kobar Kobar.getElement("#btn") .onTheClassActive() .onTheStyleColorItsWhite() .onTheStyleBackgroundColorItsBlue() .onTheClick(handleClick); // β Vanilla JS yang sama const btn = document.querySelector("#btn"); btn.classList.add("active"); btn.style.color = "white"; btn.style.backgroundColor = "blue"; btn.addEventListener("click", handleClick);
// Ambil nilai, cek kosong, serialize const nama = Kobar.getElement("#nama").getValue(); if (Kobar.getElement("#nama").checkIfEmpty()) { Kobar.getElement("#nama") .focusIt() .onTheClassIsError(); } // Serialize semua input dalam form const data = Kobar.getElement("#form").serializeIt(); // β { nama: "...", email: "...", role: "..." }
// Navigasi DOM β langsung chain Kobar.getElement("#item") .goToParent() .onTheClassHighlight(); // Anak ke-0 β langsung chain proxy Kobar.getElement("#list") .goToChildren(0) .onTheStyleColorItsGold(); // Semua anak β otomatis ke setiap elemen Kobar.getElement("#list") .goToChildren() .onTheClassVisible();
// Load & render component dengan data const { kartuProfil } = await Kobar.useComponentFromKartu(); const html = await kartuProfil.data({ nama: "Azqilana", pesan: "Halo dunia!", url: "https://azqilana.my.id" }); Kobar.getElement("#kontainer") .onTheHtml(html);
Setiap prefix punya makna. Baca kodenya β kamu langsung tahu apa yang terjadi.
.onTheClassActive()
.onTheStyleColorItsRed()
.onTheAttrDisabled()
.onTheTextHello()
.onTheClick(fn)
.offTheClassActive()
.offTheStyleColor()
.offTheAttrDisabled()
.offTheText()
.offTheClick(fn)
.toggleTheClassOpen()
.toggleTheClassOpenWithClose()
.toggleTheStyleColorItsBlueWithRed()
.toggleTheTextOnWithOff()
.checkTheClassActive()
.checkTheStyleColorItsRed()
.checkTheAttrDisabled()
.checkTheTextHello()
.goToParent()
.goToNext() / .goToPrev()
.goToChildren(index?)
.goToSiblings(index?)
.goToClosest(".modal")
.putInside(html)
.putInsideFirst(html)
.putBefore(html)
.putAfter(html)
.takeOut()
.getValue() / .setValue()
.clearValue() / .focusIt()
.checkIfEmpty()
.serializeIt()
.fadeIn() / .fadeOut()
.showIt() / .hideIt()
.scrollTo()
/ .scrollDown()
.checkIfVisible()
npx create-kobar nama-project
Scaffold otomatis β struktur folder, config routing, semua siap.
Kobar.register("beranda", () => { ... })
Logic per halaman diisolasi rapi. Tidak ada global yang berantakan.
Kobar.getElement("#btn").onTheClassActive()
Tidak perlu belajar API baru. Baca kodenya β kamu langsung tahu apa yang terjadi.