@protoblem/ui 0.0.0-stage → 0.1.0-next.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Protoblem
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,116 @@
1
- # Temporary Holding Version
1
+ # @protoblem/ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Komponen React bersama untuk semua project Protoblem: dialog, konfirmasi, tombol, ikon. Gaya memakai
4
+ Tailwind CSS 4 dan bisa disesuaikan warna merek tiap project lewat token.
5
+
6
+ Contoh hidup semua komponen ada di Storybook paket ini (alamat online menyusul).
7
+
8
+ ## Syarat
9
+
10
+ - React 19 (`react`, `react-dom`)
11
+ - Tailwind CSS 4
12
+ - Next.js tidak wajib. Paket utama jalan di aplikasi React apa pun.
13
+
14
+ ## Memasang
15
+
16
+ ```bash
17
+ npm install @protoblem/ui
18
+ ```
19
+
20
+ Paket ini publik. Tidak perlu `.npmrc`, token, atau pengaturan lain.
21
+
22
+ ### Memberi tahu AI assistant project (disarankan)
23
+
24
+ Panduan ini dan petunjuk tiap komponen ikut terpasang di `node_modules/@protoblem/ui/`, selalu sesuai versi yang
25
+ terpasang. AI assistant biasanya tidak membaca `node_modules` sendiri, jadi tulis satu baris di berkas instruksinya
26
+ (`CLAUDE.md`, `AGENTS.md`, atau sejenisnya):
27
+
28
+ ```markdown
29
+ Komponen `@protoblem/ui`: sebelum memakai atau mengubah pemakaiannya, baca `node_modules/@protoblem/ui/README.md`
30
+ dan berkas komponennya di `node_modules/@protoblem/ui/docs/components/`. Jangan menyalin isinya ke dokumen project.
31
+ ```
32
+
33
+ ## Menyambungkan CSS (wajib)
34
+
35
+ Di berkas CSS utama project (yang berisi `@import "tailwindcss"`):
36
+
37
+ ```css
38
+ @import "tailwindcss";
39
+ @import "@protoblem/ui/theme.css";
40
+ @source "../node_modules/@protoblem/ui";
41
+ ```
42
+
43
+ 1. `@import "@protoblem/ui/theme.css"` memuat token (warna, ukuran teks, sudut, bayangan) dan kelas tombol `pb-*`.
44
+ 2. `@source` **wajib**. Tanpa baris ini, kelas Tailwind yang dipakai di dalam komponen paket tidak dibuat, dan
45
+ tampilan rusak **tanpa pesan error**. Alamatnya relatif terhadap letak berkas CSS ini. Contoh: berkas CSS di
46
+ `src/app/globals.css` → `@source "../../node_modules/@protoblem/ui";`.
47
+
48
+ ### Memakai warna merek sendiri
49
+
50
+ Warna bawaan paket adalah warna Protoblem. Ganti token yang perlu **sesudah** impor paket:
51
+
52
+ ```css
53
+ @theme {
54
+ --color-action: #0f766e;
55
+ --color-action-hover: #115e59;
56
+ --color-link: #0f766e;
57
+ }
58
+ ```
59
+
60
+ Daftar lengkap token beserta nilainya: `node_modules/@protoblem/ui/styles/tokens.css`. Yang paling sering diganti:
61
+
62
+ | Token | Dipakai untuk |
63
+ |---|---|
64
+ | `--color-action`, `--color-action-hover`, `--color-action-text` | tombol utama (`pb-button`) |
65
+ | `--color-link`, `--color-accent` | teks dan ikon tombol kedua (`pb-button-outline`) |
66
+ | `--color-danger`, `--color-danger-strong` | tombol bahaya (`pb-button-danger`) |
67
+ | `--color-backdrop` | latar gelap di belakang dialog |
68
+ | `--radius-pill`, `--radius-card-lg` | sudut tombol dan dialog |
69
+
70
+ Huruf tidak diatur paket. Pasang huruf project seperti biasa (`--font-sans`).
71
+
72
+ ### Kalau project mematikan warna bawaan Tailwind
73
+
74
+ Sebagian project mematikan warna bawaan Tailwind (`blue-500`, `gray-100`, dst.) supaya hanya memakai warnanya
75
+ sendiri. Baris pematiannya harus ditulis **sebelum** impor paket:
76
+
77
+ ```css
78
+ @import "tailwindcss";
79
+ @theme { --color-*: initial; }
80
+ @import "@protoblem/ui/theme.css";
81
+ @source "../node_modules/@protoblem/ui";
82
+ ```
83
+
84
+ Kalau ditulis sesudahnya, warna paket ikut terhapus dan build CSS gagal dengan pesan
85
+ `Cannot apply unknown utility class`. Pindahkan barisnya ke atas impor paket.
86
+
87
+ ## Komponen
88
+
89
+ Teks yang tampil di layar berbahasa Indonesia secara bawaan dan bisa diganti lewat prop. Petunjuk lengkap tiap
90
+ komponen (contoh kode dan semua pilihannya) ada di satu berkas per komponen, di folder `docs/components/` paket ini.
91
+
92
+ | Komponen | Kegunaan | Petunjuk |
93
+ |---|---|---|
94
+ | `Modal` | dialog di atas halaman | [docs/components/modal.md](docs/components/modal.md) |
95
+ | `useConfirm` | pengganti `window.confirm` dengan dialog bergaya situs | [docs/components/use-confirm.md](docs/components/use-confirm.md) |
96
+ | `pb-button`, `pb-button-outline`, `pb-button-danger` | kelas CSS gaya tombol | [docs/components/buttons.md](docs/components/buttons.md) |
97
+ | `CloseIcon` | ikon garis | [docs/components/icons.md](docs/components/icons.md) |
98
+
99
+ ## Next.js
100
+
101
+ Komponen paket ini bertanda `"use client"`. `Modal` butuh state (`open`), dan `useConfirm` adalah hook, jadi
102
+ keduanya dipakai di dalam Client Component (berkas yang diawali `"use client"`), seperti contoh di atas. Komponen
103
+ khusus Next.js kelak tersedia di `@protoblem/ui/next` (belum ada isinya).
104
+
105
+ ## Versi
106
+
107
+ - Nomor versi mengikuti semver, mulai `0.x`: angka terakhir = perbaikan, angka tengah = komponen atau pilihan
108
+ baru, angka pertama = perubahan yang bisa merusak tampilan atau kode project.
109
+ - Perubahan perilaku ditambahkan sebagai pilihan (prop) baru; bawaannya tetap perilaku lama. Jadi naik versi tidak
110
+ mengubah tampilan project tanpa sengaja.
111
+ - Dua jalur: `npm install @protoblem/ui` (versi resmi, `latest`) dan `npm install @protoblem/ui@next` (versi
112
+ coba-coba untuk server staging, jangan dipakai di production).
113
+
114
+ ## Lisensi
115
+
116
+ MIT
@@ -0,0 +1,29 @@
1
+ import { type ReactNode } from "react";
2
+ export type ModalProps = {
3
+ /** Whether the dialog is shown. Its content is only mounted while open. */
4
+ open: boolean;
5
+ /** Called when the user closes the dialog: Esc, the close button, or a click on the backdrop. */
6
+ onClose: () => void;
7
+ /** Heading of the dialog; also its accessible name. */
8
+ title: string;
9
+ /** Maximum width in pixels; on narrow screens the dialog takes 94% of the viewport width. */
10
+ width?: number;
11
+ /**
12
+ * Show the round × button next to the title. Turn it off when the content already has its own
13
+ * way out (a confirmation with "Cancel"), so there are not two buttons that do the same thing.
14
+ */
15
+ closeButton?: boolean;
16
+ /** Accessible label of the × button. */
17
+ closeLabel?: string;
18
+ children: ReactNode;
19
+ };
20
+ /**
21
+ * Dialog above the page, built on the native <dialog> element: focus stays inside and Esc closes it.
22
+ *
23
+ * Only the content scrolls, inside the dialog frame: the title and close button stay at the top, and the
24
+ * scrollbar sits inside the rounded corners instead of on the outer edge.
25
+ *
26
+ * Initial focus: the first element marked `data-autofocus` (e.g. a search field); otherwise the browser
27
+ * focuses the first focusable element.
28
+ */
29
+ export declare function Modal({ open, onClose, title, width, closeButton, closeLabel, children }: ModalProps): import("react").JSX.Element;
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef } from "react";
4
+ import { CloseIcon } from "../icons/generated.js";
5
+ /**
6
+ * Dialog above the page, built on the native <dialog> element: focus stays inside and Esc closes it.
7
+ *
8
+ * Only the content scrolls, inside the dialog frame: the title and close button stay at the top, and the
9
+ * scrollbar sits inside the rounded corners instead of on the outer edge.
10
+ *
11
+ * Initial focus: the first element marked `data-autofocus` (e.g. a search field); otherwise the browser
12
+ * focuses the first focusable element.
13
+ */
14
+ export function Modal({ open, onClose, title, width = 720, closeButton = true, closeLabel = "Tutup", children }) {
15
+ const ref = useRef(null);
16
+ useEffect(() => {
17
+ const dialog = ref.current;
18
+ if (!dialog)
19
+ return;
20
+ if (open && !dialog.open) {
21
+ dialog.showModal();
22
+ dialog.querySelector("[data-autofocus]")?.focus();
23
+ }
24
+ if (!open && dialog.open)
25
+ dialog.close();
26
+ }, [open]);
27
+ return (_jsx("dialog", { ref: ref, onClose: onClose, onClick: (event) => event.target === ref.current && onClose(), "aria-label": title, style: { width: `min(94vw, ${width}px)` }, className: "m-auto max-h-[92dvh] overflow-hidden rounded-card-lg border-0 bg-white p-0 shadow-dialog backdrop:bg-backdrop open:flex open:flex-col", children: open && (_jsxs("div", { className: "flex min-h-0 flex-1 flex-col p-5 desktop:p-7", children: [_jsxs("div", { className: "mb-5 flex flex-none items-center justify-between gap-4", children: [_jsx("h2", { className: "text-title font-semibold text-ink", children: title }), closeButton && (_jsx("button", { type: "button", onClick: onClose, "aria-label": closeLabel, className: "grid size-(--touch-min) flex-none cursor-pointer place-items-center rounded-full border-0 bg-surface-muted text-ink hover:bg-line-soft", children: _jsx(CloseIcon, { size: 18 }) }))] }), _jsx("div", { "data-modal-body": true, className: "-m-1 min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain p-1", children: children })] })) }));
28
+ }
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from "react";
2
+ export type IconProps = {
3
+ /** Width and height in pixels. */
4
+ size?: number;
5
+ /** Line thickness in viewBox units (24). Larger icons use a thinner line so it stays about 2px on screen. */
6
+ strokeWidth?: number;
7
+ };
8
+ /** Line icon on a 24x24 grid that follows the text colour. Decorative: hidden from assistive technology. */
9
+ export declare function Icon({ children, size, strokeWidth }: IconProps & {
10
+ children: ReactNode;
11
+ }): import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /** Line icon on a 24x24 grid that follows the text colour. Decorative: hidden from assistive technology. */
3
+ export function Icon({ children, size = 20, strokeWidth = 1.8 }) {
4
+ return (_jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: strokeWidth, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children: children }));
5
+ }
@@ -0,0 +1,2 @@
1
+ import { type IconProps } from "./Icon.js";
2
+ export declare const CloseIcon: (props: IconProps) => import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // Generated from tokens/icons by tokens/build.mjs. Do not edit by hand.
3
+ import { Icon } from "./Icon.js";
4
+ export const CloseIcon = (props) => (_jsx(Icon, { ...props, children: _jsx("path", { d: "M6 6l12 12M18 6 6 18" }) }));
@@ -0,0 +1,4 @@
1
+ export { Modal, type ModalProps } from "./Modal/Modal.js";
2
+ export { useConfirm, type ConfirmOptions } from "./useConfirm/useConfirm.js";
3
+ export type { IconProps } from "./icons/Icon.js";
4
+ export * from "./icons/generated.js";
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ // Public entry of @protoblem/ui.
2
+ // Nothing in this entry may import from "next"; Next.js-only components live in ./next.
3
+ export { Modal } from "./Modal/Modal.js";
4
+ export { useConfirm } from "./useConfirm/useConfirm.js";
5
+ export * from "./icons/generated.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ // Entry of @protoblem/ui/next: components that depend on Next.js (next/link, next/navigation).
2
+ export {};
@@ -0,0 +1,23 @@
1
+ import { type ReactNode } from "react";
2
+ export type ConfirmOptions = {
3
+ title: string;
4
+ message: string;
5
+ /** Label of the agree button: a verb that names the result ("Ya, hapus"), not "OK". */
6
+ confirmLabel: string;
7
+ /** Label of the button that answers no. */
8
+ cancelLabel?: string;
9
+ /** `danger` = cannot be undone: red agree button, and initial focus on the cancel button so Enter does not agree by accident. */
10
+ tone?: "normal" | "danger";
11
+ };
12
+ /**
13
+ * Replacement for `window.confirm`: a dialog in the site's style with a title, an explanation, and
14
+ * buttons that name their result.
15
+ *
16
+ * const [confirm, confirmDialog] = useConfirm();
17
+ * if (!(await confirm({ title, message, confirmLabel: "Ya, hapus", tone: "danger" }))) return;
18
+ * // ...and render {confirmDialog} in the component's JSX.
19
+ *
20
+ * Closing with Esc, the cancel button, or a click outside answers `false`. Asking again while a question is
21
+ * still open answers the earlier one with `false`.
22
+ */
23
+ export declare function useConfirm(): readonly [(options: ConfirmOptions) => Promise<boolean>, ReactNode];
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useRef, useState } from "react";
4
+ import { Modal } from "../Modal/Modal.js";
5
+ /**
6
+ * Replacement for `window.confirm`: a dialog in the site's style with a title, an explanation, and
7
+ * buttons that name their result.
8
+ *
9
+ * const [confirm, confirmDialog] = useConfirm();
10
+ * if (!(await confirm({ title, message, confirmLabel: "Ya, hapus", tone: "danger" }))) return;
11
+ * // ...and render {confirmDialog} in the component's JSX.
12
+ *
13
+ * Closing with Esc, the cancel button, or a click outside answers `false`. Asking again while a question is
14
+ * still open answers the earlier one with `false`.
15
+ */
16
+ export function useConfirm() {
17
+ const [options, setOptions] = useState(null);
18
+ const resolver = useRef(null);
19
+ const confirm = useCallback((next) => new Promise((resolve) => {
20
+ resolver.current?.(false);
21
+ resolver.current = resolve;
22
+ setOptions(next);
23
+ }), []);
24
+ const answer = useCallback((value) => {
25
+ resolver.current?.(value);
26
+ resolver.current = null;
27
+ setOptions(null);
28
+ }, []);
29
+ const danger = options?.tone === "danger";
30
+ const dialog = (_jsx(Modal, { open: options !== null, onClose: () => answer(false), title: options?.title ?? "", width: 440, closeButton: false, children: options && (_jsxs("div", { className: "grid gap-5", children: [_jsx("p", { className: "text-body leading-relaxed text-gray-700", children: options.message }), _jsxs("div", { className: "flex flex-wrap justify-end gap-2.5", children: [_jsx("button", { type: "button", "data-autofocus": danger ? "" : undefined, className: "pb-button-outline px-5", onClick: () => answer(false), children: options.cancelLabel ?? "Batal" }), _jsx("button", { type: "button", "data-autofocus": danger ? undefined : "", className: danger ? "pb-button-danger px-5" : "pb-button px-5", onClick: () => answer(true), children: options.confirmLabel })] })] })) }));
31
+ return [confirm, dialog];
32
+ }
@@ -0,0 +1,27 @@
1
+ # Tombol: kelas `pb-button`, `pb-button-outline`, `pb-button-danger`
2
+
3
+ Gaya tombol berupa kelas CSS biasa, dipakai di `<button>` atau `<a>`:
4
+
5
+ ```tsx
6
+ <button type="button" className="pb-button">simpan perubahan</button>
7
+ <button type="button" className="pb-button-outline">lihat rute</button>
8
+ <button type="button" className="pb-button-danger">hapus foto</button>
9
+ <a href="/daftar" className="pb-button">daftar</a>
10
+ ```
11
+
12
+ | Kelas | Untuk |
13
+ |---|---|
14
+ | `pb-button` | aksi utama (warna `--color-action`) |
15
+ | `pb-button-outline` | aksi kedua (putih bergaris) |
16
+ | `pb-button-danger` | aksi yang tidak bisa dibatalkan (warna `--color-danger`) |
17
+
18
+ Aturan yang sudah ikut di semua tombol: tinggi minimal 44px (nyaman disentuh), teks otomatis Huruf Awal Besar
19
+ (tulis teks biasa saja), dan `disabled` tampil pudar tanpa efek hover.
20
+
21
+ Kelas Tailwind biasa di elemen yang sama **selalu menang**, jadi tombol bisa disesuaikan tanpa melawan gaya paket:
22
+
23
+ ```tsx
24
+ <button type="button" className="pb-button w-full px-5 desktop:w-auto">kirim</button>
25
+ ```
26
+
27
+ Kembali ke [panduan utama](../../README.md).
@@ -0,0 +1,12 @@
1
+ # Ikon
2
+
3
+ ```tsx
4
+ import { CloseIcon } from "@protoblem/ui";
5
+
6
+ <CloseIcon size={18} />
7
+ ```
8
+
9
+ Ikon garis 24×24 yang mengikuti warna teks dan disembunyikan dari pembaca layar (hiasan). Prop: `size` (piksel,
10
+ bawaan 20) dan `strokeWidth` (bawaan 1.8). Daftar ikon: `CloseIcon`.
11
+
12
+ Kembali ke [panduan utama](../../README.md).
@@ -0,0 +1,40 @@
1
+ # `Modal`
2
+
3
+ Dialog di atas halaman, memakai elemen `<dialog>` bawaan browser: fokus tidak bisa keluar dari dialog, Esc
4
+ menutup, klik di latar gelap menutup. Isi dialog baru dipasang saat dibuka. Yang bergulir hanya isinya, judul tetap
5
+ di atas.
6
+
7
+ ```tsx
8
+ "use client";
9
+ import { useState } from "react";
10
+ import { Modal } from "@protoblem/ui";
11
+
12
+ export function UbahAlamat() {
13
+ const [open, setOpen] = useState(false);
14
+ return (
15
+ <>
16
+ <button type="button" className="pb-button" onClick={() => setOpen(true)}>
17
+ ubah alamat
18
+ </button>
19
+ <Modal open={open} onClose={() => setOpen(false)} title="Ubah alamat">
20
+ <input data-autofocus className="w-full" />
21
+ </Modal>
22
+ </>
23
+ );
24
+ }
25
+ ```
26
+
27
+ | Prop | Tipe | Bawaan | Keterangan |
28
+ |---|---|---|---|
29
+ | `open` | `boolean` | (wajib) | dialog tampil atau tidak |
30
+ | `onClose` | `() => void` | (wajib) | dipanggil saat pengguna menutup (Esc, tombol ×, klik latar); ubah `open` jadi `false` di sini |
31
+ | `title` | `string` | (wajib) | judul dialog, sekaligus nama dialog bagi pembaca layar |
32
+ | `width` | `number` | `720` | lebar maksimum dalam piksel; di layar sempit dialog menyesuaikan |
33
+ | `closeButton` | `boolean` | `true` | tombol × di samping judul; matikan bila isi sudah punya tombol keluar sendiri |
34
+ | `closeLabel` | `string` | `"Tutup"` | label tombol × untuk pembaca layar |
35
+ | `children` | `ReactNode` | (wajib) | isi dialog |
36
+
37
+ Fokus awal: elemen di dalam isi yang diberi atribut `data-autofocus`. Tanpa itu, browser memfokus elemen pertama
38
+ yang bisa difokus (tombol ×).
39
+
40
+ Kembali ke [panduan utama](../../README.md).
@@ -0,0 +1,46 @@
1
+ # `useConfirm`
2
+
3
+ Pengganti `window.confirm`: dialog bergaya situs dengan judul, penjelasan, dan tombol yang menyebut akibatnya.
4
+
5
+ ```tsx
6
+ "use client";
7
+ import { useConfirm } from "@protoblem/ui";
8
+
9
+ export function HapusFoto({ onDelete }: { onDelete: () => void }) {
10
+ const [confirm, confirmDialog] = useConfirm();
11
+
12
+ async function hapus() {
13
+ const yes = await confirm({
14
+ title: "Hapus foto?",
15
+ message: "Foto ini akan dihapus dan tidak bisa dikembalikan.",
16
+ confirmLabel: "Ya, hapus",
17
+ tone: "danger",
18
+ });
19
+ if (yes) onDelete();
20
+ }
21
+
22
+ return (
23
+ <>
24
+ <button type="button" className="pb-button-danger" onClick={hapus}>
25
+ hapus
26
+ </button>
27
+ {confirmDialog}
28
+ </>
29
+ );
30
+ }
31
+ ```
32
+
33
+ `{confirmDialog}` wajib ditaruh di JSX komponen yang sama. Menutup lewat Esc, tombol batal, atau klik di luar
34
+ dialog = jawaban `false`.
35
+
36
+ | Pilihan | Tipe | Bawaan | Keterangan |
37
+ |---|---|---|---|
38
+ | `title` | `string` | (wajib) | judul dialog |
39
+ | `message` | `string` | (wajib) | penjelasan akibatnya |
40
+ | `confirmLabel` | `string` | (wajib) | tombol setuju: kata kerja yang menyebut akibatnya ("Ya, hapus"), bukan "OK" |
41
+ | `cancelLabel` | `string` | `"Batal"` | tombol yang menjawab tidak |
42
+ | `tone` | `"normal" \| "danger"` | `"normal"` | `danger` untuk yang tidak bisa dibatalkan: tombol merah, fokus awal di tombol batal supaya Enter tidak langsung menyetujui |
43
+
44
+ Memakai [`Modal`](modal.md) dan [tombol](buttons.md).
45
+
46
+ Kembali ke [panduan utama](../../README.md).
package/package.json CHANGED
@@ -1,6 +1,72 @@
1
1
  {
2
2
  "name": "@protoblem/ui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-next.1",
4
+ "description": "Shared React UI components styled with Tailwind CSS 4.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/protoblem/design-system.git",
9
+ "directory": "packages/react"
10
+ },
11
+ "type": "module",
12
+ "sideEffects": [
13
+ "**/*.css"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./next": {
21
+ "types": "./dist/next/index.d.ts",
22
+ "default": "./dist/next/index.js"
23
+ },
24
+ "./theme.css": "./styles/theme.css",
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "styles",
30
+ "docs"
31
+ ],
32
+ "scripts": {
33
+ "build": "node scripts/clean.mjs && tsc -p tsconfig.build.json",
34
+ "typecheck": "tsc -p tsconfig.json --noEmit",
35
+ "test": "vitest run",
36
+ "storybook": "storybook dev -p 6006",
37
+ "build-storybook": "storybook build",
38
+ "test:visual": "node scripts/visual.mjs",
39
+ "test:visual:update": "node scripts/visual.mjs --update"
40
+ },
41
+ "peerDependencies": {
42
+ "next": ">=16.4.6",
43
+ "react": ">=19.3.1",
44
+ "react-dom": ">=19.3.1"
45
+ },
46
+ "peerDependenciesMeta": {
47
+ "next": {
48
+ "optional": true
49
+ }
50
+ },
51
+ "devDependencies": {
52
+ "@fontsource/inter": "5.3.0",
53
+ "@storybook/react": "10.6.9",
54
+ "@storybook/react-vite": "10.6.9",
55
+ "@tailwindcss/node": "4.3.5",
56
+ "@tailwindcss/vite": "4.3.5",
57
+ "@types/node": "26.6.11",
58
+ "@types/react": "19.3.3",
59
+ "@types/react-dom": "19.3.0",
60
+ "@vitejs/plugin-react": "6.3.0",
61
+ "@vitest/browser-playwright": "5.1.2",
62
+ "next": "16.4.6",
63
+ "playwright": "1.65.1",
64
+ "react": "19.3.1",
65
+ "react-dom": "19.3.1",
66
+ "storybook": "10.6.9",
67
+ "tailwindcss": "4.3.5",
68
+ "vite": "8.4.0",
69
+ "vitest": "5.1.2",
70
+ "vitest-browser-react": "2.3.0"
71
+ }
72
+ }
@@ -0,0 +1,23 @@
1
+ /* Reusable component styles as pb-* classes.
2
+ They live in @layer components so any plain Tailwind class on the same element always wins
3
+ (e.g. `pb-button px-5` or `pb-button w-full`), regardless of class name order.
4
+ Layout and spacing around a component stay plain Tailwind classes in the consuming markup. */
5
+ @layer components {
6
+ /* Buttons. Shared rules: label in Title Case via `capitalize` (write plain text in markup),
7
+ touch target at least --touch-min high, and `disabled` looks faded with no hover effect. */
8
+
9
+ /* Primary action: filled with the action colour. */
10
+ .pb-button {
11
+ @apply inline-flex min-h-(--touch-min) cursor-pointer items-center justify-center gap-2 rounded-pill border-0 bg-action px-6 text-small font-semibold text-action-text capitalize no-underline hover:bg-action-hover disabled:cursor-default disabled:opacity-60 disabled:hover:bg-action;
12
+ }
13
+
14
+ /* Secondary action: white with a thin border; label and icons in the link colour. */
15
+ .pb-button-outline {
16
+ @apply inline-flex min-h-(--touch-min) cursor-pointer items-center justify-center gap-2 rounded-pill border border-line bg-white px-5.5 text-small font-semibold text-link capitalize no-underline hover:bg-surface disabled:cursor-default disabled:opacity-60 disabled:hover:bg-white [&>svg]:text-accent;
17
+ }
18
+
19
+ /* Action that cannot be undone (delete, remove): filled with the danger colour. */
20
+ .pb-button-danger {
21
+ @apply inline-flex min-h-(--touch-min) cursor-pointer items-center justify-center gap-2 rounded-pill border-0 bg-danger px-6 text-small font-semibold text-white capitalize no-underline hover:bg-danger-strong disabled:cursor-default disabled:opacity-60 disabled:hover:bg-danger;
22
+ }
23
+ }
@@ -0,0 +1,3 @@
1
+ /* Entry for consumers: @import "@protoblem/ui/theme.css" after @import "tailwindcss". */
2
+ @import "./tokens.css";
3
+ @import "./components.css";
@@ -0,0 +1,55 @@
1
+ /* Generated from tokens/src by tokens/build.mjs. Do not edit by hand. */
2
+ @theme {
3
+ --breakpoint-phone: 560px;
4
+ --breakpoint-desktop: 900px;
5
+ --color-white: #FFFFFF;
6
+ --color-bg: #FBFBFD;
7
+ --color-surface: #F5F5F7;
8
+ --color-surface-muted: #EFF0EC;
9
+ --color-line: #DCDDD8;
10
+ --color-line-soft: #E6E7E3;
11
+ --color-ink: #2B2F34;
12
+ --color-text: #3A3F43;
13
+ --color-text-muted: #6A6F73;
14
+ --color-gray-200: #B9BCB6;
15
+ --color-gray-300: #8A8F92;
16
+ --color-gray-400: #6A6F73;
17
+ --color-gray-500: #5C6165;
18
+ --color-gray-600: #4F5458;
19
+ --color-gray-700: #3A3F43;
20
+ --color-accent: #056BB2;
21
+ --color-accent-hover: #04568E;
22
+ --color-accent-tint: #E8F1F8;
23
+ --color-link: #056BB2;
24
+ --color-link-hover: #04568E;
25
+ --color-action: #056BB2;
26
+ --color-action-hover: #04568E;
27
+ --color-action-text: #FFFFFF;
28
+ --color-success: #2E7D5B;
29
+ --color-success-strong: #1F5C41;
30
+ --color-success-tint: rgba(46, 125, 91, 0.12);
31
+ --color-danger: #B42318;
32
+ --color-danger-strong: #8C1A11;
33
+ --color-danger-tint: rgba(180, 35, 24, 0.12);
34
+ --color-backdrop: rgba(0, 0, 0, 0.4);
35
+ --radius-input: 12px;
36
+ --radius-tile: 12px;
37
+ --radius-card: 16px;
38
+ --radius-panel: 20px;
39
+ --radius-card-lg: 24px;
40
+ --radius-pill: 999px;
41
+ --shadow-menu: 0px 8px 24px 0px rgba(43, 47, 52, 0.12);
42
+ --shadow-dialog: 0px 24px 60px 0px rgba(43, 47, 52, 0.25);
43
+ --touch-min: 44px;
44
+ --text-micro: 12px;
45
+ --text-label: 12px;
46
+ --text-caption: 13px;
47
+ --text-small: 14px;
48
+ --text-body: 15px;
49
+ --text-lead: 16px;
50
+ --text-subtitle: 18px;
51
+ --text-title: 20px;
52
+ --text-heading: clamp(20px, 3vw, 24px);
53
+ --text-section: clamp(24px, 3.2vw, 30px);
54
+ --text-display: clamp(32px, 5vw, 48px);
55
+ }