@ramme-io/create-app 3.0.3 → 3.1.0
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/index.js +40 -5
- package/package.json +1 -1
- package/template/AGENTS.md +63 -35
- package/template/CHANGELOG.md +9 -0
- package/template/package.json +1 -1
- package/template/src/features/about/pages/AboutPage.tsx +11 -17
- package/template/.cursorrules +0 -4
- package/template/.rammerules +0 -150
- package/template/src/components/RammeCodeBlock.tsx +0 -66
package/index.js
CHANGED
|
@@ -40,9 +40,9 @@ const destinationPath = path.resolve(process.cwd(), projectName);
|
|
|
40
40
|
// versions match what was just published, not merely that the build passes —
|
|
41
41
|
// a stale pin builds fine, it just ships the wrong framework.
|
|
42
42
|
const RELEASE_VERSIONS = {
|
|
43
|
-
'@ramme-io/ui': '^4.0
|
|
44
|
-
'@ramme-io/kernel': '^
|
|
45
|
-
'@ramme-io/shared': '^3.1.
|
|
43
|
+
'@ramme-io/ui': '^4.1.0',
|
|
44
|
+
'@ramme-io/kernel': '^6.0.0',
|
|
45
|
+
'@ramme-io/shared': '^3.1.2',
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
try {
|
|
@@ -84,13 +84,48 @@ try {
|
|
|
84
84
|
console.log('✅ Supply chain hardened. Workspace dependencies stripped.');
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
// 4.
|
|
87
|
+
// 4. AGENT RULES — one file, under every name an agent looks for.
|
|
88
|
+
//
|
|
89
|
+
// The monorepo does this with symlinks (.clinerules -> AGENTS.md, git mode
|
|
90
|
+
// 120000), which is drift-proof and completely useless here: npm pack DROPS
|
|
91
|
+
// symlinks. Measured, not assumed — a symlinked entry vanishes from the
|
|
92
|
+
// tarball entirely while a real dotfile survives. So the copies are written
|
|
93
|
+
// at scaffold time instead: nothing is duplicated in git, every agent gets
|
|
94
|
+
// the full text, and it works on every OS.
|
|
95
|
+
//
|
|
96
|
+
// CLAUDE.md is the exception. Claude Code does not read AGENTS.md on its own
|
|
97
|
+
// but does resolve `@file` imports, so it gets a real pointer rather than a
|
|
98
|
+
// copy — which means it never drifts.
|
|
99
|
+
const agentsPath = path.join(destinationPath, 'AGENTS.md');
|
|
100
|
+
if (fs.existsSync(agentsPath)) {
|
|
101
|
+
const rules = fs.readFileSync(agentsPath, 'utf8');
|
|
102
|
+
for (const name of ['.cursorrules', '.clinerules', '.windsurfrules', '.rammerules']) {
|
|
103
|
+
fs.writeFileSync(path.join(destinationPath, name), rules);
|
|
104
|
+
}
|
|
105
|
+
fs.writeFileSync(
|
|
106
|
+
path.join(destinationPath, 'CLAUDE.md'),
|
|
107
|
+
'@AGENTS.md\n\n' +
|
|
108
|
+
'## Claude Code specifics\n\n' +
|
|
109
|
+
'The import above is the whole file — `AGENTS.md` is the single source of\n' +
|
|
110
|
+
'truth for every agent working in this project, and the other rules files\n' +
|
|
111
|
+
'(`.cursorrules`, `.clinerules`, `.windsurfrules`, `.rammerules`) are copies\n' +
|
|
112
|
+
'of it for agents that look for a different filename.\n\n' +
|
|
113
|
+
'Run `/context` to confirm it loaded.\n',
|
|
114
|
+
);
|
|
115
|
+
console.log(' 🤖 Agent rules written: CLAUDE.md, .cursorrules, .clinerules, .windsurfrules, .rammerules');
|
|
116
|
+
} else {
|
|
117
|
+
// Loud rather than silent: without this the app ships with no rules for any
|
|
118
|
+
// agent, which is the thing the framework is meant to guarantee.
|
|
119
|
+
console.warn(' ⚠️ AGENTS.md missing from the template — no agent rules were written.');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// 5. Handle Gitignore
|
|
88
123
|
const gitignorePath = path.join(destinationPath, 'gitignore');
|
|
89
124
|
if (fs.existsSync(gitignorePath)) {
|
|
90
125
|
fs.renameSync(gitignorePath, path.join(destinationPath, '.gitignore'));
|
|
91
126
|
}
|
|
92
127
|
|
|
93
|
-
//
|
|
128
|
+
// 6. ONBOARDING INSTRUCTIONS — Premium Unboxing Experience
|
|
94
129
|
console.log('\n╔═══════════════════════════════════════╗');
|
|
95
130
|
console.log('║ ║');
|
|
96
131
|
console.log('║ ✨ Your project is ready! ║');
|
package/package.json
CHANGED
package/template/AGENTS.md
CHANGED
|
@@ -151,6 +151,49 @@ Layout shell: `src/templates/dashboard/DashboardLayout.tsx`
|
|
|
151
151
|
|
|
152
152
|
---
|
|
153
153
|
|
|
154
|
+
## Component sourcing — in this order
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
1st: @ramme-io/ui → Button, Card, Input, Icon, Sidebar, Modal, Drawer, StatCard…
|
|
158
|
+
2nd: @ramme-io/kernel → SmartTable, AutoForm, useCrudLocalStorage, useDataQuery…
|
|
159
|
+
3rd: src/features/<name> → local wrappers around kernel primitives
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Before creating any component, search the inventory. Run it — do not guess:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
cat node_modules/@ramme-io/ui/src/wizardManifest.ts
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Generated from each component's `@wizard` annotation, it carries the id,
|
|
169
|
+
description, tags, props and import path for every component, and it is the
|
|
170
|
+
authoritative answer to "does this already exist?". If it exists, use it.
|
|
171
|
+
|
|
172
|
+
Before writing state logic, check `@ramme-io/kernel` hooks. Before adding a
|
|
173
|
+
dependency, check the capability table above.
|
|
174
|
+
|
|
175
|
+
## Where things live
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
src/
|
|
179
|
+
config/
|
|
180
|
+
app.manifest.ts ← App identity, entities, theme defaults
|
|
181
|
+
sitemap.ts ← Route registry (add new pages here)
|
|
182
|
+
component-registry.tsx ← Component resolver for AI-driven rendering
|
|
183
|
+
navigation.ts ← User menu, settings menu, footer links
|
|
184
|
+
data/
|
|
185
|
+
mockData.ts ← Seed data + DATA_REGISTRY (DataLake)
|
|
186
|
+
features/
|
|
187
|
+
<domain>/pages/ ← Feature pages (FSD pattern)
|
|
188
|
+
templates/
|
|
189
|
+
dashboard/DashboardLayout ← Canonical layout (sidebar + header + Outlet)
|
|
190
|
+
components/
|
|
191
|
+
ProtectedAppShell.tsx ← Root shell (WorkflowEngine, Inspector, AI Chat, Settings)
|
|
192
|
+
layout/AppChromeHost.tsx ← Viewport orchestrator (header/sidebar/canvas slots)
|
|
193
|
+
pages/
|
|
194
|
+
InventoryManager.tsx ← Golden Path exemplar — copy this pattern for new pages
|
|
195
|
+
```
|
|
196
|
+
|
|
154
197
|
## Do Not
|
|
155
198
|
|
|
156
199
|
- ❌ Raw HTML `<button>` — use `<Button>` from `@ramme-io/ui`
|
|
@@ -159,6 +202,7 @@ Layout shell: `src/templates/dashboard/DashboardLayout.tsx`
|
|
|
159
202
|
- ❌ Hardcoded hex colors — use `text-primary`, `text-foreground`, CSS vars
|
|
160
203
|
- ❌ `h-screen` or `overflow-hidden` in page components — AppChromeHost owns the viewport
|
|
161
204
|
- ❌ Inline business logic in components — extract to hooks
|
|
205
|
+
- ❌ `<Flex>`, `<Box>`, `<Stack>` — Ramme has no such components
|
|
162
206
|
- ❌ Installing packages without `pnpm`
|
|
163
207
|
- ❌ **Installing anything before checking the capability table above.** Charts,
|
|
164
208
|
tables, forms, date pickers, realtime, AI, and state are all already wired.
|
|
@@ -167,40 +211,24 @@ Layout shell: `src/templates/dashboard/DashboardLayout.tsx`
|
|
|
167
211
|
|
|
168
212
|
---
|
|
169
213
|
|
|
170
|
-
##
|
|
171
|
-
|
|
172
|
-
### Cursor / Windsurf System Prompt
|
|
173
|
-
```
|
|
174
|
-
You are working inside a Ramme Framework application.
|
|
175
|
-
|
|
176
|
-
Framework laws: read .rammerules before writing any code.
|
|
177
|
-
Capability table: read AGENTS.md "What is already wired" before installing anything.
|
|
178
|
-
Component library: @ramme-io/ui (Button, Card, Input, Icon, Sidebar, Modal, Drawer, StatCard, etc.)
|
|
179
|
-
Data/Logic layer: @ramme-io/kernel (SmartTable, AutoForm, useCrudLocalStorage, useDataQuery, useAuth, etc.)
|
|
214
|
+
## Your coding agent already has this
|
|
180
215
|
|
|
181
|
-
|
|
182
|
-
|
|
216
|
+
You do not need to paste a system prompt anywhere. When this project was
|
|
217
|
+
created, this file was written out under every name the common agents look for:
|
|
183
218
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
Component inventory: node_modules/@ramme-io/ui/src/wizardManifest.ts — search before building.
|
|
201
|
-
Golden Path exemplar: src/pages/InventoryManager.tsx.
|
|
202
|
-
To add a page: create in src/features/<domain>/pages/, register in component-registry.tsx, add to sitemap.ts.
|
|
203
|
-
|
|
204
|
-
Styling: Tailwind only. Use CSS vars (text-foreground, bg-card, text-primary) — never hardcoded hex.
|
|
205
|
-
Package manager: pnpm only.
|
|
206
|
-
```
|
|
219
|
+
| your agent | reads |
|
|
220
|
+
|---|---|
|
|
221
|
+
| Claude Code | `CLAUDE.md` (imports this file) |
|
|
222
|
+
| Cursor | `.cursorrules` |
|
|
223
|
+
| Cline | `.clinerules` |
|
|
224
|
+
| Windsurf | `.windsurfrules` |
|
|
225
|
+
| anything else | point it at `AGENTS.md` |
|
|
226
|
+
|
|
227
|
+
They are copies of this file, written once when the project was created. They
|
|
228
|
+
do not re-sync on their own, so when you change the rules: **edit `AGENTS.md`,
|
|
229
|
+
then copy it over the others.** `AGENTS.md` is the one meant to be read by a
|
|
230
|
+
human; the rest exist only because each agent looks for a different filename.
|
|
231
|
+
|
|
232
|
+
That is the whole trick: the rules travel with the project instead of living in
|
|
233
|
+
your head or in a chat window, so an agent that has never seen this codebase
|
|
234
|
+
still builds from the same parts as the last one.
|
package/template/CHANGELOG.md
CHANGED
package/template/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
CodeBlock,
|
|
4
|
+
Card,
|
|
5
|
+
Button,
|
|
6
|
+
Icon,
|
|
7
|
+
Badge,
|
|
8
|
+
} from '@ramme-io/ui';
|
|
4
9
|
|
|
5
10
|
const CURSOR_WINDSURF_PROMPT = `You are working inside a Ramme Framework application.
|
|
6
11
|
|
|
@@ -90,25 +95,14 @@ interface CopyBlockProps {
|
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
function CopyBlock({ label, code, language = 'text', badge }: CopyBlockProps) {
|
|
93
|
-
const [copied, setCopied] = useState(false);
|
|
94
|
-
const copy = () => {
|
|
95
|
-
navigator.clipboard.writeText(code);
|
|
96
|
-
setCopied(true);
|
|
97
|
-
setTimeout(() => setCopied(false), 2000);
|
|
98
|
-
};
|
|
99
98
|
return (
|
|
100
99
|
<div className="space-y-2">
|
|
101
|
-
|
|
100
|
+
{badge && (
|
|
102
101
|
<div className="flex items-center gap-2">
|
|
103
|
-
<
|
|
104
|
-
{badge && <Badge variant="secondary">{badge}</Badge>}
|
|
102
|
+
<Badge variant="secondary">{badge}</Badge>
|
|
105
103
|
</div>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{copied ? 'Copied!' : 'Copy'}
|
|
109
|
-
</Button>
|
|
110
|
-
</div>
|
|
111
|
-
<RammeCodeBlock code={code} language={language} />
|
|
104
|
+
)}
|
|
105
|
+
<CodeBlock code={code} language={language} filename={label} />
|
|
112
106
|
</div>
|
|
113
107
|
);
|
|
114
108
|
}
|
package/template/.cursorrules
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
# Ramme Framework Architectural Rules
|
|
2
|
-
- Zero-Jank Mandate: Every animation and chart rendering must be hardware-accelerated. Never introduce unbuffered high-frequency state updates to the UI thread. Use the 15Hz Refresh Shield from `@ramme-io/kernel` for rapid data.
|
|
3
|
-
- The Golden Path: Refer to `src/pages/InventoryManager.tsx` as the canonical reference for state orchestration, CRUD tables, AutoForm binding, and chart rendering.
|
|
4
|
-
- Sitemap-Driven Routing: Routes must be registered inside `src/config/sitemap.ts`. The App Shell resolves sitemaps dynamically.
|
package/template/.rammerules
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
# .rammerules — Ramme Framework Laws
|
|
2
|
-
# This file is the authoritative law file for all coding agents and developers.
|
|
3
|
-
# Read this before writing any code.
|
|
4
|
-
|
|
5
|
-
## 1. Identity
|
|
6
|
-
|
|
7
|
-
This is a **Ramme Framework** application — an AI-native, browser-based web OS built on a
|
|
8
|
-
two-layer architecture:
|
|
9
|
-
|
|
10
|
-
- `@ramme-io/ui` — Tier 1 Atoms: pure presentational components, no data fetching
|
|
11
|
-
- `@ramme-io/kernel` — Tier 2 Logic: data hooks, stores, providers, auth, MQTT, SmartTable
|
|
12
|
-
|
|
13
|
-
## 2. The Reuse-Over-Build Mandate
|
|
14
|
-
|
|
15
|
-
Before creating any UI component, search the inventory. Run this — do not guess:
|
|
16
|
-
|
|
17
|
-
cat node_modules/@ramme-io/ui/src/wizardManifest.ts
|
|
18
|
-
|
|
19
|
-
Generated from each component's `@wizard` annotation, it carries the id,
|
|
20
|
-
description, tags, props, and import path for every component. It is the
|
|
21
|
-
authoritative answer to "does this already exist?". `AUTO_REGISTRY`
|
|
22
|
-
(exported from `@ramme-io/ui`) is the runtime lookup of the same set — useful
|
|
23
|
-
for dynamic rendering, but the manifest is what you read to find things.
|
|
24
|
-
|
|
25
|
-
Before writing any state logic, check `@ramme-io/kernel` hooks first.
|
|
26
|
-
Before adding a dependency, check the capability table in AGENTS.md — charts,
|
|
27
|
-
tables, forms, date pickers, realtime, AI and state are already wired.
|
|
28
|
-
|
|
29
|
-
If a component or hook exists — USE IT. Do not recreate it.
|
|
30
|
-
|
|
31
|
-
## 3. Component Sourcing Hierarchy
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
1st: @ramme-io/ui → Button, Card, Input, Icon, Sidebar, Modal, Drawer, StatCard…
|
|
35
|
-
2nd: @ramme-io/kernel → SmartTable, AutoForm, useCrudLocalStorage, useDataQuery…
|
|
36
|
-
3rd: src/features/<name> → Local "Smart Block" wrappers around kernel primitives
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## 4. Route Addition Flow (The Golden Path)
|
|
40
|
-
|
|
41
|
-
To add a new page to the dashboard:
|
|
42
|
-
|
|
43
|
-
1. Create the page component in `src/features/<domain>/pages/MyPage.tsx`
|
|
44
|
-
- Use `@ramme-io/ui` primitives only (no raw HTML buttons, no raw HTML inputs)
|
|
45
|
-
- Keep business logic in hooks, not in the component
|
|
46
|
-
2. Add the component to `src/config/component-registry.tsx`
|
|
47
|
-
3. Add the route entry to `src/config/sitemap.ts`
|
|
48
|
-
|
|
49
|
-
Reference exemplar: `src/pages/InventoryManager.tsx`
|
|
50
|
-
|
|
51
|
-
## 5. Data Contract
|
|
52
|
-
|
|
53
|
-
All app data flows through the DataLake:
|
|
54
|
-
|
|
55
|
-
```ts
|
|
56
|
-
// main.tsx
|
|
57
|
-
initializeDataLake(DATA_REGISTRY);
|
|
58
|
-
|
|
59
|
-
// In DATA_REGISTRY (src/data/mockData.ts), register all entities:
|
|
60
|
-
export const DATA_REGISTRY: Record<string, any[]> = {
|
|
61
|
-
inventory: INGREDIENTS,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// In a page component, read + write via kernel hooks:
|
|
65
|
-
const { data, createItem } = useCrudLocalStorage('ramme_db_<entityId>', SEED_DATA);
|
|
66
|
-
const query = useDataQuery(data, { sort: { field: 'name', direction: 'asc' } });
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
DataLake key: the `id` field in `SmartTable` must match the key in `DATA_REGISTRY`.
|
|
70
|
-
|
|
71
|
-
## 6. Layout Laws
|
|
72
|
-
|
|
73
|
-
- NEVER hardcode `h-screen`, `fixed top-0 left-0`, or `overflow-hidden` inside page components.
|
|
74
|
-
- Page components are rendered inside `<Outlet />` inside `AppChromeHost` — the viewport is
|
|
75
|
-
already locked. Let content scroll naturally.
|
|
76
|
-
- Use `<div className="p-6 space-y-6">` as the page wrapper.
|
|
77
|
-
- The `AppChromeHost` slot pattern handles: header (App scope), sidebar (Section scope),
|
|
78
|
-
canvas (Content scope). Never fight this.
|
|
79
|
-
|
|
80
|
-
## 7. Styling Laws
|
|
81
|
-
|
|
82
|
-
- Use Tailwind utility classes.
|
|
83
|
-
- NEVER use `style={{ color: '#hex' }}` — always use theme CSS variables:
|
|
84
|
-
`text-foreground`, `text-muted-foreground`, `bg-card`, `bg-primary`, `border-border`
|
|
85
|
-
- NEVER use `bg-white` or `bg-black` — they break dark mode.
|
|
86
|
-
- NEVER use `<Flex>`, `<Box>`, or `<Stack>` components — Ramme does not use those.
|
|
87
|
-
|
|
88
|
-
## 8. Anti-Patterns (Do Not Do These)
|
|
89
|
-
|
|
90
|
-
```tsx
|
|
91
|
-
// ❌ Raw HTML button
|
|
92
|
-
<button className="bg-blue-500 text-white px-4 py-2 rounded">Save</button>
|
|
93
|
-
|
|
94
|
-
// ✅ Framework button
|
|
95
|
-
import { Button } from '@ramme-io/ui';
|
|
96
|
-
<Button variant="primary">Save</Button>
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
```tsx
|
|
100
|
-
// ❌ Hardcoded layout sizing
|
|
101
|
-
<div className="h-screen w-full fixed top-0">
|
|
102
|
-
|
|
103
|
-
// ✅ Let AppChromeHost handle the viewport
|
|
104
|
-
<div className="p-6 space-y-6">
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
```tsx
|
|
108
|
-
// ❌ Inline business logic
|
|
109
|
-
const handleSave = async () => { /* 50 lines */ };
|
|
110
|
-
|
|
111
|
-
// ✅ Domain hook
|
|
112
|
-
const { saveItem } = useInventoryItem();
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
```tsx
|
|
116
|
-
// ❌ Hardcoded colors
|
|
117
|
-
<div style={{ color: '#0ea5e9' }}>
|
|
118
|
-
|
|
119
|
-
// ✅ CSS variable
|
|
120
|
-
<div className="text-primary">
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## 9. Package Manager
|
|
124
|
-
|
|
125
|
-
This project uses `pnpm` exclusively. Never run `npm install` or `yarn add`.
|
|
126
|
-
|
|
127
|
-
## 10. Key File Map
|
|
128
|
-
|
|
129
|
-
```
|
|
130
|
-
src/
|
|
131
|
-
config/
|
|
132
|
-
app.manifest.ts ← App identity, entities, theme defaults
|
|
133
|
-
sitemap.ts ← Route registry (add new pages here)
|
|
134
|
-
component-registry.tsx ← Component resolver for AI-driven rendering
|
|
135
|
-
navigation.ts ← User menu, settings menu, footer links
|
|
136
|
-
data/
|
|
137
|
-
mockData.ts ← Seed data + DATA_REGISTRY (DataLake)
|
|
138
|
-
features/
|
|
139
|
-
<domain>/pages/ ← Feature pages (FSD pattern)
|
|
140
|
-
config/AppConfigContext ← App-level config state
|
|
141
|
-
visualizations/SmartChart ← Chart wrapper around Recharts
|
|
142
|
-
templates/
|
|
143
|
-
dashboard/DashboardLayout ← Canonical layout (sidebar + header + Outlet)
|
|
144
|
-
components/
|
|
145
|
-
ProtectedAppShell.tsx ← Root shell (WorkflowEngine, Inspector, AI Chat, Settings)
|
|
146
|
-
AppHeader.tsx ← Top bar (logo + UserNav)
|
|
147
|
-
layout/AppChromeHost.tsx ← Viewport orchestrator (header/sidebar/canvas slots)
|
|
148
|
-
pages/
|
|
149
|
-
InventoryManager.tsx ← Golden Path exemplar — copy this pattern for new pages
|
|
150
|
-
```
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
3
|
-
import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism';
|
|
4
|
-
import { Icon, Button } from '@ramme-io/ui';
|
|
5
|
-
|
|
6
|
-
interface RammeCodeBlockProps {
|
|
7
|
-
code: string;
|
|
8
|
-
language?: string;
|
|
9
|
-
variant?: 'info' | 'success' | 'secondary' | 'primary';
|
|
10
|
-
title?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const RammeCodeBlock: React.FC<RammeCodeBlockProps> = ({
|
|
14
|
-
code,
|
|
15
|
-
language = 'tsx',
|
|
16
|
-
variant = 'primary',
|
|
17
|
-
title
|
|
18
|
-
}) => {
|
|
19
|
-
const [copied, setCopied] = useState(false);
|
|
20
|
-
|
|
21
|
-
const accentColor = `var(--app-${variant}-color)`;
|
|
22
|
-
|
|
23
|
-
const copy = () => {
|
|
24
|
-
navigator.clipboard.writeText(code);
|
|
25
|
-
setCopied(true);
|
|
26
|
-
setTimeout(() => setCopied(false), 2000);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<div className="group relative rounded-xl overflow-hidden border border-border bg-[#0d0d0d] animate-in fade-in zoom-in-95 duration-500">
|
|
31
|
-
{/* Header / Title Bar */}
|
|
32
|
-
<div className="px-4 py-2 bg-white/5 border-b border-white/10 flex justify-between items-center">
|
|
33
|
-
<div className="flex items-center gap-2">
|
|
34
|
-
<div className="w-2 h-2 rounded-full" style={{ backgroundColor: accentColor }} />
|
|
35
|
-
<span className="text-[10px] font-bold uppercase tracking-widest opacity-60 text-foreground">
|
|
36
|
-
{title || language}
|
|
37
|
-
</span>
|
|
38
|
-
</div>
|
|
39
|
-
<Button variant="ghost" size="icon" className="h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity" onClick={copy}>
|
|
40
|
-
<Icon name={copied ? "check" : "copy"} size={12} style={{ color: copied ? 'var(--app-success-color)' : 'inherit' }} />
|
|
41
|
-
</Button>
|
|
42
|
-
</div>
|
|
43
|
-
|
|
44
|
-
{/* Syntax Highlighting */}
|
|
45
|
-
<SyntaxHighlighter
|
|
46
|
-
language={language}
|
|
47
|
-
style={oneDark}
|
|
48
|
-
customStyle={{
|
|
49
|
-
margin: 0,
|
|
50
|
-
padding: '1.5rem',
|
|
51
|
-
fontSize: '0.85rem',
|
|
52
|
-
background: 'transparent',
|
|
53
|
-
lineHeight: '1.6',
|
|
54
|
-
}}
|
|
55
|
-
>
|
|
56
|
-
{code}
|
|
57
|
-
</SyntaxHighlighter>
|
|
58
|
-
|
|
59
|
-
{/* Dynamic Background Glow (Compliant with Theme) */}
|
|
60
|
-
<div
|
|
61
|
-
className="absolute -right-20 -bottom-20 w-40 h-40 blur-[80px] opacity-10 pointer-events-none"
|
|
62
|
-
style={{ backgroundColor: accentColor }}
|
|
63
|
-
/>
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
};
|