@codefluss/section-renderer 0.0.1-alpha.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/README.md ADDED
@@ -0,0 +1,220 @@
1
+ # @codefluss/section-renderer
2
+
3
+ Framework-agnostic SSR renderer for page sections. Works seamlessly with Next.js, Remix, TanStack
4
+ Start, and any React framework.
5
+
6
+ ## Features
7
+
8
+ - ✅ **SSR-Native** - All plugin renderers are server-side compatible
9
+ - ✅ **Framework-Agnostic** - Works with Next.js, Remix, TanStack Start
10
+ - ✅ **Type-Safe** - Full TypeScript support with compile-time plugin validation
11
+ - ✅ **Zero Client JS** - Renders completely on the server
12
+ - ✅ **Tree-Shakeable** - Only bundle the plugins you use
13
+ - ✅ **Design System** - Built-in design system with customization
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pnpm add @codefluss/section-renderer
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ### Next.js 15 (App Router)
24
+
25
+ ```tsx
26
+ // app/page/[slug]/page.tsx
27
+ import { SectionRenderer } from '@codefluss/section-renderer';
28
+
29
+ export default async function Page({ params }) {
30
+ const pageData = await fetchPage(params.slug);
31
+
32
+ return (
33
+ <main>
34
+ {pageData.sections.map(section => (
35
+ <SectionRenderer key={section.id} section={section} language='de' />
36
+ ))}
37
+ </main>
38
+ );
39
+ }
40
+ ```
41
+
42
+ ### Remix
43
+
44
+ ```tsx
45
+ // routes/page.$slug.tsx
46
+ import { SectionRenderer } from '@codefluss/section-renderer';
47
+
48
+ export async function loader({ params }) {
49
+ return json(await fetchPage(params.slug));
50
+ }
51
+
52
+ export default function PageRoute() {
53
+ const { sections } = useLoaderData<typeof loader>();
54
+
55
+ return (
56
+ <main>
57
+ {sections.map(section => (
58
+ <SectionRenderer key={section.id} section={section} language='de' />
59
+ ))}
60
+ </main>
61
+ );
62
+ }
63
+ ```
64
+
65
+ ### TanStack Start
66
+
67
+ ```tsx
68
+ // routes/page.$slug.tsx
69
+ import { createFileRoute } from '@tanstack/react-router';
70
+ import { SectionRenderer } from '@codefluss/section-renderer';
71
+
72
+ export const Route = createFileRoute('/page/$slug')({
73
+ loader: async ({ params }) => fetchPage(params.slug),
74
+ component: PageComponent,
75
+ });
76
+
77
+ function PageComponent() {
78
+ const { sections } = Route.useLoaderData();
79
+
80
+ return (
81
+ <main>
82
+ {sections.map(section => (
83
+ <SectionRenderer key={section.id} section={section} language='de' />
84
+ ))}
85
+ </main>
86
+ );
87
+ }
88
+ ```
89
+
90
+ ## Data Structure
91
+
92
+ ### Page Section
93
+
94
+ ```typescript
95
+ const section: PageSection = {
96
+ id: 'section-1',
97
+ type: 'section',
98
+ elements: [
99
+ {
100
+ id: 'heading-1',
101
+ pluginId: 'heading',
102
+ data: {
103
+ content_i18n: {
104
+ de: 'Willkommen',
105
+ en: 'Welcome',
106
+ },
107
+ level: 1,
108
+ },
109
+ },
110
+ {
111
+ id: 'text-1',
112
+ pluginId: 'text',
113
+ data: {
114
+ content_i18n: {
115
+ de: 'Dies ist ein Beispieltext',
116
+ en: 'This is example text',
117
+ },
118
+ },
119
+ },
120
+ ],
121
+ layout: {
122
+ background: {
123
+ type: 'gradient',
124
+ gradient: {
125
+ type: 'linear',
126
+ angle: 135,
127
+ stops: [
128
+ { color: '#667eea', position: 0 },
129
+ { color: '#764ba2', position: 100 },
130
+ ],
131
+ },
132
+ },
133
+ spacing: {
134
+ padding: { top: 48, right: 32, bottom: 48, left: 32 },
135
+ },
136
+ width: {
137
+ mode: 'boxed',
138
+ maxWidth: '1200px',
139
+ },
140
+ },
141
+ };
142
+ ```
143
+
144
+ ## Supported Plugins
145
+
146
+ - `heading` - Headings (H1-H6)
147
+ - `text` - Single-line text
148
+ - `paragraph` - Multi-line text
149
+ - `image` - Responsive images
150
+ - `container` - Layout containers
151
+ - `canvas-2d` - 2D canvas (SSR fallback)
152
+ - `background-3d` - 3D backgrounds (SSR fallback)
153
+ - `configurator-3d` - 3D configurators (SSR fallback)
154
+
155
+ ## Custom Design System
156
+
157
+ ```typescript
158
+ import { createDesignSystem, SectionRenderer } from '@codefluss/section-renderer';
159
+
160
+ const myDesignSystem = createDesignSystem({
161
+ fonts: {
162
+ get: (key) => ({
163
+ family: 'Roboto, sans-serif',
164
+ size: key === 'heading' ? '48px' : '16px',
165
+ lineHeight: '1.5',
166
+ weight: key === 'heading' ? 'bold' : 'normal',
167
+ }),
168
+ },
169
+ colors: {
170
+ get: (key) => ({
171
+ value: key === 'primary' ? '#ff0000' : '#000000',
172
+ opacity: 1,
173
+ }),
174
+ },
175
+ });
176
+
177
+ // Use custom design system
178
+ <SectionRenderer
179
+ section={section}
180
+ designSystem={myDesignSystem}
181
+ />
182
+ ```
183
+
184
+ ## API Reference
185
+
186
+ ### SectionRenderer
187
+
188
+ ```typescript
189
+ interface SectionRendererProps {
190
+ section: PageSection;
191
+ language?: string;
192
+ designSystem?: PluginDesignSystem;
193
+ className?: string;
194
+ }
195
+ ```
196
+
197
+ ### Utilities
198
+
199
+ ```typescript
200
+ // Get plugin renderer
201
+ const renderer = getPluginRenderer('heading');
202
+
203
+ // Check if plugin is supported
204
+ const isSupported = isPluginSupported('heading');
205
+
206
+ // Get all supported plugins
207
+ const plugins = getSupportedPlugins();
208
+ ```
209
+
210
+ ## TypeScript
211
+
212
+ Full TypeScript support out of the box:
213
+
214
+ ```typescript
215
+ import type { PageSection, SectionElement, PluginId } from '@codefluss/section-renderer';
216
+ ```
217
+
218
+ ## License
219
+
220
+ MIT
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Section Renderer - Main Exports
3
+ *
4
+ * Framework-agnostic SSR renderer for page sections
5
+ */
6
+ export { SectionRenderer } from "./section-renderer";
7
+ export type { SectionRendererProps, PageSection, SectionElement, PluginId, PluginRenderer, PluginRendererMap, } from "./types";
8
+ export { getPluginRenderer, isPluginSupported, getSupportedPlugins, PLUGIN_RENDERERS, } from "./utils/plugin-loader";
9
+ export { defaultDesignSystem, createDesignSystem, storyDependencies, cn, } from "./utils/design-system";
10
+ export { propertyDefinitionsToArgTypes, commonFormFieldArgTypes, } from "./utils/storybook-argtypes";
11
+ export { createDesignSystemFromJson, resolveTypographyStyles, resolveColorValue, resolveSpacingStyles, resolveGapStyles, resolveBoxModelStyles, resolveContainerGridStyles, resolveFormFieldStyles, resolveCheckboxRadioStyles, resolveButtonStyles, } from "./utils/design-system-resolver";
12
+ export type { BoxModelStyles, FormFieldStyles, CheckboxRadioStyles, ButtonStyles, } from "./utils/design-system-resolver";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,YAAY,EACX,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,QAAQ,EACR,cAAc,EACd,iBAAiB,GACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GAChB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACN,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,EAAE,GACF,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACN,6BAA6B,EAC7B,uBAAuB,GACvB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACN,0BAA0B,EAC1B,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,0BAA0B,EAC1B,mBAAmB,GACnB,MAAM,gCAAgC,CAAC;AAExC,YAAY,EACX,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,YAAY,GACZ,MAAM,gCAAgC,CAAC"}