@damarkuncoro/landing-page 0.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/README.md ADDED
@@ -0,0 +1,358 @@
1
+ # @damarkuncoro/landing-page
2
+
3
+ Config-driven landing page library for building beautiful, responsive landing pages with minimal code.
4
+
5
+ ## Features
6
+
7
+ - 🚀 **Config-driven**: Define your landing page with a simple JSON configuration
8
+ - 📦 **Framework-agnostic**: Works with any framework (React, Vue, Svelte, etc.)
9
+ - 🎨 **Themeable**: Customize colors, fonts, spacing, and breakpoints
10
+ - 📱 **Responsive**: Built with mobile-first design principles
11
+ - ⚡ **Fast**: Lightweight and optimized for performance
12
+ - 🔌 **Extensible**: Add custom sections and components
13
+ - 📝 **Type-safe**: Full TypeScript support
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @damarkuncoro/landing-page
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ 1. Define your landing page configuration:
24
+
25
+ ```typescript
26
+ import { defineLandingPage } from '@damarkuncoro/landing-page'
27
+
28
+ const landingPage = defineLandingPage({
29
+ title: 'My Awesome Landing Page',
30
+ description: 'A beautiful landing page built with @damarkuncoro/landing-page',
31
+ sections: [
32
+ {
33
+ id: 'hero',
34
+ type: 'hero',
35
+ config: {
36
+ title: 'Welcome to Our Platform',
37
+ subtitle: 'Discover amazing features that will transform your workflow',
38
+ buttons: [
39
+ {
40
+ id: 'primary-button',
41
+ text: 'Get Started',
42
+ url: '/signup',
43
+ variant: 'primary',
44
+ size: 'md',
45
+ },
46
+ {
47
+ id: 'secondary-button',
48
+ text: 'Learn More',
49
+ url: '/about',
50
+ variant: 'secondary',
51
+ size: 'md',
52
+ },
53
+ ],
54
+ },
55
+ },
56
+ {
57
+ id: 'features',
58
+ type: 'features',
59
+ config: {
60
+ features: [
61
+ {
62
+ id: 'feature-1',
63
+ title: 'Fast Performance',
64
+ description: 'Our platform is optimized for speed and efficiency',
65
+ },
66
+ {
67
+ id: 'feature-2',
68
+ title: 'Modern Design',
69
+ description: 'Beautiful, responsive interface that works on all devices',
70
+ },
71
+ {
72
+ id: 'feature-3',
73
+ title: 'Secure & Reliable',
74
+ description: 'Enterprise-grade security and reliability',
75
+ },
76
+ ],
77
+ },
78
+ },
79
+ ],
80
+ })
81
+ ```
82
+
83
+ 2. Render it with your framework:
84
+
85
+ ### React
86
+
87
+ ```typescript
88
+ import React from 'react'
89
+ import ReactDOM from 'react-dom/client'
90
+ import { createReactRenderer } from '@damarkuncoro/landing-page'
91
+
92
+ const LandingPage = createReactRenderer()
93
+
94
+ ReactDOM.createRoot(document.getElementById('root')!).render(
95
+ <React.StrictMode>
96
+ <LandingPage config={landingPage} />
97
+ </React.StrictMode>
98
+ )
99
+ ```
100
+
101
+ ## Schema & Validation
102
+
103
+ The library includes comprehensive JSON schemas for validating landing page configurations. You can use these schemas to:
104
+
105
+ - Validate configurations before rendering
106
+ - Generate documentation
107
+ - Build no-code editors
108
+
109
+ ### Validation API
110
+
111
+ ```typescript
112
+ import { validateLandingPageConfig, validateSectionConfig } from '@damarkuncoro/landing-page'
113
+
114
+ // Validate entire landing page
115
+ const config = {
116
+ title: 'My Landing Page',
117
+ description: 'A beautiful landing page',
118
+ sections: [],
119
+ }
120
+
121
+ const errors = validateLandingPageConfig(config)
122
+ console.log(errors) // [{ field: 'root', message: 'must NOT have fewer than 1 items', type: 'minItems' }]
123
+
124
+ // Validate single section
125
+ const heroSection = {
126
+ title: 'Welcome',
127
+ subtitle: 'This is my landing page',
128
+ }
129
+
130
+ const sectionErrors = validateSectionConfig('hero', heroSection)
131
+ console.log(sectionErrors) // null - valid
132
+ ```
133
+
134
+ ### Accessing Schemas
135
+
136
+ ```typescript
137
+ import { landingPageSchema, sectionSchemas, schemaDefinitions } from '@damarkuncoro/landing-page'
138
+
139
+ // Get the entire landing page schema
140
+ console.log(landingPageSchema)
141
+
142
+ // Get specific section schemas
143
+ console.log(sectionSchemas.hero) // Hero section schema
144
+ console.log(sectionSchemas.features) // Features section schema
145
+ ```
146
+
147
+ ## Configuration
148
+
149
+ ### LandingPageConfig
150
+
151
+ The main configuration object that defines your entire landing page.
152
+
153
+ ```typescript
154
+ interface LandingPageConfig {
155
+ id?: string
156
+ className?: string
157
+ title: string
158
+ description: string
159
+ sections: Section[]
160
+ theme?: ThemeConfig
161
+ }
162
+ ```
163
+
164
+ ### Section Types
165
+
166
+ #### Hero Section
167
+
168
+ ```typescript
169
+ interface HeroConfig {
170
+ title: string
171
+ subtitle: string
172
+ image?: string
173
+ video?: string
174
+ buttons: ButtonConfig[]
175
+ alignment?: 'left' | 'center' | 'right'
176
+ }
177
+ ```
178
+
179
+ #### Features Section
180
+
181
+ ```typescript
182
+ interface FeatureConfig {
183
+ features: Feature[]
184
+ }
185
+
186
+ interface Feature {
187
+ id: string
188
+ title: string
189
+ description: string
190
+ icon?: string
191
+ image?: string
192
+ }
193
+ ```
194
+
195
+ #### Testimonials Section
196
+
197
+ ```typescript
198
+ interface TestimonialConfig {
199
+ testimonials: Testimonial[]
200
+ }
201
+
202
+ interface Testimonial {
203
+ id: string
204
+ quote: string
205
+ author: string
206
+ role?: string
207
+ avatar?: string
208
+ }
209
+ ```
210
+
211
+ #### Pricing Section
212
+
213
+ ```typescript
214
+ interface PricingConfig {
215
+ plans: PricingPlan[]
216
+ }
217
+
218
+ interface PricingPlan {
219
+ id: string
220
+ title: string
221
+ description: string
222
+ price: number
223
+ period?: string
224
+ features: string[]
225
+ button: ButtonConfig
226
+ featured?: boolean
227
+ }
228
+ ```
229
+
230
+ #### CTA Section
231
+
232
+ ```typescript
233
+ interface CtaConfig {
234
+ title: string
235
+ description: string
236
+ button: ButtonConfig
237
+ image?: string
238
+ }
239
+ ```
240
+
241
+ #### Footer Section
242
+
243
+ ```typescript
244
+ interface FooterConfig {
245
+ logo?: string
246
+ title?: string
247
+ description?: string
248
+ links: {
249
+ title: string
250
+ items: {
251
+ text: string
252
+ url: string
253
+ target?: '_blank' | '_self'
254
+ }[]
255
+ }[]
256
+ socialLinks: {
257
+ platform: string
258
+ url: string
259
+ icon?: string
260
+ }[]
261
+ copyright?: string
262
+ }
263
+ ```
264
+
265
+ ### Theme Configuration
266
+
267
+ ```typescript
268
+ interface ThemeConfig {
269
+ colors: {
270
+ primary: string
271
+ secondary: string
272
+ accent: string
273
+ background: string
274
+ text: string
275
+ muted: string
276
+ }
277
+ spacing: {
278
+ xs: string
279
+ sm: string
280
+ md: string
281
+ lg: string
282
+ xl: string
283
+ }
284
+ fonts: {
285
+ heading: string
286
+ body: string
287
+ mono: string
288
+ }
289
+ breakpoints: {
290
+ sm: string
291
+ md: string
292
+ lg: string
293
+ xl: string
294
+ }
295
+ }
296
+ ```
297
+
298
+ ## API
299
+
300
+ ### defineLandingPage(config: LandingPageConfig)
301
+
302
+ Creates a landing page instance from a configuration object.
303
+
304
+ ```typescript
305
+ const landingPage = defineLandingPage(config)
306
+ ```
307
+
308
+ ### Methods
309
+
310
+ - **getSection(id: string)**: Returns a section by id
311
+ - **addSection(section: Section)**: Adds a new section
312
+ - **removeSection(id: string)**: Removes a section by id
313
+ - **updateSection(id: string, updates: any)**: Updates a section
314
+ - **validate()**: Validates the configuration
315
+ - **toJSON()**: Returns the raw config
316
+
317
+ ## Extensibility
318
+
319
+ You can create custom section types and renderers by extending the library.
320
+
321
+ ### Custom Section Type
322
+
323
+ ```typescript
324
+ // types.ts
325
+ export type SectionType = 'hero' | 'features' | 'testimonials' | 'pricing' | 'cta' | 'footer' | 'custom'
326
+
327
+ // components/types.ts
328
+ export interface CustomSectionConfig {
329
+ content: string
330
+ }
331
+
332
+ // renderers/react.tsx
333
+ const CustomSection = ({ config, theme }: { config: CustomSectionConfig; theme: any }) => (
334
+ <Section className={config.className}>
335
+ <Container>
336
+ <div dangerouslySetInnerHTML={{ __html: config.content }} />
337
+ </Container>
338
+ </Section>
339
+ )
340
+
341
+ // In createReactRenderer
342
+ switch (section.type) {
343
+ // ... existing types
344
+ case 'custom':
345
+ return <CustomSection config={section.config} theme={theme} key={section.id} />
346
+ }
347
+ ```
348
+
349
+ ## Browser Support
350
+
351
+ - Chrome (latest)
352
+ - Firefox (latest)
353
+ - Safari (latest)
354
+ - Edge (latest)
355
+
356
+ ## License
357
+
358
+ MIT