@umituz/react-native-design-system 1.0.2 → 1.0.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-design-system",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Universal design system for React Native apps - Domain-Driven Design architecture with Material Design 3 components",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -1,37 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* useAppDesignTokens Hook - Design Tokens
|
|
2
|
+
* useAppDesignTokens Hook - Theme-Aware Design Tokens
|
|
3
3
|
*
|
|
4
|
-
* ✅
|
|
5
|
-
* ✅ Returns
|
|
6
|
-
* ✅
|
|
7
|
-
* ✅
|
|
4
|
+
* ✅ Accepts optional themeMode parameter
|
|
5
|
+
* ✅ Returns tokens for specified theme (light/dark)
|
|
6
|
+
* ✅ Apps control theme, package provides tokens
|
|
7
|
+
* ✅ Single source of truth
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* For dynamic theme switching, apps should use @domains/theme ThemeProvider.
|
|
9
|
+
* @param themeMode - Optional theme mode ('light' | 'dark'), defaults to 'light'
|
|
11
10
|
*
|
|
12
|
-
* @example
|
|
11
|
+
* @example Basic usage (light theme)
|
|
13
12
|
* ```typescript
|
|
14
13
|
* import { useAppDesignTokens } from '@umituz/react-native-design-system';
|
|
15
14
|
*
|
|
16
15
|
* const MyComponent = () => {
|
|
17
|
-
* const tokens = useAppDesignTokens();
|
|
16
|
+
* const tokens = useAppDesignTokens(); // Uses light theme by default
|
|
18
17
|
* return (
|
|
19
18
|
* <View style={{
|
|
20
19
|
* backgroundColor: tokens.colors.primary,
|
|
21
|
-
* padding: tokens.spacing.md
|
|
22
|
-
* borderRadius: tokens.borders.radius.md
|
|
20
|
+
* padding: tokens.spacing.md
|
|
23
21
|
* }}>
|
|
24
22
|
* <Text style={tokens.typography.bodyLarge}>Hello!</Text>
|
|
25
23
|
* </View>
|
|
26
24
|
* );
|
|
27
25
|
* };
|
|
28
26
|
* ```
|
|
27
|
+
*
|
|
28
|
+
* @example Theme-aware usage
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { useAppDesignTokens } from '@umituz/react-native-design-system';
|
|
31
|
+
* import { useTheme } from '@domains/theme';
|
|
32
|
+
*
|
|
33
|
+
* const MyComponent = () => {
|
|
34
|
+
* const { themeMode } = useTheme(); // Get theme from app's theme system
|
|
35
|
+
* const tokens = useAppDesignTokens(themeMode); // Pass theme to hook
|
|
36
|
+
*
|
|
37
|
+
* return (
|
|
38
|
+
* <View style={{ backgroundColor: tokens.colors.background }}>
|
|
39
|
+
* <Text style={{ color: tokens.colors.textPrimary }}>
|
|
40
|
+
* This text color changes with theme!
|
|
41
|
+
* </Text>
|
|
42
|
+
* </View>
|
|
43
|
+
* );
|
|
44
|
+
* };
|
|
45
|
+
* ```
|
|
29
46
|
*/
|
|
30
47
|
|
|
31
|
-
import {
|
|
48
|
+
import { useMemo } from 'react';
|
|
49
|
+
import { createDesignTokens, type DesignTokens, type ThemeMode } from '../tokens/core/TokenFactory';
|
|
32
50
|
|
|
33
|
-
export const useAppDesignTokens = () => {
|
|
34
|
-
|
|
35
|
-
// Apps using factory generator will override this with theme-aware version
|
|
36
|
-
return STATIC_DESIGN_TOKENS;
|
|
51
|
+
export const useAppDesignTokens = (themeMode: ThemeMode = 'light'): DesignTokens => {
|
|
52
|
+
return useMemo(() => createDesignTokens(themeMode), [themeMode]);
|
|
37
53
|
};
|
|
@@ -16,7 +16,7 @@ export const ListItem: React.FC<ListItemProps> = ({
|
|
|
16
16
|
const Component: React.ComponentType<any> = onPress ? TouchableOpacity : View;
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
|
-
<Component style={[listItemStyles.container, disabled
|
|
19
|
+
<Component style={[listItemStyles.container, disabled ? listItemStyles.disabled : undefined, style]} onPress={onPress} disabled={disabled} activeOpacity={0.7}>
|
|
20
20
|
{leftIcon && (
|
|
21
21
|
<View style={listItemStyles.iconContainer}>
|
|
22
22
|
<AtomicIcon name={leftIcon} color={disabled ? 'surfaceVariant' : 'primary'} />
|
|
@@ -24,11 +24,11 @@ export const ListItem: React.FC<ListItemProps> = ({
|
|
|
24
24
|
)}
|
|
25
25
|
<View style={listItemStyles.content}>
|
|
26
26
|
<AtomicText type="bodyLarge" color={disabled ? 'surfaceVariant' : 'onSurface'} numberOfLines={1}>{title}</AtomicText>
|
|
27
|
-
{subtitle && <AtomicText type="bodySmall" color=
|
|
27
|
+
{subtitle && <AtomicText type="bodySmall" color="surfaceVariant" numberOfLines={2} style={listItemStyles.subtitle}>{subtitle}</AtomicText>}
|
|
28
28
|
</View>
|
|
29
29
|
{rightIcon && onPress && (
|
|
30
30
|
<View style={listItemStyles.iconContainer}>
|
|
31
|
-
<AtomicIcon name={rightIcon} color=
|
|
31
|
+
<AtomicIcon name={rightIcon} color="surfaceVariant" />
|
|
32
32
|
</View>
|
|
33
33
|
)}
|
|
34
34
|
</Component>
|