cdslibrary 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,65 @@
1
+ import { Animated, FlatList, StyleSheet, Text, View } from "react-native";
2
+
3
+
4
+ import { getSlides } from "../assets/onboarding/slides";
5
+ import { OnboardingItem } from "./onboardingItem";
6
+ import { useTheme } from "../context/CDSThemeContext";
7
+ import { CDSBottomSheet } from "./CDSBottomSheet";
8
+ import { useEffect, useRef, useState } from "react";
9
+ import { Paginator } from "./Paginator";
10
+
11
+ export const Onboarding = () => {
12
+ const [parentWidth, setParentWidth] = useState(0);
13
+
14
+ // Función onLayout para obtener las dimensiones del contenedor padre
15
+ const handleLayout = (event) => {
16
+ const { width } = event.nativeEvent.layout;
17
+ setParentWidth(width); // Guardamos el ancho en el estado
18
+ };
19
+
20
+
21
+ const [currentIndex, setCurrentIndex] = useState(0);
22
+
23
+ const viewableItemsChanged = useRef(({ viewableItems }) => {
24
+ setCurrentIndex(viewableItems[0].index);
25
+ }).current;
26
+
27
+ const viewConfig = useRef({ viewAreaCoveragePercentThreshold: 50 }).current;
28
+
29
+ const scrollX = useRef(new Animated.Value(0)).current;
30
+ console.log(scrollX)
31
+ const slidesRef = useRef(null);
32
+
33
+ const { isDarkMode } = useTheme();
34
+ const slides = getSlides(isDarkMode);
35
+
36
+
37
+ return (
38
+ <View style={Styles.container} onLayout={handleLayout}>
39
+ <FlatList data={slides} renderItem={({ item }) => <OnboardingItem item={item} parentWidth={parentWidth} />}
40
+ horizontal
41
+ showsHorizontalScrollIndicator={false}
42
+ pagingEnabled
43
+ bounces={false}
44
+ keyExtractor={(item) => item.id}
45
+ onScroll={Animated.event([{ nativeEvent: { contentOffset: { x: scrollX } } }], { useNativeDriver: false })}
46
+ onViewableItemsChanged={viewableItemsChanged}
47
+ viewabilityConfig={viewConfig}
48
+ scrollEventThrottle={32}
49
+ ref={slidesRef}
50
+ style={{ width: '100%' }}
51
+ />
52
+ <Paginator width={parentWidth} data={slides} scrollX={scrollX}/>
53
+ </View>
54
+ )
55
+ }
56
+
57
+
58
+
59
+ const Styles = StyleSheet.create({
60
+ container: {
61
+ flex: 1,
62
+ justifyContent: 'center',
63
+ width: '100%',
64
+ }
65
+ })
@@ -0,0 +1,52 @@
1
+ import { View, Text, StyleSheet, Animated, useWindowDimensions } from "react-native";
2
+ import { useTheme } from "../context/CDSThemeContext";
3
+
4
+
5
+
6
+
7
+ export const Paginator = ({ data, scrollX, width }) => {
8
+
9
+ const { theme } = useTheme();
10
+
11
+ return (
12
+ <View style={styles.container}>
13
+ {data.map((_, index) => {
14
+
15
+ const inputRange = [(index - 1) * width, index * width, (index + 1) * width];
16
+ const dotWidth = scrollX.interpolate({
17
+ inputRange,
18
+ outputRange: [8, 16, 8],
19
+ extrapolate: "clamp",
20
+ });
21
+ const dotColor = scrollX.interpolate({
22
+ inputRange,
23
+ outputRange: [theme.surface.special.progressbarBg, theme.surface.special.progress, theme.surface.special.progressbarBg],
24
+ extrapolate: "clamp",
25
+ });
26
+ return (
27
+ <Animated.View
28
+ key={index.toString()}
29
+ style={[
30
+ styles.dot,
31
+ { width: dotWidth, backgroundColor: dotColor },
32
+ ]}
33
+ />
34
+ );
35
+ })}
36
+ </View>
37
+ );
38
+ }
39
+
40
+ const styles = StyleSheet.create({
41
+ container: {
42
+ flexDirection: "row",
43
+ height: 64,
44
+ },
45
+ dot: {
46
+ width: 8,
47
+ height: 8,
48
+ borderRadius: 4,
49
+ marginHorizontal: 4,
50
+ backgroundColor: 'red'
51
+ },
52
+ });
@@ -0,0 +1,39 @@
1
+ import { View, Text, Image, useWindowDimensions, StyleSheet } from "react-native";
2
+ import { getSemanticTextStyles } from "../tokens/CDSsemanticTextStyles";
3
+ import { useTheme } from "../context/CDSThemeContext";
4
+ export const OnboardingItem = ({ item, parentWidth }) => {
5
+
6
+ const { theme } = useTheme();
7
+ const textStyles = getSemanticTextStyles(theme);
8
+
9
+ return (
10
+ <View style={[styles.container, {width: parentWidth}]}>
11
+ <View style={[styles.textContainer]}>
12
+ <Text style={textStyles.bold.lg}>{item.title}</Text>
13
+ <Text style={textStyles.regular.md}>{item.description}</Text>
14
+ </View>
15
+ <Image source={item.image} resizeMode="contain" style={[styles.image,]} />
16
+ </View>
17
+ );
18
+ }
19
+
20
+
21
+ const styles = StyleSheet.create({
22
+ container: {
23
+ flex: 1,
24
+ justifyContent: "flex-end",
25
+ alignItems: "center",
26
+ gap: 40,
27
+ backgroundColor: 'red',
28
+
29
+ },
30
+
31
+ textContainer: {
32
+ width: '100%',
33
+ gap: 16,
34
+ },
35
+
36
+ image: {
37
+ height: 353,
38
+ },
39
+ });
@@ -0,0 +1,52 @@
1
+ import React, { createContext, useState, useContext, useEffect } from 'react';
2
+ import { Appearance, Platform } from 'react-native';
3
+ import {CDSsemanticColors} from '../tokens/CDSsemanticColors';
4
+
5
+
6
+ const ThemeContext = createContext();
7
+
8
+ export const CDSThemeProvider = ({ children }) => {
9
+
10
+ const getSystemTheme = () => {
11
+ if (Platform.OS === 'web') {
12
+ return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
13
+ }
14
+ return Appearance.getColorScheme() || 'light';
15
+ };
16
+
17
+ const [theme, setTheme] = useState(getSystemTheme);
18
+
19
+ const toggleTheme = () => {
20
+ setTheme(theme === 'light' ? 'dark' : 'light');
21
+ };
22
+
23
+ const isDarkMode = theme === 'dark';
24
+
25
+ useEffect(() => {
26
+ if (Platform.OS === 'web') {
27
+ const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
28
+ const handleChange = (e) => {
29
+ setTheme(e.matches ? 'dark' : 'light');
30
+ };
31
+ mediaQuery.addEventListener('change', handleChange);
32
+
33
+ return () => {
34
+ mediaQuery.removeEventListener('change', handleChange);
35
+ };
36
+ } else {
37
+ const subscription = Appearance.addChangeListener(({ colorScheme }) => {
38
+ setTheme(colorScheme);
39
+ });
40
+
41
+ return () => subscription.remove();
42
+ }
43
+ }, []);
44
+
45
+ return (
46
+ <ThemeContext.Provider value={{ theme: CDSsemanticColors[theme], toggleTheme, isDarkMode }}>
47
+ {children}
48
+ </ThemeContext.Provider>
49
+ );
50
+ };
51
+
52
+ export const useTheme = () => useContext(ThemeContext);
package/index.js ADDED
@@ -0,0 +1,21 @@
1
+ import { registerRootComponent } from 'expo';
2
+
3
+ import App from './App';
4
+
5
+ // registerRootComponent calls AppRegistry.registerComponent('main', () => App);
6
+ // It also ensures that whether you load the app in Expo Go or in a native build,
7
+ // the environment is set up appropriately
8
+ registerRootComponent(App);
9
+
10
+ export {CDSBottomSheet} from './components/CDSBottomSheet';
11
+ export {CDSButton} from './components/CDSButton';
12
+ export {CDSCarousel} from './components/CDSCarousel';
13
+ export {CDSCarouselDots} from './components/CDSCarouselDots';
14
+ export {CDSInput} from './components/CDSInput';
15
+ export {CDSOnboarding} from './components/CDSOnboarding';
16
+ export {CDSSwitch} from './components/CDSSwitch';
17
+
18
+
19
+ export {CDSThemeProvider, useTheme} from './context/CDSThemeContext';
20
+ export {getSemanticTextStyles} from './tokens/CDSsemanticTextStyles';
21
+ export {CDSsemanticColors} from './tokens/CDSsemanticColors';
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "cdslibrary",
3
+ "license": "0BSD",
4
+ "version": "1.0.0",
5
+ "main": "index.js",
6
+ "author": "Nat Viramontes",
7
+ "description": "A library of components for the CDS project",
8
+ "scripts": {
9
+ "start": "expo start",
10
+ "android": "expo start --android",
11
+ "ios": "expo start --ios",
12
+ "web": "expo start --web"
13
+ },
14
+ "dependencies": {
15
+ "@expo-google-fonts/inter": "^0.2.3",
16
+ "@expo/metro-runtime": "~4.0.1",
17
+ "@expo/vector-icons": "^14.0.2",
18
+ "expo": "~52.0.38",
19
+ "expo-status-bar": "~2.0.1",
20
+ "react": "18.3.1",
21
+ "react-native": "0.76.7",
22
+ "react-native-web": "~0.19.13"
23
+ },
24
+ "devDependencies": {
25
+ "@babel/core": "^7.20.0"
26
+ },
27
+ "private": false
28
+ }
@@ -0,0 +1,146 @@
1
+ export const CDSprimitiveColors = {
2
+ brand: {
3
+ 50: "#FEF5F8",
4
+ 100: "#FEECF2",
5
+ 150: "#FBB1C9",
6
+ 200: "#F98BAE",
7
+ 300: "#F76492",
8
+ 400: "#F53D77",
9
+ 500: "#F3165C",
10
+ 600: "#D50B4E",
11
+ 700: "#AE0940",
12
+ 800: "#880732",
13
+ 900: "#610524",
14
+ },
15
+ neutral: {
16
+ 0: "#FFFFFF",
17
+ 100: "#F9F9F9",
18
+ 200: "#F1F3F3",
19
+ 300: "#E8EAEB",
20
+ 400: "#D8DCDE",
21
+ 500: "#9DA5A9",
22
+ 600: "#586061",
23
+ 700: "#40484D",
24
+ 800: "#283238",
25
+ 850: "#36383B",
26
+ 900: "#0E1319",
27
+ 950: "#292B2D",
28
+ 975: "#1E1E1E",
29
+ 1000: "#000000",
30
+ },
31
+ blue: {
32
+ 100: "#EFF5FD",
33
+ 200: "#B1D1FB",
34
+ 250: "#A0BFE8",
35
+ 275: "#3780DF",
36
+ 300: "#0B63D5",
37
+ 350: "#063674",
38
+ },
39
+ green: {
40
+ 100: "#EFFDF5",
41
+ 200: "#A2EAC2",
42
+ 250: "#B5D0C1",
43
+ 300: "#0E8142",
44
+ 350: "#0A5C2F",
45
+ },
46
+ scarlet: {
47
+ 100: "#FCF0F0",
48
+ 200: "#F3BAB6",
49
+ 250: "#D9B5B5",
50
+ 300: "#C02121",
51
+ 350: "#831616",
52
+ },
53
+ marigold: {
54
+ 100: "#FFF7F0",
55
+ 200: "#FFD3AD",
56
+ 250: "#E7C3A6",
57
+ 300: "#E06900",
58
+ 350: "#A34D00",
59
+ },
60
+ brown: {
61
+ 100: "#F6F4F5",
62
+ 150: "#DAD2D3",
63
+ 200: "#C8BCBE",
64
+ 300: "#B6A5A8",
65
+ 400: "#A38F92",
66
+ 500: "#91787C",
67
+ 600: "#7B6568",
68
+ 700: "#655255",
69
+ 800: "#4F4043",
70
+ 900: "#3D292C",
71
+ 950: "#382E2F",
72
+ },
73
+ overlay: {light:"rgba(0, 0, 0, 0.50)",
74
+ dark: 'rgba(0,0,0,0.75)'
75
+ },
76
+ };
77
+
78
+
79
+
80
+
81
+ export const CDSprimitiveFontValues = {
82
+
83
+ family: {
84
+ interRegular: 'Inter_400Regular',
85
+ interSemiBold: 'Inter_600SemiBold',
86
+ interBold: 'Inter_700Bold',
87
+ },
88
+
89
+ size: {
90
+ typography: {
91
+ mobile: {
92
+ xs: 12,
93
+ sm: 14,
94
+ md: 17,
95
+ lg: 21,
96
+ xl: 25,
97
+ "2xl": 30,
98
+ "3xl": 36,
99
+ },
100
+ desktop: {
101
+ xs: 14,
102
+ sm: 16,
103
+ md: 21,
104
+ lg: 27,
105
+ xl: 36,
106
+ "2xl": 47,
107
+ "3xl": 61,
108
+ },
109
+ },
110
+ iconography: {
111
+ mobile: {
112
+ xs: 14,
113
+ sm: 18,
114
+ md: 22,
115
+ lg: 40,
116
+ },
117
+ desktop: {
118
+ xs: 16,
119
+ sm: 20,
120
+ md: 24,
121
+ lg: 48,
122
+ },
123
+ },
124
+ },
125
+
126
+ lineHeight: {
127
+ mobile: {
128
+ xs: 18,
129
+ sm: 20,
130
+ md: 24,
131
+ lg: 28,
132
+ xl: 31,
133
+ "2xl": 38,
134
+ "3xl": 44,
135
+ },
136
+ desktop: {
137
+ xs: 18,
138
+ sm: 22,
139
+ md: 28,
140
+ lg: 35,
141
+ xl: 43,
142
+ "2xl": 56,
143
+ "3xl": 71,
144
+ },
145
+ },
146
+ };
@@ -0,0 +1,213 @@
1
+ import { CDSprimitiveColors } from "./CDSprimitiveTokens";
2
+ import { Dimensions, Platform } from "react-native";
3
+ const { width } = Dimensions.get("window");
4
+
5
+ export const CDSsemanticColors = {
6
+ light: {
7
+ logo:{
8
+ source:"../assets/logoMonte.png"
9
+ },
10
+ icon: {
11
+ neutral: {
12
+ primary: CDSprimitiveColors.neutral[800],
13
+ secondary: CDSprimitiveColors.neutral[0],
14
+ tertiary: CDSprimitiveColors.neutral[200],
15
+ primaryVariant: CDSprimitiveColors.neutral[300],
16
+ tertiaryVariant: CDSprimitiveColors.neutral[600],
17
+ secondaryVariant: CDSprimitiveColors.neutral[100],
18
+ },
19
+ brand: {
20
+ primary: CDSprimitiveColors.brand[600],
21
+ },
22
+ feedback: {
23
+ info: CDSprimitiveColors.blue[300],
24
+ success: CDSprimitiveColors.green[300],
25
+ warning: CDSprimitiveColors.marigold[300],
26
+ error: CDSprimitiveColors.scarlet[300],
27
+ },
28
+ },
29
+ surface: {
30
+ action: {
31
+ disabled: CDSprimitiveColors.neutral[400],
32
+ primary: CDSprimitiveColors.neutral[800],
33
+ pressed: CDSprimitiveColors.neutral[200],
34
+ },
35
+ feedback: {
36
+ info: CDSprimitiveColors.blue[100],
37
+ success: CDSprimitiveColors.green[100],
38
+ warning: CDSprimitiveColors.marigold[100],
39
+ error: CDSprimitiveColors.scarlet[100],
40
+ },
41
+ neutral: {
42
+ primary: CDSprimitiveColors.neutral[0],
43
+ tertiary: CDSprimitiveColors.neutral[200],
44
+ primaryVariant: CDSprimitiveColors.neutral[300],
45
+ tertiaryVariant: CDSprimitiveColors.neutral[600],
46
+ secondary: CDSprimitiveColors.neutral[100],
47
+ },
48
+ background: {
49
+ default: CDSprimitiveColors.brown[100],
50
+ },
51
+ special: {
52
+ overlay: CDSprimitiveColors.overlay.light,
53
+ scroll: CDSprimitiveColors.neutral[400],
54
+ tooltip: CDSprimitiveColors.neutral[500],
55
+ progress: CDSprimitiveColors.brand[600],
56
+ progressbarBg: CDSprimitiveColors.neutral[400],
57
+ display: CDSprimitiveColors.neutral[800],
58
+ footer: CDSprimitiveColors.neutral[800],
59
+ illustrationIdCardDevice: CDSprimitiveColors.neutral[400],
60
+ illustrationIdCard: CDSprimitiveColors.neutral[500],
61
+ },
62
+ },
63
+ outline: {
64
+ brand: {
65
+ primary: CDSprimitiveColors.brand[600],
66
+ secondary: CDSprimitiveColors.brand[400],
67
+ tertiary: CDSprimitiveColors.brand[50],
68
+ },
69
+ action: {
70
+ disabled: CDSprimitiveColors.neutral[400],
71
+ primary: CDSprimitiveColors.neutral[800],
72
+ },
73
+ neutral: {
74
+ focus: CDSprimitiveColors.neutral[800],
75
+ tertiary: CDSprimitiveColors.neutral[600],
76
+ primary: CDSprimitiveColors.neutral[300],
77
+ secondary: CDSprimitiveColors.neutral[400],
78
+ primaryVariant: CDSprimitiveColors.neutral[200],
79
+ tertiaryVariant: CDSprimitiveColors.neutral[500],
80
+ },
81
+ feedback: {
82
+ info: CDSprimitiveColors.blue[300],
83
+ success: CDSprimitiveColors.green[300],
84
+ warning: CDSprimitiveColors.marigold[300],
85
+ error: CDSprimitiveColors.scarlet[300],
86
+ },
87
+ },
88
+ text: {
89
+ neutral: {
90
+ primary: CDSprimitiveColors.neutral[800],
91
+ contrast: CDSprimitiveColors.neutral[0],
92
+ disabled: CDSprimitiveColors.neutral[500],
93
+ secondary: CDSprimitiveColors.neutral[600],
94
+ tertiary: CDSprimitiveColors.neutral[900],
95
+ placeholder: CDSprimitiveColors.neutral[500],
96
+ },
97
+ brand: {
98
+ primary: CDSprimitiveColors.brand[600],
99
+ secondary: CDSprimitiveColors.brand[400],
100
+ tertiary: CDSprimitiveColors.brand[800],
101
+ },
102
+ feedback: {
103
+ info: CDSprimitiveColors.blue[300],
104
+ success: CDSprimitiveColors.green[300],
105
+ warning: CDSprimitiveColors.marigold[300],
106
+ error: CDSprimitiveColors.scarlet[300],
107
+ },
108
+ },
109
+ },
110
+ dark: {
111
+ logo:{
112
+ source:'../assets/logoMonteW.png'
113
+ },
114
+ icon: {
115
+ neutral: {
116
+ primary: CDSprimitiveColors.neutral[200],
117
+ secondary: CDSprimitiveColors.neutral[1000],
118
+ tertiary: CDSprimitiveColors.neutral[200],
119
+ primaryVariant: CDSprimitiveColors.neutral[700],
120
+ tertiaryVariant: CDSprimitiveColors.neutral[600],
121
+ secondaryVariant: CDSprimitiveColors.neutral[975],
122
+ },
123
+ brand: {
124
+ primary: CDSprimitiveColors.brand[150],
125
+ },
126
+ feedback: {
127
+ info: CDSprimitiveColors.blue[350],
128
+ success: CDSprimitiveColors.green[350],
129
+ warning: CDSprimitiveColors.marigold[350],
130
+ error: CDSprimitiveColors.scarlet[350],
131
+ },
132
+ },
133
+ surface: {
134
+ action: {
135
+ disabled: CDSprimitiveColors.neutral[600],
136
+ primary: CDSprimitiveColors.neutral[200],
137
+ },
138
+ feedback: {
139
+ info: CDSprimitiveColors.blue[250],
140
+ success: CDSprimitiveColors.green[250],
141
+ warning: CDSprimitiveColors.marigold[250],
142
+ error: CDSprimitiveColors.scarlet[250],
143
+ },
144
+ neutral: {
145
+ primary: CDSprimitiveColors.neutral[950],
146
+ tertiary: CDSprimitiveColors.neutral[200],
147
+ primaryVariant: CDSprimitiveColors.neutral[700],
148
+ tertiaryVariant: CDSprimitiveColors.neutral[600],
149
+ secondary: CDSprimitiveColors.neutral[975],
150
+ },
151
+ background: {
152
+ default: CDSprimitiveColors.neutral[950],
153
+ },
154
+ special: {
155
+ overlay: CDSprimitiveColors.overlay.dark,
156
+ scroll: CDSprimitiveColors.neutral[400],
157
+ tooltip: CDSprimitiveColors.neutral[500],
158
+ progress: CDSprimitiveColors.brand[600],
159
+ progressbarBg: CDSprimitiveColors.neutral[400],
160
+ display: CDSprimitiveColors.neutral[800],
161
+ footer: CDSprimitiveColors.neutral[800],
162
+ illustrationIdCardDevice: CDSprimitiveColors.neutral[400],
163
+ illustrationIdCard: CDSprimitiveColors.neutral[500],
164
+ },
165
+ },
166
+ outline: {
167
+ brand: {
168
+ primary: CDSprimitiveColors.brand[500],
169
+ secondary: CDSprimitiveColors.brand[150],
170
+ tertiary: CDSprimitiveColors.brand[900],
171
+ },
172
+ action: {
173
+ disabled: CDSprimitiveColors.neutral[600],
174
+ primary: CDSprimitiveColors.neutral[200],
175
+ },
176
+ neutral: {
177
+ focus: CDSprimitiveColors.neutral[0],
178
+ tertiary: CDSprimitiveColors.neutral[200],
179
+ primary: CDSprimitiveColors.neutral[700],
180
+ secondary: CDSprimitiveColors.neutral[800],
181
+ primaryVariant: CDSprimitiveColors.neutral[600],
182
+ tertiaryVariant: CDSprimitiveColors.neutral[500],
183
+ },
184
+ feedback: {
185
+ info: CDSprimitiveColors.blue[350],
186
+ success: CDSprimitiveColors.green[350],
187
+ warning: CDSprimitiveColors.marigold[350],
188
+ error: CDSprimitiveColors.scarlet[350],
189
+ },
190
+ },
191
+ text: {
192
+ neutral: {
193
+ primary: CDSprimitiveColors.neutral[200],
194
+ contrast: CDSprimitiveColors.neutral[1000],
195
+ disabled: CDSprimitiveColors.neutral[850],
196
+ secondary: CDSprimitiveColors.neutral[400],
197
+ tertiary: CDSprimitiveColors.neutral[100],
198
+ placeholder: CDSprimitiveColors.neutral[300],
199
+ },
200
+ brand: {
201
+ primary: CDSprimitiveColors.brand[150],
202
+ secondary: CDSprimitiveColors.brand[700],
203
+ tertiary: CDSprimitiveColors.brand[900],
204
+ },
205
+ feedback: {
206
+ info: CDSprimitiveColors.blue[350],
207
+ success: CDSprimitiveColors.green[350],
208
+ warning: CDSprimitiveColors.marigold[350],
209
+ error: CDSprimitiveColors.scarlet[350],
210
+ },
211
+ },
212
+ },
213
+ };