@rubixscript/react-native-onboarding 1.0.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.
@@ -0,0 +1,574 @@
1
+ import { Platform, StyleSheet } from 'react-native';
2
+ import { OnboardingTheme, PresetConfig } from '../types';
3
+
4
+ // ============================================================================
5
+ // BASE THEME UTILITIES
6
+ // ============================================================================
7
+
8
+ const createBaseTypography = () => ({
9
+ title: {
10
+ fontFamily: Platform.select({ ios: 'System', android: 'Roboto' }),
11
+ fontWeight: '700' as const,
12
+ letterSpacing: -0.5,
13
+ },
14
+ description: {
15
+ fontFamily: Platform.select({ ios: 'System', android: 'Roboto' }),
16
+ fontWeight: '400' as const,
17
+ lineHeight: 24,
18
+ },
19
+ button: {
20
+ fontFamily: Platform.select({ ios: 'System', android: 'Roboto' }),
21
+ fontWeight: '600' as const,
22
+ letterSpacing: 0.5,
23
+ },
24
+ label: {
25
+ fontFamily: Platform.select({ ios: 'System', android: 'Roboto' }),
26
+ fontWeight: '500' as const,
27
+ },
28
+ });
29
+
30
+ const createSpacing = () => ({
31
+ xs: 4,
32
+ sm: 8,
33
+ md: 16,
34
+ lg: 24,
35
+ xl: 32,
36
+ xxl: 48,
37
+ });
38
+
39
+ const createBorderRadius = () => ({
40
+ sm: 4,
41
+ md: 12,
42
+ lg: 16,
43
+ xl: 24,
44
+ full: 9999,
45
+ });
46
+
47
+ const createShadows = () => ({
48
+ sm: {
49
+ ...Platform.select({
50
+ ios: { shadowColor: '#000', shadowOffset: { width: 0, height: 1 }, shadowOpacity: 0.1, shadowRadius: 2 },
51
+ android: { elevation: 2 },
52
+ }),
53
+ },
54
+ md: {
55
+ ...Platform.select({
56
+ ios: { shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.15, shadowRadius: 4 },
57
+ android: { elevation: 4 },
58
+ }),
59
+ },
60
+ lg: {
61
+ ...Platform.select({
62
+ ios: { shadowColor: '#000', shadowOffset: { width: 0, height: 4 }, shadowOpacity: 0.2, shadowRadius: 8 },
63
+ android: { elevation: 8 },
64
+ }),
65
+ },
66
+ });
67
+
68
+ // ============================================================================
69
+ // ONEPAGE THEME
70
+ // ============================================================================
71
+
72
+ export const onepageTheme: OnboardingTheme = {
73
+ colors: {
74
+ primary: '#667EEA',
75
+ secondary: '#06D6A0',
76
+ background: '#F8FAFC',
77
+ surface: '#FFFFFF',
78
+ text: {
79
+ primary: '#1E293B',
80
+ secondary: '#64748B',
81
+ inverse: '#FFFFFF',
82
+ },
83
+ border: '#E2E8F0',
84
+ overlay: 'rgba(0, 0, 0, 0.1)',
85
+ },
86
+ typography: {
87
+ title: {
88
+ ...createBaseTypography().title,
89
+ fontSize: 28,
90
+ color: '#1E293B',
91
+ },
92
+ description: {
93
+ ...createBaseTypography().description,
94
+ fontSize: 15,
95
+ color: '#64748B',
96
+ },
97
+ button: {
98
+ ...createBaseTypography().button,
99
+ fontSize: 16,
100
+ color: '#FFFFFF',
101
+ },
102
+ label: {
103
+ ...createBaseTypography().label,
104
+ fontSize: 14,
105
+ color: '#475569',
106
+ },
107
+ },
108
+ spacing: createSpacing(),
109
+ borderRadius: createBorderRadius(),
110
+ shadows: createShadows(),
111
+ };
112
+
113
+ export const onepagePreset: PresetConfig = {
114
+ theme: onepageTheme,
115
+ navigation: {
116
+ style: 'dots',
117
+ position: 'bottom',
118
+ showSkip: true,
119
+ showBack: true,
120
+ skipLabel: 'Skip',
121
+ backLabel: 'Back',
122
+ nextLabel: 'Next',
123
+ doneLabel: "Let's Get Started",
124
+ },
125
+ animation: {
126
+ type: 'slide',
127
+ duration: 300,
128
+ },
129
+ defaultSlideStyles: {
130
+ image: {
131
+ width: '100%',
132
+ height: 280,
133
+ borderRadius: 16,
134
+ marginBottom: 24,
135
+ },
136
+ title: {
137
+ fontSize: 24,
138
+ marginBottom: 12,
139
+ textAlign: 'center',
140
+ },
141
+ description: {
142
+ fontSize: 15,
143
+ textAlign: 'center',
144
+ paddingHorizontal: 32,
145
+ lineHeight: 22,
146
+ },
147
+ },
148
+ };
149
+
150
+ // ============================================================================
151
+ // ZAPRECIPE THEME
152
+ // ============================================================================
153
+
154
+ export const zaprecipeTheme: OnboardingTheme = {
155
+ colors: {
156
+ primary: '#6B4EFF',
157
+ secondary: '#FF8C42',
158
+ background: '#FFFFFF',
159
+ surface: '#FFFFFF',
160
+ text: {
161
+ primary: '#1E293B',
162
+ secondary: '#64748B',
163
+ inverse: '#FFFFFF',
164
+ },
165
+ border: '#E2E8F0',
166
+ overlay: 'rgba(255, 255, 255, 0.2)',
167
+ },
168
+ typography: {
169
+ title: {
170
+ ...createBaseTypography().title,
171
+ fontSize: 32,
172
+ color: '#FFFFFF',
173
+ },
174
+ description: {
175
+ ...createBaseTypography().description,
176
+ fontSize: 16,
177
+ color: 'rgba(255, 255, 255, 0.9)',
178
+ },
179
+ button: {
180
+ ...createBaseTypography().button,
181
+ fontSize: 16,
182
+ color: '#FFFFFF',
183
+ },
184
+ label: {
185
+ ...createBaseTypography().label,
186
+ fontSize: 14,
187
+ color: '#FFFFFF',
188
+ },
189
+ },
190
+ spacing: createSpacing(),
191
+ borderRadius: createBorderRadius(),
192
+ shadows: createShadows(),
193
+ };
194
+
195
+ export const zaprecipePreset: PresetConfig = {
196
+ theme: zaprecipeTheme,
197
+ navigation: {
198
+ style: 'dots',
199
+ position: 'floating',
200
+ showSkip: true,
201
+ showBack: true,
202
+ skipLabel: 'Skip',
203
+ backLabel: 'Back',
204
+ nextLabel: 'Continue',
205
+ doneLabel: "Let's Start Cooking!",
206
+ },
207
+ animation: {
208
+ type: 'fade',
209
+ duration: 250,
210
+ },
211
+ defaultSlideStyles: {
212
+ image: {
213
+ width: '100%',
214
+ height: 300,
215
+ borderRadius: 0,
216
+ marginBottom: 0,
217
+ },
218
+ title: {
219
+ fontSize: 28,
220
+ marginBottom: 16,
221
+ textAlign: 'center',
222
+ },
223
+ description: {
224
+ fontSize: 15,
225
+ textAlign: 'center',
226
+ paddingHorizontal: 24,
227
+ lineHeight: 22,
228
+ },
229
+ },
230
+ };
231
+
232
+ // ============================================================================
233
+ // POMODO THEME
234
+ // ============================================================================
235
+
236
+ export const pomodoTheme: OnboardingTheme = {
237
+ colors: {
238
+ primary: '#FF6B6B',
239
+ secondary: '#667EEA',
240
+ background: '#F6F6F6',
241
+ surface: '#FFFFFF',
242
+ text: {
243
+ primary: '#1E293B',
244
+ secondary: '#64748B',
245
+ inverse: '#FFFFFF',
246
+ },
247
+ border: '#E2E8F0',
248
+ overlay: 'rgba(0, 0, 0, 0.05)',
249
+ },
250
+ typography: {
251
+ title: {
252
+ ...createBaseTypography().title,
253
+ fontSize: 24,
254
+ color: '#1E293B',
255
+ },
256
+ description: {
257
+ ...createBaseTypography().description,
258
+ fontSize: 14,
259
+ color: '#64748B',
260
+ },
261
+ button: {
262
+ ...createBaseTypography().button,
263
+ fontSize: 16,
264
+ color: '#FFFFFF',
265
+ },
266
+ },
267
+ spacing: createSpacing(),
268
+ borderRadius: createBorderRadius(),
269
+ shadows: createShadows(),
270
+ };
271
+
272
+ export const pomodoPreset: PresetConfig = {
273
+ theme: pomodoTheme,
274
+ navigation: {
275
+ style: 'dots',
276
+ position: 'bottom',
277
+ showSkip: false,
278
+ showBack: false,
279
+ nextLabel: 'Next',
280
+ doneLabel: 'Get Started',
281
+ },
282
+ animation: {
283
+ type: 'fade',
284
+ duration: 500,
285
+ },
286
+ defaultSlideStyles: {
287
+ icon: {
288
+ width: 160,
289
+ height: 160,
290
+ borderRadius: 80,
291
+ justifyContent: 'center',
292
+ alignItems: 'center',
293
+ marginBottom: 24,
294
+ },
295
+ title: {
296
+ fontSize: 22,
297
+ marginBottom: 12,
298
+ textAlign: 'center',
299
+ fontWeight: '600',
300
+ },
301
+ description: {
302
+ fontSize: 14,
303
+ textAlign: 'center',
304
+ paddingHorizontal: 32,
305
+ lineHeight: 20,
306
+ },
307
+ },
308
+ };
309
+
310
+ // ============================================================================
311
+ // MODERN THEME
312
+ // ============================================================================
313
+
314
+ export const modernTheme: OnboardingTheme = {
315
+ colors: {
316
+ primary: '#8B5CF6',
317
+ secondary: '#EC4899',
318
+ background: '#FFFFFF',
319
+ surface: '#F9FAFB',
320
+ text: {
321
+ primary: '#111827',
322
+ secondary: '#6B7280',
323
+ inverse: '#FFFFFF',
324
+ },
325
+ border: '#E5E7EB',
326
+ overlay: 'rgba(0, 0, 0, 0.05)',
327
+ },
328
+ typography: {
329
+ title: {
330
+ ...createBaseTypography().title,
331
+ fontSize: 30,
332
+ color: '#111827',
333
+ },
334
+ description: {
335
+ ...createBaseTypography().description,
336
+ fontSize: 16,
337
+ color: '#6B7280',
338
+ },
339
+ button: {
340
+ ...createBaseTypography().button,
341
+ fontSize: 16,
342
+ color: '#FFFFFF',
343
+ },
344
+ },
345
+ spacing: createSpacing(),
346
+ borderRadius: createBorderRadius(),
347
+ shadows: createShadows(),
348
+ };
349
+
350
+ export const modernPreset: PresetConfig = {
351
+ theme: modernTheme,
352
+ navigation: {
353
+ style: 'progress-bar',
354
+ position: 'top',
355
+ showSkip: true,
356
+ showBack: true,
357
+ skipLabel: 'Skip',
358
+ backLabel: 'Back',
359
+ nextLabel: 'Next',
360
+ doneLabel: 'Get Started',
361
+ },
362
+ animation: {
363
+ type: 'slide',
364
+ duration: 350,
365
+ },
366
+ defaultSlideStyles: {
367
+ title: {
368
+ fontSize: 28,
369
+ marginBottom: 16,
370
+ fontWeight: '700',
371
+ },
372
+ description: {
373
+ fontSize: 16,
374
+ lineHeight: 24,
375
+ },
376
+ },
377
+ };
378
+
379
+ // ============================================================================
380
+ // MINIMAL THEME
381
+ // ============================================================================
382
+
383
+ export const minimalTheme: OnboardingTheme = {
384
+ colors: {
385
+ primary: '#111827',
386
+ secondary: '#6B7280',
387
+ background: '#FFFFFF',
388
+ surface: '#FFFFFF',
389
+ text: {
390
+ primary: '#111827',
391
+ secondary: '#6B7280',
392
+ inverse: '#FFFFFF',
393
+ },
394
+ border: '#E5E7EB',
395
+ },
396
+ typography: {
397
+ title: {
398
+ ...createBaseTypography().title,
399
+ fontSize: 24,
400
+ color: '#111827',
401
+ },
402
+ description: {
403
+ ...createBaseTypography().description,
404
+ fontSize: 15,
405
+ color: '#6B7280',
406
+ },
407
+ button: {
408
+ ...createBaseTypography().button,
409
+ fontSize: 15,
410
+ color: '#FFFFFF',
411
+ },
412
+ },
413
+ spacing: createSpacing(),
414
+ borderRadius: createBorderRadius(),
415
+ shadows: createShadows(),
416
+ };
417
+
418
+ export const minimalPreset: PresetConfig = {
419
+ theme: minimalTheme,
420
+ navigation: {
421
+ style: 'steps',
422
+ position: 'bottom',
423
+ showSkip: true,
424
+ showBack: false,
425
+ skipLabel: 'Skip',
426
+ nextLabel: 'Next',
427
+ doneLabel: 'Start',
428
+ },
429
+ animation: {
430
+ type: 'fade',
431
+ duration: 200,
432
+ },
433
+ defaultSlideStyles: {
434
+ title: {
435
+ fontSize: 22,
436
+ marginBottom: 8,
437
+ fontWeight: '600',
438
+ },
439
+ description: {
440
+ fontSize: 14,
441
+ lineHeight: 20,
442
+ },
443
+ },
444
+ };
445
+
446
+ // ============================================================================
447
+ // GRADIENT THEME
448
+ // ============================================================================
449
+
450
+ export const gradientTheme: OnboardingTheme = {
451
+ colors: {
452
+ primary: '#667EEA',
453
+ secondary: '#764BA2',
454
+ background: '#667EEA',
455
+ surface: 'rgba(255, 255, 255, 0.15)',
456
+ text: {
457
+ primary: '#FFFFFF',
458
+ secondary: 'rgba(255, 255, 255, 0.8)',
459
+ inverse: '#FFFFFF',
460
+ },
461
+ border: 'rgba(255, 255, 255, 0.2)',
462
+ overlay: 'rgba(255, 255, 255, 0.1)',
463
+ },
464
+ typography: {
465
+ title: {
466
+ ...createBaseTypography().title,
467
+ fontSize: 32,
468
+ color: '#FFFFFF',
469
+ },
470
+ description: {
471
+ ...createBaseTypography().description,
472
+ fontSize: 16,
473
+ color: 'rgba(255, 255, 255, 0.9)',
474
+ },
475
+ button: {
476
+ ...createBaseTypography().button,
477
+ fontSize: 16,
478
+ color: '#FFFFFF',
479
+ },
480
+ },
481
+ spacing: createSpacing(),
482
+ borderRadius: createBorderRadius(),
483
+ shadows: createShadows(),
484
+ };
485
+
486
+ export const gradientPreset: PresetConfig = {
487
+ theme: gradientTheme,
488
+ navigation: {
489
+ style: 'dots',
490
+ position: 'floating',
491
+ showSkip: true,
492
+ showBack: true,
493
+ skipLabel: 'Skip',
494
+ backLabel: 'Back',
495
+ nextLabel: 'Next',
496
+ doneLabel: 'Get Started',
497
+ },
498
+ animation: {
499
+ type: 'parallax',
500
+ duration: 400,
501
+ parallaxFactor: 0.3,
502
+ },
503
+ defaultSlideStyles: {
504
+ title: {
505
+ fontSize: 28,
506
+ marginBottom: 16,
507
+ textAlign: 'center',
508
+ },
509
+ description: {
510
+ fontSize: 15,
511
+ textAlign: 'center',
512
+ paddingHorizontal: 24,
513
+ lineHeight: 22,
514
+ },
515
+ },
516
+ };
517
+
518
+ // ============================================================================
519
+ // THEME GETTERS
520
+ // ============================================================================
521
+
522
+ export const getTheme = (preset: string): OnboardingTheme => {
523
+ const themes: Record<string, OnboardingTheme> = {
524
+ onepage: onepageTheme,
525
+ zaprecipe: zaprecipeTheme,
526
+ pomodo: pomodoTheme,
527
+ modern: modernTheme,
528
+ minimal: minimalTheme,
529
+ gradient: gradientTheme,
530
+ };
531
+ return themes[preset] || modernTheme;
532
+ };
533
+
534
+ export const getPreset = (preset: string): PresetConfig => {
535
+ const presets: Record<string, PresetConfig> = {
536
+ onepage: onepagePreset,
537
+ zaprecipe: zaprecipePreset,
538
+ pomodo: pomodoPreset,
539
+ modern: modernPreset,
540
+ minimal: minimalPreset,
541
+ gradient: gradientPreset,
542
+ };
543
+ return presets[preset] || modernPreset;
544
+ };
545
+
546
+ export const mergeTheme = (base: OnboardingTheme, custom?: Partial<OnboardingTheme>): OnboardingTheme => {
547
+ if (!custom) return base;
548
+
549
+ return {
550
+ colors: { ...base.colors, ...custom.colors, text: { ...base.colors.text, ...custom.colors?.text } },
551
+ typography: { ...base.typography, ...custom.typography },
552
+ spacing: { ...base.spacing, ...custom.spacing },
553
+ borderRadius: { ...base.borderRadius, ...custom.borderRadius },
554
+ shadows: { ...base.shadows, ...custom.shadows },
555
+ };
556
+ };
557
+
558
+ export default {
559
+ onepageTheme,
560
+ zaprecipeTheme,
561
+ pomodoTheme,
562
+ modernTheme,
563
+ minimalTheme,
564
+ gradientTheme,
565
+ onepagePreset,
566
+ zaprecipePreset,
567
+ pomodoPreset,
568
+ modernPreset,
569
+ minimalPreset,
570
+ gradientPreset,
571
+ getTheme,
572
+ getPreset,
573
+ mergeTheme,
574
+ };