glideui-core 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/LICENSE +21 -0
- package/README.md +70 -0
- package/package.json +48 -0
- package/src/components/Avatar.tsx +139 -0
- package/src/components/Badge.tsx +78 -0
- package/src/components/Button.tsx +147 -0
- package/src/components/Card.tsx +64 -0
- package/src/components/Input.tsx +112 -0
- package/src/components/Skeleton.tsx +92 -0
- package/src/index.ts +24 -0
- package/src/theme/index.ts +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nitesh Nagpal
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# GlideUI ✦
|
|
2
|
+
|
|
3
|
+
> Animated React Native components for Expo. Copy-paste or install. Dark mode first.
|
|
4
|
+
|
|
5
|
+
**[glideui.dev](https://glideui.dev)** · [Components](https://glideui.dev/components) · MIT License
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @glide-ui/core
|
|
13
|
+
# or
|
|
14
|
+
bun add @glide-ui/core
|
|
15
|
+
# or
|
|
16
|
+
yarn add @glide-ui/core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { Button, Badge, Card, Input, Avatar, Skeleton } from '@glide-ui/core';
|
|
23
|
+
|
|
24
|
+
export default function App() {
|
|
25
|
+
return (
|
|
26
|
+
<Card>
|
|
27
|
+
<Avatar name="Nitesh Nagpal" status="online" />
|
|
28
|
+
<Input label="Email" placeholder="your@email.com" />
|
|
29
|
+
<Button onPress={() => console.log('pressed!')}>
|
|
30
|
+
Get started
|
|
31
|
+
</Button>
|
|
32
|
+
<Badge variant="success" dot>Active</Badge>
|
|
33
|
+
</Card>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Components
|
|
39
|
+
|
|
40
|
+
### Free (19 components)
|
|
41
|
+
- **Core:** Button, Badge, Avatar, Card, Separator
|
|
42
|
+
- **Form:** Input, Textarea, Switch, Checkbox, Radio, Select
|
|
43
|
+
- **Feedback:** Toast, Skeleton, Progress, Modal, BottomSheet
|
|
44
|
+
- **Navigation:** TabBar, Tabs, Accordion
|
|
45
|
+
|
|
46
|
+
### Pro (5 components)
|
|
47
|
+
- OTP Input, Date Picker, Swipeable Card, Data Table, Charts
|
|
48
|
+
|
|
49
|
+
## Copy-paste model
|
|
50
|
+
|
|
51
|
+
Don't want the package? Copy components directly:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx glide-ui add button
|
|
55
|
+
npx glide-ui add input
|
|
56
|
+
npx glide-ui add all
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Files are copied to `components/ui/` in your project. You own the code.
|
|
60
|
+
|
|
61
|
+
## Requirements
|
|
62
|
+
|
|
63
|
+
- React Native ≥ 0.73
|
|
64
|
+
- Expo ≥ 50
|
|
65
|
+
- React ≥ 18
|
|
66
|
+
- TypeScript recommended
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
MIT © Nitesh Nagpal
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "glideui-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Animated React Native components for Expo. Copy-paste or install. Dark mode first.",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"types": "src/index.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"src",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/indiepilotai/glide-ui"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://glideui.dev",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/indiepilotai/glide-ui/issues"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"react-native",
|
|
22
|
+
"expo",
|
|
23
|
+
"components",
|
|
24
|
+
"ui",
|
|
25
|
+
"animated",
|
|
26
|
+
"dark-mode",
|
|
27
|
+
"typescript",
|
|
28
|
+
"glideui",
|
|
29
|
+
"mobile",
|
|
30
|
+
"component-library"
|
|
31
|
+
],
|
|
32
|
+
"author": "Nitesh Nagpal <niteshnagpal@outlook.com>",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public",
|
|
36
|
+
"registry": "https://registry.npmjs.org/"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"react": ">=18.0.0",
|
|
40
|
+
"react-native": ">=0.73.0",
|
|
41
|
+
"expo": ">=50.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"typescript": "^5.0.0",
|
|
45
|
+
"@types/react": "^18.0.0",
|
|
46
|
+
"@types/react-native": "^0.73.0"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Text, Image, StyleSheet, ViewStyle } from 'react-native';
|
|
3
|
+
import { colors, typography } from '../theme';
|
|
4
|
+
|
|
5
|
+
export type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
6
|
+
|
|
7
|
+
export interface AvatarProps {
|
|
8
|
+
src?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
size?: AvatarSize;
|
|
11
|
+
status?: 'online' | 'offline' | 'busy' | 'away';
|
|
12
|
+
style?: ViewStyle;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const sizes = {
|
|
16
|
+
xs: 24,
|
|
17
|
+
sm: 32,
|
|
18
|
+
md: 40,
|
|
19
|
+
lg: 48,
|
|
20
|
+
xl: 64,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const statusColors = {
|
|
24
|
+
online: colors.success,
|
|
25
|
+
offline: colors.textMuted,
|
|
26
|
+
busy: colors.error,
|
|
27
|
+
away: colors.warning,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function getInitials(name: string) {
|
|
31
|
+
return name
|
|
32
|
+
.split(' ')
|
|
33
|
+
.map(n => n[0])
|
|
34
|
+
.slice(0, 2)
|
|
35
|
+
.join('')
|
|
36
|
+
.toUpperCase();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function stringToColor(str: string) {
|
|
40
|
+
const palette = [colors.primary, colors.success, '#f97316', '#ec4899', '#06b6d4'];
|
|
41
|
+
let hash = 0;
|
|
42
|
+
for (let i = 0; i < str.length; i++) {
|
|
43
|
+
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
|
44
|
+
}
|
|
45
|
+
return palette[Math.abs(hash) % palette.length];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function Avatar({ src, name = '', size = 'md', status, style }: AvatarProps) {
|
|
49
|
+
const dim = sizes[size];
|
|
50
|
+
const bg = stringToColor(name);
|
|
51
|
+
const statusDim = dim * 0.28;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<View style={[{ width: dim, height: dim }, style]}>
|
|
55
|
+
{src ? (
|
|
56
|
+
<Image
|
|
57
|
+
source={{ uri: src }}
|
|
58
|
+
style={[styles.image, { width: dim, height: dim, borderRadius: dim / 2 }]}
|
|
59
|
+
/>
|
|
60
|
+
) : (
|
|
61
|
+
<View style={[styles.fallback, { width: dim, height: dim, borderRadius: dim / 2, backgroundColor: bg }]}>
|
|
62
|
+
<Text style={[styles.initials, { fontSize: dim * 0.35, color: '#fff' }]}>
|
|
63
|
+
{getInitials(name)}
|
|
64
|
+
</Text>
|
|
65
|
+
</View>
|
|
66
|
+
)}
|
|
67
|
+
{status && (
|
|
68
|
+
<View style={[
|
|
69
|
+
styles.status,
|
|
70
|
+
{
|
|
71
|
+
width: statusDim,
|
|
72
|
+
height: statusDim,
|
|
73
|
+
borderRadius: statusDim / 2,
|
|
74
|
+
backgroundColor: statusColors[status],
|
|
75
|
+
bottom: 0,
|
|
76
|
+
right: 0,
|
|
77
|
+
},
|
|
78
|
+
]} />
|
|
79
|
+
)}
|
|
80
|
+
</View>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Avatar group
|
|
85
|
+
export function AvatarGroup({ avatars, max = 3 }: { avatars: AvatarProps[]; max?: number }) {
|
|
86
|
+
const visible = avatars.slice(0, max);
|
|
87
|
+
const remaining = avatars.length - max;
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<View style={styles.group}>
|
|
91
|
+
{visible.map((a, i) => (
|
|
92
|
+
<View key={i} style={{ marginLeft: i === 0 ? 0 : -10, zIndex: visible.length - i }}>
|
|
93
|
+
<Avatar {...a} size="sm" style={styles.groupItem} />
|
|
94
|
+
</View>
|
|
95
|
+
))}
|
|
96
|
+
{remaining > 0 && (
|
|
97
|
+
<View style={[styles.fallback, styles.groupItem, styles.remainder, { marginLeft: -10 }]}>
|
|
98
|
+
<Text style={styles.remainderText}>+{remaining}</Text>
|
|
99
|
+
</View>
|
|
100
|
+
)}
|
|
101
|
+
</View>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const styles = StyleSheet.create({
|
|
106
|
+
image: {},
|
|
107
|
+
fallback: {
|
|
108
|
+
alignItems: 'center',
|
|
109
|
+
justifyContent: 'center',
|
|
110
|
+
},
|
|
111
|
+
initials: {
|
|
112
|
+
fontWeight: '700',
|
|
113
|
+
},
|
|
114
|
+
status: {
|
|
115
|
+
position: 'absolute',
|
|
116
|
+
borderWidth: 2,
|
|
117
|
+
borderColor: colors.bg,
|
|
118
|
+
},
|
|
119
|
+
group: {
|
|
120
|
+
flexDirection: 'row',
|
|
121
|
+
alignItems: 'center',
|
|
122
|
+
},
|
|
123
|
+
groupItem: {
|
|
124
|
+
borderWidth: 2,
|
|
125
|
+
borderColor: colors.bg,
|
|
126
|
+
},
|
|
127
|
+
remainder: {
|
|
128
|
+
width: 32,
|
|
129
|
+
height: 32,
|
|
130
|
+
borderRadius: 16,
|
|
131
|
+
backgroundColor: colors.surface,
|
|
132
|
+
borderColor: colors.border,
|
|
133
|
+
},
|
|
134
|
+
remainderText: {
|
|
135
|
+
...typography.xs,
|
|
136
|
+
color: colors.textSecondary,
|
|
137
|
+
fontWeight: '600',
|
|
138
|
+
},
|
|
139
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Text, StyleSheet, ViewStyle } from 'react-native';
|
|
3
|
+
import { colors, radius, typography } from '../theme';
|
|
4
|
+
|
|
5
|
+
export type BadgeVariant = 'default' | 'success' | 'warning' | 'error' | 'info';
|
|
6
|
+
|
|
7
|
+
export interface BadgeProps {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
variant?: BadgeVariant;
|
|
10
|
+
dot?: boolean;
|
|
11
|
+
style?: ViewStyle;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const variantStyles = {
|
|
15
|
+
default: {
|
|
16
|
+
bg: colors.primaryLight,
|
|
17
|
+
border: colors.primaryBorder,
|
|
18
|
+
text: colors.primary,
|
|
19
|
+
dot: colors.primary,
|
|
20
|
+
},
|
|
21
|
+
success: {
|
|
22
|
+
bg: colors.successLight,
|
|
23
|
+
border: colors.success + '40',
|
|
24
|
+
text: colors.success,
|
|
25
|
+
dot: colors.success,
|
|
26
|
+
},
|
|
27
|
+
warning: {
|
|
28
|
+
bg: colors.warningLight,
|
|
29
|
+
border: colors.warning + '40',
|
|
30
|
+
text: colors.warning,
|
|
31
|
+
dot: colors.warning,
|
|
32
|
+
},
|
|
33
|
+
error: {
|
|
34
|
+
bg: colors.errorLight,
|
|
35
|
+
border: colors.error + '40',
|
|
36
|
+
text: colors.error,
|
|
37
|
+
dot: colors.error,
|
|
38
|
+
},
|
|
39
|
+
info: {
|
|
40
|
+
bg: colors.infoLight,
|
|
41
|
+
border: colors.info + '40',
|
|
42
|
+
text: colors.info,
|
|
43
|
+
dot: colors.info,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export function Badge({ children, variant = 'default', dot = false, style }: BadgeProps) {
|
|
48
|
+
const v = variantStyles[variant];
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<View style={[styles.base, { backgroundColor: v.bg, borderColor: v.border }, style]}>
|
|
52
|
+
{dot && <View style={[styles.dot, { backgroundColor: v.dot }]} />}
|
|
53
|
+
<Text style={[styles.text, { color: v.text }]}>{children}</Text>
|
|
54
|
+
</View>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const styles = StyleSheet.create({
|
|
59
|
+
base: {
|
|
60
|
+
flexDirection: 'row',
|
|
61
|
+
alignItems: 'center',
|
|
62
|
+
alignSelf: 'flex-start',
|
|
63
|
+
paddingHorizontal: 10,
|
|
64
|
+
paddingVertical: 3,
|
|
65
|
+
borderRadius: radius.full,
|
|
66
|
+
borderWidth: 1,
|
|
67
|
+
gap: 5,
|
|
68
|
+
},
|
|
69
|
+
dot: {
|
|
70
|
+
width: 6,
|
|
71
|
+
height: 6,
|
|
72
|
+
borderRadius: 3,
|
|
73
|
+
},
|
|
74
|
+
text: {
|
|
75
|
+
...typography.xs,
|
|
76
|
+
fontWeight: '600',
|
|
77
|
+
},
|
|
78
|
+
});
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Pressable,
|
|
4
|
+
Text,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
ActivityIndicator,
|
|
7
|
+
ViewStyle,
|
|
8
|
+
TextStyle,
|
|
9
|
+
Platform,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import { colors, spacing, radius, typography } from '../theme';
|
|
12
|
+
|
|
13
|
+
export type ButtonVariant = 'solid' | 'outline' | 'ghost' | 'destructive';
|
|
14
|
+
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
15
|
+
|
|
16
|
+
export interface ButtonProps {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
variant?: ButtonVariant;
|
|
19
|
+
size?: ButtonSize;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
loading?: boolean;
|
|
22
|
+
fullWidth?: boolean;
|
|
23
|
+
onPress?: () => void;
|
|
24
|
+
style?: ViewStyle;
|
|
25
|
+
textStyle?: TextStyle;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function Button({
|
|
29
|
+
children,
|
|
30
|
+
variant = 'solid',
|
|
31
|
+
size = 'md',
|
|
32
|
+
disabled = false,
|
|
33
|
+
loading = false,
|
|
34
|
+
fullWidth = false,
|
|
35
|
+
onPress,
|
|
36
|
+
style,
|
|
37
|
+
textStyle,
|
|
38
|
+
}: ButtonProps) {
|
|
39
|
+
const isDisabled = disabled || loading;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Pressable
|
|
43
|
+
onPress={onPress}
|
|
44
|
+
disabled={isDisabled}
|
|
45
|
+
style={({ pressed }) => [
|
|
46
|
+
styles.base,
|
|
47
|
+
styles[variant],
|
|
48
|
+
styles[`size_${size}`],
|
|
49
|
+
fullWidth && styles.fullWidth,
|
|
50
|
+
isDisabled && styles.disabled,
|
|
51
|
+
pressed && !isDisabled && styles.pressed,
|
|
52
|
+
style,
|
|
53
|
+
]}
|
|
54
|
+
>
|
|
55
|
+
{loading ? (
|
|
56
|
+
<ActivityIndicator
|
|
57
|
+
size="small"
|
|
58
|
+
color={variant === 'solid' ? '#000' : colors.primary}
|
|
59
|
+
/>
|
|
60
|
+
) : (
|
|
61
|
+
<Text style={[styles.text, styles[`text_${variant}`], styles[`textSize_${size}`], textStyle]}>
|
|
62
|
+
{children}
|
|
63
|
+
</Text>
|
|
64
|
+
)}
|
|
65
|
+
</Pressable>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const styles = StyleSheet.create({
|
|
70
|
+
base: {
|
|
71
|
+
flexDirection: 'row',
|
|
72
|
+
alignItems: 'center',
|
|
73
|
+
justifyContent: 'center',
|
|
74
|
+
borderRadius: radius.xl,
|
|
75
|
+
borderWidth: 1,
|
|
76
|
+
borderColor: 'transparent',
|
|
77
|
+
},
|
|
78
|
+
// Variants
|
|
79
|
+
solid: {
|
|
80
|
+
backgroundColor: colors.primary,
|
|
81
|
+
},
|
|
82
|
+
outline: {
|
|
83
|
+
backgroundColor: 'transparent',
|
|
84
|
+
borderColor: colors.primary,
|
|
85
|
+
},
|
|
86
|
+
ghost: {
|
|
87
|
+
backgroundColor: colors.primaryLight,
|
|
88
|
+
borderColor: 'transparent',
|
|
89
|
+
},
|
|
90
|
+
destructive: {
|
|
91
|
+
backgroundColor: colors.errorLight,
|
|
92
|
+
borderColor: colors.error + '40',
|
|
93
|
+
},
|
|
94
|
+
// Sizes
|
|
95
|
+
size_sm: {
|
|
96
|
+
paddingHorizontal: spacing.md,
|
|
97
|
+
paddingVertical: spacing.xs + 2,
|
|
98
|
+
gap: spacing.xs,
|
|
99
|
+
},
|
|
100
|
+
size_md: {
|
|
101
|
+
paddingHorizontal: spacing.lg,
|
|
102
|
+
paddingVertical: spacing.sm + 2,
|
|
103
|
+
gap: spacing.xs,
|
|
104
|
+
},
|
|
105
|
+
size_lg: {
|
|
106
|
+
paddingHorizontal: spacing.xl,
|
|
107
|
+
paddingVertical: spacing.md,
|
|
108
|
+
gap: spacing.sm,
|
|
109
|
+
},
|
|
110
|
+
// States
|
|
111
|
+
disabled: {
|
|
112
|
+
opacity: 0.4,
|
|
113
|
+
},
|
|
114
|
+
pressed: {
|
|
115
|
+
opacity: 0.85,
|
|
116
|
+
transform: [{ scale: 0.98 }],
|
|
117
|
+
},
|
|
118
|
+
fullWidth: {
|
|
119
|
+
width: '100%',
|
|
120
|
+
},
|
|
121
|
+
// Text
|
|
122
|
+
text: {
|
|
123
|
+
fontWeight: '600',
|
|
124
|
+
},
|
|
125
|
+
text_solid: {
|
|
126
|
+
color: '#000000',
|
|
127
|
+
},
|
|
128
|
+
text_outline: {
|
|
129
|
+
color: colors.primary,
|
|
130
|
+
},
|
|
131
|
+
text_ghost: {
|
|
132
|
+
color: colors.primary,
|
|
133
|
+
},
|
|
134
|
+
text_destructive: {
|
|
135
|
+
color: colors.error,
|
|
136
|
+
},
|
|
137
|
+
// Text sizes
|
|
138
|
+
textSize_sm: {
|
|
139
|
+
...typography.sm,
|
|
140
|
+
},
|
|
141
|
+
textSize_md: {
|
|
142
|
+
...typography.base,
|
|
143
|
+
},
|
|
144
|
+
textSize_lg: {
|
|
145
|
+
...typography.lg,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Pressable, StyleSheet, ViewStyle } from 'react-native';
|
|
3
|
+
import { colors, spacing, radius } from '../theme';
|
|
4
|
+
|
|
5
|
+
export type CardVariant = 'default' | 'bordered' | 'elevated';
|
|
6
|
+
|
|
7
|
+
export interface CardProps {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
variant?: CardVariant;
|
|
10
|
+
onPress?: () => void;
|
|
11
|
+
style?: ViewStyle;
|
|
12
|
+
padding?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function Card({
|
|
16
|
+
children,
|
|
17
|
+
variant = 'default',
|
|
18
|
+
onPress,
|
|
19
|
+
style,
|
|
20
|
+
padding = spacing.lg,
|
|
21
|
+
}: CardProps) {
|
|
22
|
+
const content = (
|
|
23
|
+
<View style={[styles.base, styles[variant], { padding }, style]}>
|
|
24
|
+
{children}
|
|
25
|
+
</View>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
if (onPress) {
|
|
29
|
+
return (
|
|
30
|
+
<Pressable
|
|
31
|
+
onPress={onPress}
|
|
32
|
+
style={({ pressed }) => pressed && { opacity: 0.85 }}
|
|
33
|
+
>
|
|
34
|
+
{content}
|
|
35
|
+
</Pressable>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return content;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const styles = StyleSheet.create({
|
|
43
|
+
base: {
|
|
44
|
+
borderRadius: radius.xl,
|
|
45
|
+
borderWidth: 1,
|
|
46
|
+
},
|
|
47
|
+
default: {
|
|
48
|
+
backgroundColor: 'rgba(255,255,255,0.03)',
|
|
49
|
+
borderColor: colors.border,
|
|
50
|
+
},
|
|
51
|
+
bordered: {
|
|
52
|
+
backgroundColor: 'transparent',
|
|
53
|
+
borderColor: colors.borderHover,
|
|
54
|
+
},
|
|
55
|
+
elevated: {
|
|
56
|
+
backgroundColor: colors.surface,
|
|
57
|
+
borderColor: colors.border,
|
|
58
|
+
shadowColor: '#000',
|
|
59
|
+
shadowOffset: { width: 0, height: 4 },
|
|
60
|
+
shadowOpacity: 0.3,
|
|
61
|
+
shadowRadius: 12,
|
|
62
|
+
elevation: 8,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
TextInput,
|
|
4
|
+
View,
|
|
5
|
+
Text,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
TextInputProps,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
Pressable,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import { colors, spacing, radius, typography } from '../theme';
|
|
12
|
+
|
|
13
|
+
export interface InputProps extends TextInputProps {
|
|
14
|
+
label?: string;
|
|
15
|
+
error?: string;
|
|
16
|
+
hint?: string;
|
|
17
|
+
leftIcon?: React.ReactNode;
|
|
18
|
+
rightIcon?: React.ReactNode;
|
|
19
|
+
containerStyle?: ViewStyle;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function Input({
|
|
23
|
+
label,
|
|
24
|
+
error,
|
|
25
|
+
hint,
|
|
26
|
+
leftIcon,
|
|
27
|
+
rightIcon,
|
|
28
|
+
containerStyle,
|
|
29
|
+
style,
|
|
30
|
+
...props
|
|
31
|
+
}: InputProps) {
|
|
32
|
+
const [focused, setFocused] = useState(false);
|
|
33
|
+
|
|
34
|
+
const borderColor = error
|
|
35
|
+
? colors.error
|
|
36
|
+
: focused
|
|
37
|
+
? colors.primary
|
|
38
|
+
: colors.border;
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<View style={[styles.container, containerStyle]}>
|
|
42
|
+
{label && <Text style={styles.label}>{label}</Text>}
|
|
43
|
+
|
|
44
|
+
<View style={[styles.inputWrapper, { borderColor }]}>
|
|
45
|
+
{leftIcon && <View style={styles.icon}>{leftIcon}</View>}
|
|
46
|
+
|
|
47
|
+
<TextInput
|
|
48
|
+
style={[
|
|
49
|
+
styles.input,
|
|
50
|
+
leftIcon ? styles.inputWithLeft : null,
|
|
51
|
+
rightIcon ? styles.inputWithRight : null,
|
|
52
|
+
style,
|
|
53
|
+
]}
|
|
54
|
+
placeholderTextColor={colors.textDisabled}
|
|
55
|
+
onFocus={() => setFocused(true)}
|
|
56
|
+
onBlur={() => setFocused(false)}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
|
|
60
|
+
{rightIcon && <View style={styles.icon}>{rightIcon}</View>}
|
|
61
|
+
</View>
|
|
62
|
+
|
|
63
|
+
{error ? (
|
|
64
|
+
<Text style={styles.error}>{error}</Text>
|
|
65
|
+
) : hint ? (
|
|
66
|
+
<Text style={styles.hint}>{hint}</Text>
|
|
67
|
+
) : null}
|
|
68
|
+
</View>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const styles = StyleSheet.create({
|
|
73
|
+
container: {
|
|
74
|
+
gap: spacing.xs,
|
|
75
|
+
},
|
|
76
|
+
label: {
|
|
77
|
+
...typography.sm,
|
|
78
|
+
color: colors.textSecondary,
|
|
79
|
+
fontWeight: '500',
|
|
80
|
+
},
|
|
81
|
+
inputWrapper: {
|
|
82
|
+
flexDirection: 'row',
|
|
83
|
+
alignItems: 'center',
|
|
84
|
+
backgroundColor: 'rgba(255,255,255,0.04)',
|
|
85
|
+
borderRadius: radius.lg,
|
|
86
|
+
borderWidth: 1,
|
|
87
|
+
},
|
|
88
|
+
input: {
|
|
89
|
+
flex: 1,
|
|
90
|
+
paddingHorizontal: spacing.md,
|
|
91
|
+
paddingVertical: spacing.sm + 2,
|
|
92
|
+
...typography.base,
|
|
93
|
+
color: colors.textPrimary,
|
|
94
|
+
},
|
|
95
|
+
inputWithLeft: {
|
|
96
|
+
paddingLeft: spacing.xs,
|
|
97
|
+
},
|
|
98
|
+
inputWithRight: {
|
|
99
|
+
paddingRight: spacing.xs,
|
|
100
|
+
},
|
|
101
|
+
icon: {
|
|
102
|
+
paddingHorizontal: spacing.md,
|
|
103
|
+
},
|
|
104
|
+
error: {
|
|
105
|
+
...typography.xs,
|
|
106
|
+
color: colors.error,
|
|
107
|
+
},
|
|
108
|
+
hint: {
|
|
109
|
+
...typography.xs,
|
|
110
|
+
color: colors.textMuted,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { Animated, StyleSheet, View, ViewStyle } from 'react-native';
|
|
3
|
+
import { radius } from '../theme';
|
|
4
|
+
|
|
5
|
+
export interface SkeletonProps {
|
|
6
|
+
width?: number | string;
|
|
7
|
+
height?: number;
|
|
8
|
+
borderRadius?: number;
|
|
9
|
+
style?: ViewStyle;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function Skeleton({
|
|
13
|
+
width = '100%',
|
|
14
|
+
height = 16,
|
|
15
|
+
borderRadius = radius.md,
|
|
16
|
+
style,
|
|
17
|
+
}: SkeletonProps) {
|
|
18
|
+
const shimmer = useRef(new Animated.Value(0)).current;
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
Animated.loop(
|
|
22
|
+
Animated.sequence([
|
|
23
|
+
Animated.timing(shimmer, {
|
|
24
|
+
toValue: 1,
|
|
25
|
+
duration: 1000,
|
|
26
|
+
useNativeDriver: true,
|
|
27
|
+
}),
|
|
28
|
+
Animated.timing(shimmer, {
|
|
29
|
+
toValue: 0,
|
|
30
|
+
duration: 1000,
|
|
31
|
+
useNativeDriver: true,
|
|
32
|
+
}),
|
|
33
|
+
])
|
|
34
|
+
).start();
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
const opacity = shimmer.interpolate({
|
|
38
|
+
inputRange: [0, 1],
|
|
39
|
+
outputRange: [0.4, 0.8],
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Animated.View
|
|
44
|
+
style={[
|
|
45
|
+
styles.base,
|
|
46
|
+
{
|
|
47
|
+
width: width as any,
|
|
48
|
+
height,
|
|
49
|
+
borderRadius,
|
|
50
|
+
opacity,
|
|
51
|
+
},
|
|
52
|
+
style,
|
|
53
|
+
]}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Convenience components
|
|
59
|
+
export function SkeletonText({ lines = 3, style }: { lines?: number; style?: ViewStyle }) {
|
|
60
|
+
const widths = ['100%', '85%', '70%'];
|
|
61
|
+
return (
|
|
62
|
+
<View style={[{ gap: 8 }, style]}>
|
|
63
|
+
{Array.from({ length: lines }).map((_, i) => (
|
|
64
|
+
<Skeleton key={i} width={widths[i % widths.length] as any} height={12} />
|
|
65
|
+
))}
|
|
66
|
+
</View>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function SkeletonCard({ style }: { style?: ViewStyle }) {
|
|
71
|
+
return (
|
|
72
|
+
<View style={[styles.card, style]}>
|
|
73
|
+
<Skeleton width={48} height={48} borderRadius={24} />
|
|
74
|
+
<View style={{ flex: 1, gap: 8 }}>
|
|
75
|
+
<Skeleton width="60%" height={14} />
|
|
76
|
+
<Skeleton width="40%" height={11} />
|
|
77
|
+
</View>
|
|
78
|
+
</View>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const styles = StyleSheet.create({
|
|
83
|
+
base: {
|
|
84
|
+
backgroundColor: 'rgba(255,255,255,0.08)',
|
|
85
|
+
},
|
|
86
|
+
card: {
|
|
87
|
+
flexDirection: 'row',
|
|
88
|
+
alignItems: 'center',
|
|
89
|
+
gap: 12,
|
|
90
|
+
padding: 16,
|
|
91
|
+
},
|
|
92
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// GlideUI — Animated React Native components for Expo
|
|
2
|
+
// glideui.dev
|
|
3
|
+
|
|
4
|
+
// Theme
|
|
5
|
+
export * from './theme';
|
|
6
|
+
|
|
7
|
+
// Components
|
|
8
|
+
export { Button } from './components/Button';
|
|
9
|
+
export type { ButtonProps, ButtonVariant, ButtonSize } from './components/Button';
|
|
10
|
+
|
|
11
|
+
export { Badge } from './components/Badge';
|
|
12
|
+
export type { BadgeProps, BadgeVariant } from './components/Badge';
|
|
13
|
+
|
|
14
|
+
export { Input } from './components/Input';
|
|
15
|
+
export type { InputProps } from './components/Input';
|
|
16
|
+
|
|
17
|
+
export { Card } from './components/Card';
|
|
18
|
+
export type { CardProps, CardVariant } from './components/Card';
|
|
19
|
+
|
|
20
|
+
export { Skeleton, SkeletonText, SkeletonCard } from './components/Skeleton';
|
|
21
|
+
export type { SkeletonProps } from './components/Skeleton';
|
|
22
|
+
|
|
23
|
+
export { Avatar, AvatarGroup } from './components/Avatar';
|
|
24
|
+
export type { AvatarProps, AvatarSize } from './components/Avatar';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export const colors = {
|
|
2
|
+
// Brand
|
|
3
|
+
primary: '#8b5cf6',
|
|
4
|
+
primaryLight: 'rgba(139, 92, 246, 0.1)',
|
|
5
|
+
primaryBorder: 'rgba(139, 92, 246, 0.3)',
|
|
6
|
+
|
|
7
|
+
// Background
|
|
8
|
+
bg: '#0a0a0f',
|
|
9
|
+
surface: '#141420',
|
|
10
|
+
surfaceHover: '#1a1a2e',
|
|
11
|
+
|
|
12
|
+
// Text
|
|
13
|
+
textPrimary: '#ffffff',
|
|
14
|
+
textSecondary: '#9ca3af',
|
|
15
|
+
textMuted: '#6b7280',
|
|
16
|
+
textDisabled: '#374151',
|
|
17
|
+
|
|
18
|
+
// Border
|
|
19
|
+
border: 'rgba(255, 255, 255, 0.08)',
|
|
20
|
+
borderHover: 'rgba(255, 255, 255, 0.15)',
|
|
21
|
+
|
|
22
|
+
// Semantic
|
|
23
|
+
success: '#10b981',
|
|
24
|
+
successLight: 'rgba(16, 185, 129, 0.1)',
|
|
25
|
+
warning: '#f59e0b',
|
|
26
|
+
warningLight: 'rgba(245, 158, 11, 0.1)',
|
|
27
|
+
error: '#ef4444',
|
|
28
|
+
errorLight: 'rgba(239, 68, 68, 0.1)',
|
|
29
|
+
info: '#3b82f6',
|
|
30
|
+
infoLight: 'rgba(59, 130, 246, 0.1)',
|
|
31
|
+
} as const;
|
|
32
|
+
|
|
33
|
+
export const spacing = {
|
|
34
|
+
xs: 4,
|
|
35
|
+
sm: 8,
|
|
36
|
+
md: 12,
|
|
37
|
+
lg: 16,
|
|
38
|
+
xl: 24,
|
|
39
|
+
xxl: 32,
|
|
40
|
+
} as const;
|
|
41
|
+
|
|
42
|
+
export const radius = {
|
|
43
|
+
sm: 6,
|
|
44
|
+
md: 10,
|
|
45
|
+
lg: 14,
|
|
46
|
+
xl: 18,
|
|
47
|
+
full: 9999,
|
|
48
|
+
} as const;
|
|
49
|
+
|
|
50
|
+
export const typography = {
|
|
51
|
+
xs: { fontSize: 11, lineHeight: 16 },
|
|
52
|
+
sm: { fontSize: 13, lineHeight: 18 },
|
|
53
|
+
base: { fontSize: 15, lineHeight: 22 },
|
|
54
|
+
lg: { fontSize: 17, lineHeight: 24 },
|
|
55
|
+
xl: { fontSize: 20, lineHeight: 28 },
|
|
56
|
+
xxl: { fontSize: 24, lineHeight: 32 },
|
|
57
|
+
} as const;
|
|
58
|
+
|
|
59
|
+
export type GlideTheme = {
|
|
60
|
+
colors: typeof colors;
|
|
61
|
+
spacing: typeof spacing;
|
|
62
|
+
radius: typeof radius;
|
|
63
|
+
typography: typeof typography;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const defaultTheme: GlideTheme = {
|
|
67
|
+
colors,
|
|
68
|
+
spacing,
|
|
69
|
+
radius,
|
|
70
|
+
typography,
|
|
71
|
+
};
|