@robin-ux/native 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/.eslintrc.js +5 -0
- package/README.md +35 -0
- package/android/build.gradle +43 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/robinuxnative/RobinUxNativeModule.kt +50 -0
- package/android/src/main/java/expo/modules/robinuxnative/RobinUxNativeView.kt +30 -0
- package/build/RobinUxNative.types.d.ts +18 -0
- package/build/RobinUxNative.types.d.ts.map +1 -0
- package/build/RobinUxNative.types.js +2 -0
- package/build/RobinUxNative.types.js.map +1 -0
- package/build/RobinUxNativeModule.d.ts +10 -0
- package/build/RobinUxNativeModule.d.ts.map +1 -0
- package/build/RobinUxNativeModule.js +4 -0
- package/build/RobinUxNativeModule.js.map +1 -0
- package/build/RobinUxNativeModule.web.d.ts +10 -0
- package/build/RobinUxNativeModule.web.d.ts.map +1 -0
- package/build/RobinUxNativeModule.web.js +12 -0
- package/build/RobinUxNativeModule.web.js.map +1 -0
- package/build/RobinUxNativeView.d.ts +4 -0
- package/build/RobinUxNativeView.d.ts.map +1 -0
- package/build/RobinUxNativeView.js +7 -0
- package/build/RobinUxNativeView.js.map +1 -0
- package/build/RobinUxNativeView.web.d.ts +4 -0
- package/build/RobinUxNativeView.web.d.ts.map +1 -0
- package/build/RobinUxNativeView.web.js +7 -0
- package/build/RobinUxNativeView.web.js.map +1 -0
- package/build/components/Badge.d.ts +36 -0
- package/build/components/Badge.d.ts.map +1 -0
- package/build/components/Badge.js +78 -0
- package/build/components/Badge.js.map +1 -0
- package/build/components/Button.d.ts +43 -0
- package/build/components/Button.d.ts.map +1 -0
- package/build/components/Button.js +120 -0
- package/build/components/Button.js.map +1 -0
- package/build/components/DynamicStatusBar.d.ts +30 -0
- package/build/components/DynamicStatusBar.d.ts.map +1 -0
- package/build/components/DynamicStatusBar.js +70 -0
- package/build/components/DynamicStatusBar.js.map +1 -0
- package/build/components/Input.d.ts +73 -0
- package/build/components/Input.d.ts.map +1 -0
- package/build/components/Input.js +138 -0
- package/build/components/Input.js.map +1 -0
- package/build/components/SegmentedControl.d.ts +40 -0
- package/build/components/SegmentedControl.d.ts.map +1 -0
- package/build/components/SegmentedControl.js +73 -0
- package/build/components/SegmentedControl.js.map +1 -0
- package/build/components/Text.d.ts +32 -0
- package/build/components/Text.d.ts.map +1 -0
- package/build/components/Text.js +51 -0
- package/build/components/Text.js.map +1 -0
- package/build/components/index.d.ts +13 -0
- package/build/components/index.d.ts.map +1 -0
- package/build/components/index.js +13 -0
- package/build/components/index.js.map +1 -0
- package/build/index.d.ts +7 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +10 -0
- package/build/index.js.map +1 -0
- package/build/theme/ThemeContext.d.ts +22 -0
- package/build/theme/ThemeContext.d.ts.map +1 -0
- package/build/theme/ThemeContext.js +35 -0
- package/build/theme/ThemeContext.js.map +1 -0
- package/build/theme/ThemeProvider.d.ts +33 -0
- package/build/theme/ThemeProvider.d.ts.map +1 -0
- package/build/theme/ThemeProvider.js +31 -0
- package/build/theme/ThemeProvider.js.map +1 -0
- package/build/theme/defaultTheme.d.ts +18 -0
- package/build/theme/defaultTheme.d.ts.map +1 -0
- package/build/theme/defaultTheme.js +77 -0
- package/build/theme/defaultTheme.js.map +1 -0
- package/build/theme/index.d.ts +6 -0
- package/build/theme/index.d.ts.map +1 -0
- package/build/theme/index.js +7 -0
- package/build/theme/index.js.map +1 -0
- package/build/theme/types.d.ts +40 -0
- package/build/theme/types.d.ts.map +1 -0
- package/build/theme/types.js +2 -0
- package/build/theme/types.js.map +1 -0
- package/build/utils/index.d.ts +3 -0
- package/build/utils/index.d.ts.map +1 -0
- package/build/utils/index.js +3 -0
- package/build/utils/index.js.map +1 -0
- package/build/utils/styles.d.ts +88 -0
- package/build/utils/styles.d.ts.map +1 -0
- package/build/utils/styles.js +150 -0
- package/build/utils/styles.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/RobinUxNative.podspec +29 -0
- package/ios/RobinUxNativeModule.swift +48 -0
- package/ios/RobinUxNativeView.swift +38 -0
- package/package.json +69 -0
- package/src/RobinUxNative.types.ts +19 -0
- package/src/RobinUxNativeModule.ts +12 -0
- package/src/RobinUxNativeModule.web.ts +15 -0
- package/src/RobinUxNativeView.tsx +11 -0
- package/src/RobinUxNativeView.web.tsx +15 -0
- package/src/components/Badge.tsx +101 -0
- package/src/components/Button.tsx +176 -0
- package/src/components/DynamicStatusBar.tsx +93 -0
- package/src/components/Input.tsx +248 -0
- package/src/components/SegmentedControl.tsx +107 -0
- package/src/components/Text.tsx +107 -0
- package/src/components/index.ts +23 -0
- package/src/index.ts +70 -0
- package/src/theme/ThemeContext.ts +38 -0
- package/src/theme/ThemeProvider.tsx +45 -0
- package/src/theme/defaultTheme.ts +91 -0
- package/src/theme/index.ts +12 -0
- package/src/theme/types.ts +52 -0
- package/src/utils/index.ts +19 -0
- package/src/utils/styles.ts +188 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Theme, ThemeColors } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Default light theme colors - a neutral, accessible color palette.
|
|
5
|
+
*/
|
|
6
|
+
export const defaultLightColors: ThemeColors = {
|
|
7
|
+
// Backgrounds
|
|
8
|
+
background: '#ffffff',
|
|
9
|
+
backgroundSecondary: '#f5f5f5',
|
|
10
|
+
|
|
11
|
+
// Foreground (text)
|
|
12
|
+
foreground: '#1a1a1a',
|
|
13
|
+
foregroundSecondary: '#666666',
|
|
14
|
+
foregroundTertiary: '#999999',
|
|
15
|
+
|
|
16
|
+
// Primary brand colors
|
|
17
|
+
primary: '#3b82f6',
|
|
18
|
+
primaryLight: '#60a5fa',
|
|
19
|
+
primaryDark: '#2563eb',
|
|
20
|
+
|
|
21
|
+
// Accent colors
|
|
22
|
+
accent: '#8b5cf6',
|
|
23
|
+
accentLight: '#a78bfa',
|
|
24
|
+
|
|
25
|
+
// Semantic/status colors
|
|
26
|
+
destructive: '#ef4444',
|
|
27
|
+
destructiveForeground: '#ffffff',
|
|
28
|
+
success: '#10b981',
|
|
29
|
+
warning: '#f59e0b',
|
|
30
|
+
error: '#ef4444',
|
|
31
|
+
info: '#3b82f6',
|
|
32
|
+
|
|
33
|
+
// UI element colors
|
|
34
|
+
border: '#e5e5e5',
|
|
35
|
+
muted: '#f5f5f5',
|
|
36
|
+
mutedForeground: '#666666',
|
|
37
|
+
card: '#ffffff',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Default dark theme colors - a neutral, accessible dark color palette.
|
|
42
|
+
*/
|
|
43
|
+
export const defaultDarkColors: ThemeColors = {
|
|
44
|
+
// Backgrounds
|
|
45
|
+
background: '#0a0a0a',
|
|
46
|
+
backgroundSecondary: '#171717',
|
|
47
|
+
|
|
48
|
+
// Foreground (text)
|
|
49
|
+
foreground: '#fafafa',
|
|
50
|
+
foregroundSecondary: '#a3a3a3',
|
|
51
|
+
foregroundTertiary: '#737373',
|
|
52
|
+
|
|
53
|
+
// Primary brand colors
|
|
54
|
+
primary: '#60a5fa',
|
|
55
|
+
primaryLight: '#93c5fd',
|
|
56
|
+
primaryDark: '#3b82f6',
|
|
57
|
+
|
|
58
|
+
// Accent colors
|
|
59
|
+
accent: '#a78bfa',
|
|
60
|
+
accentLight: '#c4b5fd',
|
|
61
|
+
|
|
62
|
+
// Semantic/status colors
|
|
63
|
+
destructive: '#f87171',
|
|
64
|
+
destructiveForeground: '#ffffff',
|
|
65
|
+
success: '#34d399',
|
|
66
|
+
warning: '#fbbf24',
|
|
67
|
+
error: '#f87171',
|
|
68
|
+
info: '#60a5fa',
|
|
69
|
+
|
|
70
|
+
// UI element colors
|
|
71
|
+
border: '#262626',
|
|
72
|
+
muted: '#262626',
|
|
73
|
+
mutedForeground: '#a3a3a3',
|
|
74
|
+
card: '#171717',
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Default light theme - used as fallback when no ThemeProvider is present.
|
|
79
|
+
*/
|
|
80
|
+
export const defaultTheme: Theme = {
|
|
81
|
+
colors: defaultLightColors,
|
|
82
|
+
isDark: false,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Default dark theme variant.
|
|
87
|
+
*/
|
|
88
|
+
export const defaultDarkTheme: Theme = {
|
|
89
|
+
colors: defaultDarkColors,
|
|
90
|
+
isDark: true,
|
|
91
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Theme context and hooks
|
|
2
|
+
export { ThemeContext, useTheme, useThemeSafe } from './ThemeContext';
|
|
3
|
+
|
|
4
|
+
// Theme provider
|
|
5
|
+
export { ThemeProvider } from './ThemeProvider';
|
|
6
|
+
export type { ThemeProviderProps } from './ThemeProvider';
|
|
7
|
+
|
|
8
|
+
// Default themes
|
|
9
|
+
export { defaultTheme, defaultDarkTheme, defaultLightColors, defaultDarkColors } from './defaultTheme';
|
|
10
|
+
|
|
11
|
+
// Types
|
|
12
|
+
export type { Theme, ThemeColors, ThemeContextValue } from './types';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme color definitions for @robin-ux/native components.
|
|
3
|
+
* These define all the semantic colors used by components.
|
|
4
|
+
*/
|
|
5
|
+
export interface ThemeColors {
|
|
6
|
+
// Backgrounds
|
|
7
|
+
background: string;
|
|
8
|
+
backgroundSecondary: string;
|
|
9
|
+
|
|
10
|
+
// Foreground (text)
|
|
11
|
+
foreground: string;
|
|
12
|
+
foregroundSecondary: string;
|
|
13
|
+
foregroundTertiary: string;
|
|
14
|
+
|
|
15
|
+
// Primary brand colors
|
|
16
|
+
primary: string;
|
|
17
|
+
primaryLight: string;
|
|
18
|
+
primaryDark: string;
|
|
19
|
+
|
|
20
|
+
// Accent colors
|
|
21
|
+
accent: string;
|
|
22
|
+
accentLight: string;
|
|
23
|
+
|
|
24
|
+
// Semantic/status colors
|
|
25
|
+
destructive: string;
|
|
26
|
+
destructiveForeground: string;
|
|
27
|
+
success: string;
|
|
28
|
+
warning: string;
|
|
29
|
+
error: string;
|
|
30
|
+
info: string;
|
|
31
|
+
|
|
32
|
+
// UI element colors
|
|
33
|
+
border: string;
|
|
34
|
+
muted: string;
|
|
35
|
+
mutedForeground: string;
|
|
36
|
+
card: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Complete theme object containing colors and mode information.
|
|
41
|
+
*/
|
|
42
|
+
export interface Theme {
|
|
43
|
+
colors: ThemeColors;
|
|
44
|
+
isDark: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Theme context value type.
|
|
49
|
+
*/
|
|
50
|
+
export interface ThemeContextValue {
|
|
51
|
+
theme: Theme;
|
|
52
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Style utilities
|
|
2
|
+
export {
|
|
3
|
+
spacing,
|
|
4
|
+
borderRadius,
|
|
5
|
+
typography,
|
|
6
|
+
shadows,
|
|
7
|
+
layouts,
|
|
8
|
+
useThemedStyles,
|
|
9
|
+
createThemedStyle,
|
|
10
|
+
} from './styles';
|
|
11
|
+
|
|
12
|
+
// Types
|
|
13
|
+
export type {
|
|
14
|
+
SpacingKey,
|
|
15
|
+
BorderRadiusKey,
|
|
16
|
+
TypographyVariant,
|
|
17
|
+
ShadowKey,
|
|
18
|
+
LayoutKey,
|
|
19
|
+
} from './styles';
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { StyleSheet, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
import { useThemeSafe } from '../theme';
|
|
3
|
+
import { ThemeColors } from '../theme/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Spacing scale for consistent layout.
|
|
7
|
+
*/
|
|
8
|
+
export const spacing = {
|
|
9
|
+
xs: 4,
|
|
10
|
+
sm: 8,
|
|
11
|
+
md: 16,
|
|
12
|
+
lg: 24,
|
|
13
|
+
xl: 32,
|
|
14
|
+
xxl: 48,
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
export type SpacingKey = keyof typeof spacing;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Border radius scale.
|
|
21
|
+
*/
|
|
22
|
+
export const borderRadius = {
|
|
23
|
+
sm: 4,
|
|
24
|
+
md: 8,
|
|
25
|
+
lg: 12,
|
|
26
|
+
xl: 16,
|
|
27
|
+
full: 9999,
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
30
|
+
export type BorderRadiusKey = keyof typeof borderRadius;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Typography presets using system fonts.
|
|
34
|
+
*/
|
|
35
|
+
export const typography = {
|
|
36
|
+
// Headings
|
|
37
|
+
heading: {
|
|
38
|
+
fontSize: 32,
|
|
39
|
+
lineHeight: 40,
|
|
40
|
+
fontWeight: '800' as const,
|
|
41
|
+
} as TextStyle,
|
|
42
|
+
|
|
43
|
+
subheading: {
|
|
44
|
+
fontSize: 24,
|
|
45
|
+
lineHeight: 32,
|
|
46
|
+
fontWeight: '700' as const,
|
|
47
|
+
} as TextStyle,
|
|
48
|
+
|
|
49
|
+
title: {
|
|
50
|
+
fontSize: 20,
|
|
51
|
+
lineHeight: 28,
|
|
52
|
+
fontWeight: '600' as const,
|
|
53
|
+
} as TextStyle,
|
|
54
|
+
|
|
55
|
+
// Body text
|
|
56
|
+
body: {
|
|
57
|
+
fontSize: 16,
|
|
58
|
+
lineHeight: 24,
|
|
59
|
+
fontWeight: '400' as const,
|
|
60
|
+
} as TextStyle,
|
|
61
|
+
|
|
62
|
+
bodyMedium: {
|
|
63
|
+
fontSize: 16,
|
|
64
|
+
lineHeight: 24,
|
|
65
|
+
fontWeight: '500' as const,
|
|
66
|
+
} as TextStyle,
|
|
67
|
+
|
|
68
|
+
bodySemibold: {
|
|
69
|
+
fontSize: 16,
|
|
70
|
+
lineHeight: 24,
|
|
71
|
+
fontWeight: '600' as const,
|
|
72
|
+
} as TextStyle,
|
|
73
|
+
|
|
74
|
+
// Small text
|
|
75
|
+
caption: {
|
|
76
|
+
fontSize: 14,
|
|
77
|
+
lineHeight: 20,
|
|
78
|
+
fontWeight: '400' as const,
|
|
79
|
+
} as TextStyle,
|
|
80
|
+
|
|
81
|
+
label: {
|
|
82
|
+
fontSize: 12,
|
|
83
|
+
lineHeight: 16,
|
|
84
|
+
fontWeight: '500' as const,
|
|
85
|
+
} as TextStyle,
|
|
86
|
+
} as const;
|
|
87
|
+
|
|
88
|
+
export type TypographyVariant = keyof typeof typography;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Common shadow styles.
|
|
92
|
+
*/
|
|
93
|
+
export const shadows = {
|
|
94
|
+
sm: {
|
|
95
|
+
shadowColor: '#000',
|
|
96
|
+
shadowOffset: { width: 0, height: 1 },
|
|
97
|
+
shadowOpacity: 0.05,
|
|
98
|
+
shadowRadius: 2,
|
|
99
|
+
elevation: 1,
|
|
100
|
+
} as ViewStyle,
|
|
101
|
+
|
|
102
|
+
md: {
|
|
103
|
+
shadowColor: '#000',
|
|
104
|
+
shadowOffset: { width: 0, height: 2 },
|
|
105
|
+
shadowOpacity: 0.1,
|
|
106
|
+
shadowRadius: 4,
|
|
107
|
+
elevation: 2,
|
|
108
|
+
} as ViewStyle,
|
|
109
|
+
|
|
110
|
+
lg: {
|
|
111
|
+
shadowColor: '#000',
|
|
112
|
+
shadowOffset: { width: 0, height: 4 },
|
|
113
|
+
shadowOpacity: 0.15,
|
|
114
|
+
shadowRadius: 8,
|
|
115
|
+
elevation: 4,
|
|
116
|
+
} as ViewStyle,
|
|
117
|
+
} as const;
|
|
118
|
+
|
|
119
|
+
export type ShadowKey = keyof typeof shadows;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Common flex layouts.
|
|
123
|
+
*/
|
|
124
|
+
export const layouts = {
|
|
125
|
+
row: {
|
|
126
|
+
flexDirection: 'row',
|
|
127
|
+
} as ViewStyle,
|
|
128
|
+
|
|
129
|
+
rowCenter: {
|
|
130
|
+
flexDirection: 'row',
|
|
131
|
+
alignItems: 'center',
|
|
132
|
+
} as ViewStyle,
|
|
133
|
+
|
|
134
|
+
rowBetween: {
|
|
135
|
+
flexDirection: 'row',
|
|
136
|
+
alignItems: 'center',
|
|
137
|
+
justifyContent: 'space-between',
|
|
138
|
+
} as ViewStyle,
|
|
139
|
+
|
|
140
|
+
center: {
|
|
141
|
+
alignItems: 'center',
|
|
142
|
+
justifyContent: 'center',
|
|
143
|
+
} as ViewStyle,
|
|
144
|
+
|
|
145
|
+
flex1: {
|
|
146
|
+
flex: 1,
|
|
147
|
+
} as ViewStyle,
|
|
148
|
+
} as const;
|
|
149
|
+
|
|
150
|
+
export type LayoutKey = keyof typeof layouts;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Type for style factory function.
|
|
154
|
+
*/
|
|
155
|
+
type StyleFactory<T> = (colors: ThemeColors) => T;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Hook to create themed styles using StyleSheet.create.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```tsx
|
|
162
|
+
* const styles = useThemedStyles((colors) => ({
|
|
163
|
+
* container: {
|
|
164
|
+
* backgroundColor: colors.background,
|
|
165
|
+
* padding: spacing.md,
|
|
166
|
+
* },
|
|
167
|
+
* title: {
|
|
168
|
+
* ...typography.heading,
|
|
169
|
+
* color: colors.foreground,
|
|
170
|
+
* },
|
|
171
|
+
* }));
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
export function useThemedStyles<T extends StyleSheet.NamedStyles<T>>(factory: StyleFactory<T>): T {
|
|
175
|
+
const { colors } = useThemeSafe();
|
|
176
|
+
return StyleSheet.create(factory(colors));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Create a themed style object without StyleSheet.create.
|
|
181
|
+
* Useful for dynamic styles or when you need to merge with other styles.
|
|
182
|
+
*/
|
|
183
|
+
export function createThemedStyle<T extends ViewStyle | TextStyle>(
|
|
184
|
+
factory: StyleFactory<T>,
|
|
185
|
+
colors: ThemeColors
|
|
186
|
+
): T {
|
|
187
|
+
return factory(colors);
|
|
188
|
+
}
|
package/tsconfig.json
ADDED