Slice · AI prompt
Pure Notion-clone primitives in 3 variants — page editor · 11-view database · tree sidebar — over one shared domain-type model. Not the full app (that's `notion`).
# Install `notion-ui` — Notion UI — page editor · database · sidebar primitives
> Pure Notion-clone primitives in 3 variants — page editor · 11-view database · tree sidebar — over one shared domain-type model. Not the full app (that's `notion`).
📚 Knowledge base : https://resource.rahmanef.com/llms.txt
📦 Slice detail : https://resource.rahmanef.com/slices/notion-ui
🧠 JSON catalog : https://resource.rahmanef.com/api/knowledge?slice=notion-ui
🔗 Source : https://github.com/rahmanef63/resource-site/tree/main/frontend/slices/notion-ui
## 1. Install
```bash
npx rahman-resources add notion-ui
# alias: npx rr add notion-ui
```
The CLI copies `frontend/slices/notion-ui/` into your project + augments `.env.example` + installs npm deps automatically. Run it from your project root.
## 2. What it ships
- npm: `@dnd-kit/core`, `@dnd-kit/sortable`, `@dnd-kit/utilities`, `katex`, `highlight.js`, `recharts`, `lucide-react`
- shadcn primitives: `button`, `checkbox`, `dialog`, `dropdown-menu`, `input`, `popover`, `select`, `separator`, `sheet`, `switch`, `toggle-group`, `tooltip`
## 3. Wire it up
**Controlled component.** `<NotionDatabase />` renders the whole surface — 11 views (table, board, list, gallery, calendar, feed, chart, dashboard, form, map, timeline), 18 cell types, filter / sort / group / calculate, row peek + multi-select, table cell drag-fill, CSV / JSON import-export. It is 100% props-driven: it owns NO data state — you hold `db` + `rows` and persist every change callback. The view tab strip scrolls horizontally and the card clips to its border, so it stays inside any container width.
**1. Install** — `npx rr add notion-ui database`. Cascades the `notion-shell` peer (the domain types live there). Components import from `@/features/notion-ui`; types from `@/features/notion-ui`.
**2. Minimal wire-up** — keep `db: Database` + `rows: Page[]` in your store (a Convex query result or `useState`) and pass change handlers:
```tsx
import { NotionDatabase } from '@/features/notion-ui';
<NotionDatabase
db={db}
rows={rows}
onRowAdd={addRow}
onRowUpdate={(rowId, propId, value) => setValue(rowId, propId, value)}
onRowRemove={removeRow}
onPropertyAdd={addProperty}
onViewActivate={setActiveView}
onViewAdd={addView}
onViewConfigChange={(viewId, patch) => patchView(viewId, patch)}
/>
```
Omit any callback and that affordance goes read-only; pass `readOnly` to freeze everything at once.
**3. Data shape** — `Database = { id, name, properties: Property[], views: DatabaseViewConfig[], activeViewId }`; each row `Page = { id, title, rowProps: Record<propId, PropertyValue> }`. For `relation` / `rollup` cells also pass `pages` + `databases`; for `person` / `created_by` cells pass `userLookup(id)`.
**4. Import / export** — mount `<DatabaseIOActions db={db} rows={rows} onImport={handleImport} />` in your toolbar: CSV/JSON in (with schema-diff), CSV/JSON + live-schema templates out. New columns arrive with a `tempId` — map it to your real backend id before writing their `rowProps`.
**5. Backend (optional)** — the UI is store-agnostic. For Convex persistence copy `template-base/database-silong/convex/` (handlers → `convex/`, schema fragment merges into `convex/schema.ts`). Pick `_shared/minimal/` (single-user, noop authz) or `_shared/full/` (`@convex-dev/auth` + workspaces). See CONVEX-BACKEND.md.
**Just one view?** Import it directly — `import { TableView } from '@/features/notion-ui'` — and feed it `rows` + `renderCell` + `renderColumnHeader`.
## Rules of engagement
- shadcn-only UI primitives. No raw `<button>` / `<dialog>` / native date or file inputs.
- 200-line hard cap per source file (extract neighbours when over).
- All Convex queries hit an index (`.withIndex(...)`); never bare `.collect()`.
- Public mutations/queries declare `args:` validators + authz.
- Full ruleset: https://resource.rahmanef.com/best-practice
The agent will fetch /llms.txt for the full ruleset and use /api/knowledge for the JSON catalog.