kaff-components 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -8
- package/dist/index.d.mts +15 -6
- package/dist/index.d.ts +15 -6
- package/dist/index.js +7 -13
- package/dist/index.mjs +6 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,69 @@
|
|
|
1
|
-
|
|
1
|
+
🎨 Tema
|
|
2
|
+
VisualMinimalis & Konsisten: Berfokus pada kejelasan antarmuka dengan penerapan prinsip styled design pada warna, spacing, dan typography untuk menciptakan UI yang bersih dan modern.
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
📦 Instalasi
|
|
5
|
+
Gunakan npm untuk menginstal library ini ke dalam proyek Anda:Bashnpm install kaff-components@latest
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
🚀 Penggunaan (Usage)
|
|
8
|
+
Library ini mengembalikan objek HTML asli (HTMLElement). Untuk menggunakannya di framework modern seperti React, gunakan useRef dan appendChild untuk merender komponen ke dalam DOM.1. Implementasi Layout & NavigasiBerikut adalah contoh penggunaan komponen Navbar, Sidebar, dan Button dalam satu dashboard interaktif:JavaScript
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
import { useEffect, useRef, useState } from 'react';
|
|
11
|
+
import { Navbar, Sidebar, Button } from 'kaff-components';
|
|
12
|
+
|
|
13
|
+
function App() {
|
|
14
|
+
const [active, setActive] = useState('dashboard');
|
|
15
|
+
const navRef = useRef(null);
|
|
16
|
+
const sideRef = useRef(null);
|
|
17
|
+
const contentRef = useRef(null);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
// Render Navbar dengan Kustomisasi
|
|
21
|
+
if (navRef.current) {
|
|
22
|
+
navRef.current.innerHTML = '';
|
|
23
|
+
navRef.current.appendChild(Navbar({
|
|
24
|
+
brand: 'Kaff Design System',
|
|
25
|
+
backgroundColor: '#007bff',
|
|
26
|
+
links: []
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Render Sidebar & Logika Navigasi
|
|
31
|
+
if (sideRef.current) {
|
|
32
|
+
sideRef.current.innerHTML = '';
|
|
33
|
+
const sidebarElement = Sidebar({
|
|
34
|
+
items: ['Button', 'Input', 'Card'],
|
|
35
|
+
activeColor: '#333'
|
|
36
|
+
});
|
|
37
|
+
sideRef.current.appendChild(sidebarElement);
|
|
38
|
+
|
|
39
|
+
// Event Listener untuk Navigasi Antar Komponen
|
|
40
|
+
sidebarElement.querySelectorAll('div').forEach(item => {
|
|
41
|
+
item.onclick = () => setActive(item.innerText.toLowerCase());
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}, []);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div style={{ display: 'flex', flexDirection: 'column', height: '100vh' }}>
|
|
48
|
+
<div ref={navRef}></div>
|
|
49
|
+
<div style={{ display: 'flex', flex: 1 }}>
|
|
50
|
+
<div ref={sideRef}></div>
|
|
51
|
+
<main style={{ flex: 1, padding: '20px', background: '#121212', color: 'white' }}>
|
|
52
|
+
<h1>Preview: {active.toUpperCase()}</h1>
|
|
53
|
+
<div ref={contentRef}></div>
|
|
54
|
+
</main>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
🛠️ Komponen Tersedia (API)
|
|
61
|
+
Library ini mendukung kustomisasi penuh melalui props pada setiap komponennya:KomponenProperti / ParameterFungsiNavbarbrand, links, backgroundColor, textColorNavigasi bar bagian atas dengan dukungan tautan.Sidebaritems, width, activeColorNavigasi samping dengan efek hover kustom.Containerchildren, maxWidth, paddingPembungkus tata letak agar konten tetap simetris di tengah.Buttontext, colorTombol aksi utama dengan berbagai varian warna.Badgelabel, colorLabel penanda status atau informasi versi.
|
|
62
|
+
|
|
63
|
+
🛡️ Keamanan & DistribusiTwo-Factor Authentication (2FA):
|
|
64
|
+
Setiap proses publikasi ke registry npm diverifikasi menggunakan Security Key/Passkey (PIN atau Biometrik perangkat Windows) untuk menjamin keamanan kode.Semantic Versioning: Mengikuti standar penomoran versi (Major.Minor.Patch) untuk menjaga stabilitas ketergantungan antar proyek.
|
|
65
|
+
|
|
66
|
+
🏗️ Struktur Folder Proyeksrc/components/:
|
|
67
|
+
Berisi logika utama komponen yang ditulis dalam TypeScript.dist/: Berisi file hasil kompilasi yang siap digunakan di lingkungan produksi (.js, .mjs, .d.ts).
|
|
68
|
+
|
|
69
|
+
Dibuat oleh Fillah - STIKOM PGRI Banyuwangi.
|
package/dist/index.d.mts
CHANGED
|
@@ -30,18 +30,27 @@ declare const Badge: ({ label, color }: BadgeProps) => HTMLSpanElement;
|
|
|
30
30
|
|
|
31
31
|
interface NavbarProps {
|
|
32
32
|
brand: string;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
backgroundColor?: string;
|
|
34
|
+
textColor?: string;
|
|
35
|
+
links?: {
|
|
36
|
+
name: string;
|
|
37
|
+
url: string;
|
|
36
38
|
}[];
|
|
37
39
|
}
|
|
38
|
-
declare const Navbar: ({ brand,
|
|
40
|
+
declare const Navbar: ({ brand, backgroundColor, textColor }: NavbarProps) => HTMLElement;
|
|
39
41
|
|
|
40
42
|
interface SidebarProps {
|
|
41
43
|
items: string[];
|
|
44
|
+
width?: string;
|
|
45
|
+
activeColor?: string;
|
|
42
46
|
}
|
|
43
|
-
declare const Sidebar: ({ items }: SidebarProps) => HTMLElement;
|
|
47
|
+
declare const Sidebar: ({ items, width, activeColor }: SidebarProps) => HTMLElement;
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
interface ContainerProps {
|
|
50
|
+
children: HTMLElement;
|
|
51
|
+
maxWidth?: string;
|
|
52
|
+
padding?: string;
|
|
53
|
+
}
|
|
54
|
+
declare const Container: ({ children, maxWidth, padding }: ContainerProps) => HTMLDivElement;
|
|
46
55
|
|
|
47
56
|
export { Alert, Badge, Button, Card, Container, Input, Navbar, Sidebar };
|
package/dist/index.d.ts
CHANGED
|
@@ -30,18 +30,27 @@ declare const Badge: ({ label, color }: BadgeProps) => HTMLSpanElement;
|
|
|
30
30
|
|
|
31
31
|
interface NavbarProps {
|
|
32
32
|
brand: string;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
backgroundColor?: string;
|
|
34
|
+
textColor?: string;
|
|
35
|
+
links?: {
|
|
36
|
+
name: string;
|
|
37
|
+
url: string;
|
|
36
38
|
}[];
|
|
37
39
|
}
|
|
38
|
-
declare const Navbar: ({ brand,
|
|
40
|
+
declare const Navbar: ({ brand, backgroundColor, textColor }: NavbarProps) => HTMLElement;
|
|
39
41
|
|
|
40
42
|
interface SidebarProps {
|
|
41
43
|
items: string[];
|
|
44
|
+
width?: string;
|
|
45
|
+
activeColor?: string;
|
|
42
46
|
}
|
|
43
|
-
declare const Sidebar: ({ items }: SidebarProps) => HTMLElement;
|
|
47
|
+
declare const Sidebar: ({ items, width, activeColor }: SidebarProps) => HTMLElement;
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
interface ContainerProps {
|
|
50
|
+
children: HTMLElement;
|
|
51
|
+
maxWidth?: string;
|
|
52
|
+
padding?: string;
|
|
53
|
+
}
|
|
54
|
+
declare const Container: ({ children, maxWidth, padding }: ContainerProps) => HTMLDivElement;
|
|
46
55
|
|
|
47
56
|
export { Alert, Badge, Button, Card, Container, Input, Navbar, Sidebar };
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
<h4 style="margin: 0 0 10px 0; color: #007bff;">${
|
|
3
|
-
<p style="margin: 0; font-size: 14px; color: #ccc;">${
|
|
4
|
-
`,e};var
|
|
5
|
-
<div style="
|
|
6
|
-
|
|
7
|
-
${t.map(o=>`<a href="${o.href}" style="color: white; text-decoration: none; font-size: 0.9rem;">${o.label}</a>`).join("")}
|
|
1
|
+
"use strict";var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(o,r)=>{for(var e in r)i(o,e,{get:r[e],enumerable:!0})},l=(o,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of d(r))!c.call(o,n)&&n!==e&&i(o,n,{get:()=>r[n],enumerable:!(t=a(r,n))||t.enumerable});return o};var u=o=>l(i({},"__esModule",{value:!0}),o);var v={};p(v,{Alert:()=>m,Badge:()=>f,Button:()=>x,Card:()=>b,Container:()=>C,Input:()=>g,Navbar:()=>h,Sidebar:()=>y});module.exports=u(v);var x=({text:o,color:r="blue"})=>{let e=document.createElement("button");return e.innerText=o,Object.assign(e.style,{padding:"12px 24px",borderRadius:"8px",border:"none",cursor:"pointer",fontWeight:"bold",fontSize:"14px",color:"white",backgroundColor:r==="blue"?"#007bff":r,transition:"all 0.3s ease",boxShadow:"0 4px 6px rgba(0,0,0,0.1)"}),e.onmouseover=()=>e.style.transform="translateY(-2px)",e.onmouseout=()=>e.style.transform="translateY(0)",e};var g=({placeholder:o="Type here...",type:r="text"})=>{let e=document.createElement("div"),t=document.createElement("input");return t.type=r,t.placeholder=o,Object.assign(t.style,{width:"100%",padding:"10px 15px",borderRadius:"6px",border:"1px solid #444",backgroundColor:"#333",color:"white",fontSize:"14px",outline:"none",transition:"border-color 0.3s"}),t.onfocus=()=>t.style.borderColor="#007bff",t.onblur=()=>t.style.borderColor="#444",e.appendChild(t),e};var b=({title:o,content:r})=>{let e=document.createElement("div");return Object.assign(e.style,{padding:"20px",borderRadius:"12px",backgroundColor:"#2a2a2a",border:"1px solid #333",boxShadow:"0 4px 12px rgba(0,0,0,0.2)",color:"white",maxWidth:"300px"}),e.innerHTML=`
|
|
2
|
+
<h4 style="margin: 0 0 10px 0; color: #007bff;">${o}</h4>
|
|
3
|
+
<p style="margin: 0; font-size: 14px; color: #ccc;">${r}</p>
|
|
4
|
+
`,e};var m=({message:o,type:r="success"})=>{let e=document.createElement("div");return Object.assign(e.style,{padding:"12px 20px",borderRadius:"8px",fontSize:"14px",fontWeight:"500",color:"white",backgroundColor:r==="success"?"#28a745":"#dc3545",borderLeft:`5px solid ${r==="success"?"#1e7e34":"#bd2130"}`,marginBottom:"10px"}),e.innerText=o,e};var f=({label:o,color:r="#6c757d"})=>{let e=document.createElement("span");return Object.assign(e.style,{padding:"4px 10px",borderRadius:"20px",fontSize:"12px",fontWeight:"bold",color:"white",backgroundColor:r,display:"inline-block"}),e.innerText=o,e};var h=({brand:o,backgroundColor:r="#333",textColor:e="white"})=>{let t=document.createElement("nav");return Object.assign(t.style,{display:"flex",padding:"1rem 2rem",backgroundColor:r,color:e,boxShadow:"0 2px 4px rgba(0,0,0,0.1)"}),t.innerHTML=`<div style="font-weight: bold; font-size: 1.5rem;">${o}</div>`,t};var y=({items:o,width:r="250px",activeColor:e="#444"})=>{let t=document.createElement("aside");return Object.assign(t.style,{width:r,height:"100vh",backgroundColor:"#222",color:"white",padding:"2rem 1rem"}),t.innerHTML=o.map(s=>`
|
|
5
|
+
<div class="menu-item" style="padding: 10px; cursor: pointer; border-radius: 4px; transition: 0.3s;">
|
|
6
|
+
${s}
|
|
8
7
|
</div>
|
|
9
|
-
|
|
10
|
-
<div style="padding: 0.75rem 1rem; border-radius: 4px; cursor: pointer; transition: background 0.3s;"
|
|
11
|
-
onmouseover="this.style.background='#444'" onmouseout="this.style.background='transparent'">
|
|
12
|
-
${e}
|
|
13
|
-
</div>
|
|
14
|
-
`).join(""),t};var y=r=>{let t=document.createElement("div");return Object.assign(t.style,{maxWidth:"1200px",margin:"0 auto",padding:"2rem",width:"100%"}),t.appendChild(r),t};0&&(module.exports={Alert,Badge,Button,Card,Container,Input,Navbar,Sidebar});
|
|
8
|
+
`).join(""),t.querySelectorAll(".menu-item").forEach(s=>{s.onmouseover=()=>s.style.backgroundColor=e,s.onmouseout=()=>s.style.backgroundColor="transparent"}),t};var C=({children:o,maxWidth:r="1200px",padding:e="2rem"})=>{let t=document.createElement("div");return Object.assign(t.style,{maxWidth:r,margin:"0 auto",padding:e,width:"100%"}),t.appendChild(o),t};0&&(module.exports={Alert,Badge,Button,Card,Container,Input,Navbar,Sidebar});
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
<h4 style="margin: 0 0 10px 0; color: #007bff;">${
|
|
1
|
+
var i=({text:o,color:t="blue"})=>{let e=document.createElement("button");return e.innerText=o,Object.assign(e.style,{padding:"12px 24px",borderRadius:"8px",border:"none",cursor:"pointer",fontWeight:"bold",fontSize:"14px",color:"white",backgroundColor:t==="blue"?"#007bff":t,transition:"all 0.3s ease",boxShadow:"0 4px 6px rgba(0,0,0,0.1)"}),e.onmouseover=()=>e.style.transform="translateY(-2px)",e.onmouseout=()=>e.style.transform="translateY(0)",e};var d=({placeholder:o="Type here...",type:t="text"})=>{let e=document.createElement("div"),r=document.createElement("input");return r.type=t,r.placeholder=o,Object.assign(r.style,{width:"100%",padding:"10px 15px",borderRadius:"6px",border:"1px solid #444",backgroundColor:"#333",color:"white",fontSize:"14px",outline:"none",transition:"border-color 0.3s"}),r.onfocus=()=>r.style.borderColor="#007bff",r.onblur=()=>r.style.borderColor="#444",e.appendChild(r),e};var p=({title:o,content:t})=>{let e=document.createElement("div");return Object.assign(e.style,{padding:"20px",borderRadius:"12px",backgroundColor:"#2a2a2a",border:"1px solid #333",boxShadow:"0 4px 12px rgba(0,0,0,0.2)",color:"white",maxWidth:"300px"}),e.innerHTML=`
|
|
2
|
+
<h4 style="margin: 0 0 10px 0; color: #007bff;">${o}</h4>
|
|
3
3
|
<p style="margin: 0; font-size: 14px; color: #ccc;">${t}</p>
|
|
4
|
-
`,e};var
|
|
5
|
-
<div style="
|
|
6
|
-
|
|
7
|
-
${t.map(o=>`<a href="${o.href}" style="color: white; text-decoration: none; font-size: 0.9rem;">${o.label}</a>`).join("")}
|
|
4
|
+
`,e};var u=({message:o,type:t="success"})=>{let e=document.createElement("div");return Object.assign(e.style,{padding:"12px 20px",borderRadius:"8px",fontSize:"14px",fontWeight:"500",color:"white",backgroundColor:t==="success"?"#28a745":"#dc3545",borderLeft:`5px solid ${t==="success"?"#1e7e34":"#bd2130"}`,marginBottom:"10px"}),e.innerText=o,e};var g=({label:o,color:t="#6c757d"})=>{let e=document.createElement("span");return Object.assign(e.style,{padding:"4px 10px",borderRadius:"20px",fontSize:"12px",fontWeight:"bold",color:"white",backgroundColor:t,display:"inline-block"}),e.innerText=o,e};var m=({brand:o,backgroundColor:t="#333",textColor:e="white"})=>{let r=document.createElement("nav");return Object.assign(r.style,{display:"flex",padding:"1rem 2rem",backgroundColor:t,color:e,boxShadow:"0 2px 4px rgba(0,0,0,0.1)"}),r.innerHTML=`<div style="font-weight: bold; font-size: 1.5rem;">${o}</div>`,r};var h=({items:o,width:t="250px",activeColor:e="#444"})=>{let r=document.createElement("aside");return Object.assign(r.style,{width:t,height:"100vh",backgroundColor:"#222",color:"white",padding:"2rem 1rem"}),r.innerHTML=o.map(n=>`
|
|
5
|
+
<div class="menu-item" style="padding: 10px; cursor: pointer; border-radius: 4px; transition: 0.3s;">
|
|
6
|
+
${n}
|
|
8
7
|
</div>
|
|
9
|
-
|
|
10
|
-
<div style="padding: 0.75rem 1rem; border-radius: 4px; cursor: pointer; transition: background 0.3s;"
|
|
11
|
-
onmouseover="this.style.background='#444'" onmouseout="this.style.background='transparent'">
|
|
12
|
-
${e}
|
|
13
|
-
</div>
|
|
14
|
-
`).join(""),t};var h=r=>{let t=document.createElement("div");return Object.assign(t.style,{maxWidth:"1200px",margin:"0 auto",padding:"2rem",width:"100%"}),t.appendChild(r),t};export{c as Alert,x as Badge,n as Button,d as Card,h as Container,i as Input,u as Navbar,m as Sidebar};
|
|
8
|
+
`).join(""),r.querySelectorAll(".menu-item").forEach(n=>{n.onmouseover=()=>n.style.backgroundColor=e,n.onmouseout=()=>n.style.backgroundColor="transparent"}),r};var C=({children:o,maxWidth:t="1200px",padding:e="2rem"})=>{let r=document.createElement("div");return Object.assign(r.style,{maxWidth:t,margin:"0 auto",padding:e,width:"100%"}),r.appendChild(o),r};export{u as Alert,g as Badge,i as Button,p as Card,C as Container,d as Input,m as Navbar,h as Sidebar};
|