@react-native-reusables/cli 0.2.0 → 0.2.1

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.
Files changed (35) hide show
  1. package/__generated/starter-base/README.md +16 -0
  2. package/__generated/starter-base/app/+not-found.tsx +18 -0
  3. package/__generated/starter-base/app/_layout.tsx +69 -0
  4. package/__generated/starter-base/app/index.tsx +95 -0
  5. package/__generated/starter-base/app.json +40 -0
  6. package/__generated/starter-base/assets/images/adaptive-icon.png +0 -0
  7. package/__generated/starter-base/assets/images/favicon.png +0 -0
  8. package/__generated/starter-base/assets/images/icon.png +0 -0
  9. package/__generated/starter-base/assets/images/splash.png +0 -0
  10. package/__generated/starter-base/babel.config.js +6 -0
  11. package/__generated/starter-base/components/ThemeToggle.tsx +38 -0
  12. package/__generated/starter-base/components/ui/avatar.tsx +45 -0
  13. package/__generated/starter-base/components/ui/button.tsx +88 -0
  14. package/__generated/starter-base/components/ui/card.tsx +57 -0
  15. package/__generated/starter-base/components/ui/progress.tsx +61 -0
  16. package/__generated/starter-base/components/ui/text.tsx +24 -0
  17. package/__generated/starter-base/components/ui/tooltip.tsx +39 -0
  18. package/__generated/starter-base/global.css +49 -0
  19. package/__generated/starter-base/index.js +12 -0
  20. package/__generated/starter-base/lib/android-navigation-bar.ts +11 -0
  21. package/__generated/starter-base/lib/constants.ts +18 -0
  22. package/__generated/starter-base/lib/icons/Info.tsx +4 -0
  23. package/__generated/starter-base/lib/icons/MoonStar.tsx +4 -0
  24. package/__generated/starter-base/lib/icons/Sun.tsx +4 -0
  25. package/__generated/starter-base/lib/icons/iconWithClassName.ts +14 -0
  26. package/__generated/starter-base/lib/useColorScheme.tsx +11 -0
  27. package/__generated/starter-base/lib/utils.ts +6 -0
  28. package/__generated/starter-base/metro.config.js +6 -0
  29. package/__generated/starter-base/nativewind-env.d.ts +1 -0
  30. package/__generated/starter-base/package.json +53 -0
  31. package/__generated/starter-base/tailwind.config.js +65 -0
  32. package/__generated/starter-base/tsconfig.json +19 -0
  33. package/dist/index.js +2 -2
  34. package/dist/index.js.map +1 -1
  35. package/package.json +4 -4
@@ -0,0 +1,16 @@
1
+ # Starter base
2
+
3
+ A starting point to help you set up your project quickly and use the common components provided by `react-native-reusables`. The idea is to make it easier for you to get started.
4
+
5
+ ## Features
6
+
7
+ - NativeWind v4
8
+ - Dark and light mode
9
+ - Android Navigation Bar matches mode
10
+ - Persistant mode
11
+ - Common components
12
+ - ThemeToggle, Avatar, Button, Card, Progress, Text, Tooltip
13
+
14
+ <img src="https://github.com/mrzachnugent/react-native-reusables/assets/63797719/42c94108-38a7-498b-9c70-18640420f1bc"
15
+ alt="starter-base-template"
16
+ style="width:270px;" />
@@ -0,0 +1,18 @@
1
+ import { Link, Stack } from 'expo-router';
2
+ import { View } from 'react-native';
3
+ import { Text } from '~/components/ui/text';
4
+
5
+ export default function NotFoundScreen() {
6
+ return (
7
+ <>
8
+ <Stack.Screen options={{ title: 'Oops!' }} />
9
+ <View>
10
+ <Text>This screen doesn't exist.</Text>
11
+
12
+ <Link href='/'>
13
+ <Text>Go to home screen!</Text>
14
+ </Link>
15
+ </View>
16
+ </>
17
+ );
18
+ }
@@ -0,0 +1,69 @@
1
+ import '~/global.css';
2
+
3
+ import { DarkTheme, DefaultTheme, Theme, ThemeProvider } from '@react-navigation/native';
4
+ import { Stack } from 'expo-router';
5
+ import { StatusBar } from 'expo-status-bar';
6
+ import * as React from 'react';
7
+ import { Platform } from 'react-native';
8
+ import { NAV_THEME } from '~/lib/constants';
9
+ import { useColorScheme } from '~/lib/useColorScheme';
10
+ import { PortalHost } from '@rn-primitives/portal';
11
+ import { ThemeToggle } from '~/components/ThemeToggle';
12
+ import { setAndroidNavigationBar } from '~/lib/android-navigation-bar';
13
+
14
+ const LIGHT_THEME: Theme = {
15
+ ...DefaultTheme,
16
+ colors: NAV_THEME.light,
17
+ };
18
+ const DARK_THEME: Theme = {
19
+ ...DarkTheme,
20
+ colors: NAV_THEME.dark,
21
+ };
22
+
23
+ export {
24
+ // Catch any errors thrown by the Layout component.
25
+ ErrorBoundary,
26
+ } from 'expo-router';
27
+
28
+ export default function RootLayout() {
29
+ const hasMounted = React.useRef(false);
30
+ const { colorScheme, isDarkColorScheme } = useColorScheme();
31
+ const [isColorSchemeLoaded, setIsColorSchemeLoaded] = React.useState(false);
32
+
33
+ useIsomorphicLayoutEffect(() => {
34
+ if (hasMounted.current) {
35
+ return;
36
+ }
37
+
38
+ if (Platform.OS === 'web') {
39
+ // Adds the background color to the html element to prevent white background on overscroll.
40
+ document.documentElement.classList.add('bg-background');
41
+ }
42
+ setAndroidNavigationBar(colorScheme);
43
+ setIsColorSchemeLoaded(true);
44
+ hasMounted.current = true;
45
+ }, []);
46
+
47
+ if (!isColorSchemeLoaded) {
48
+ return null;
49
+ }
50
+
51
+ return (
52
+ <ThemeProvider value={isDarkColorScheme ? DARK_THEME : LIGHT_THEME}>
53
+ <StatusBar style={isDarkColorScheme ? 'light' : 'dark'} />
54
+ <Stack>
55
+ <Stack.Screen
56
+ name='index'
57
+ options={{
58
+ title: 'Starter Base',
59
+ headerRight: () => <ThemeToggle />,
60
+ }}
61
+ />
62
+ </Stack>
63
+ <PortalHost />
64
+ </ThemeProvider>
65
+ );
66
+ }
67
+
68
+ const useIsomorphicLayoutEffect =
69
+ Platform.OS === 'web' && typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;
@@ -0,0 +1,95 @@
1
+ import * as React from 'react';
2
+ import { View } from 'react-native';
3
+ import Animated, { FadeInUp, FadeOutDown, LayoutAnimationConfig } from 'react-native-reanimated';
4
+ import { Info } from '~/lib/icons/Info';
5
+ import { Avatar, AvatarFallback, AvatarImage } from '~/components/ui/avatar';
6
+ import { Button } from '~/components/ui/button';
7
+ import {
8
+ Card,
9
+ CardContent,
10
+ CardDescription,
11
+ CardFooter,
12
+ CardHeader,
13
+ CardTitle,
14
+ } from '~/components/ui/card';
15
+ import { Progress } from '~/components/ui/progress';
16
+ import { Text } from '~/components/ui/text';
17
+ import { Tooltip, TooltipContent, TooltipTrigger } from '~/components/ui/tooltip';
18
+
19
+ const GITHUB_AVATAR_URI =
20
+ 'https://i.pinimg.com/originals/ef/a2/8d/efa28d18a04e7fa40ed49eeb0ab660db.jpg';
21
+
22
+ export default function Screen() {
23
+ const [progress, setProgress] = React.useState(78);
24
+
25
+ function updateProgressValue() {
26
+ setProgress(Math.floor(Math.random() * 100));
27
+ }
28
+ return (
29
+ <View className='flex-1 justify-center items-center gap-5 p-6 bg-secondary/30'>
30
+ <Card className='w-full max-w-sm p-6 rounded-2xl'>
31
+ <CardHeader className='items-center'>
32
+ <Avatar alt="Rick Sanchez's Avatar" className='w-24 h-24'>
33
+ <AvatarImage source={{ uri: GITHUB_AVATAR_URI }} />
34
+ <AvatarFallback>
35
+ <Text>RS</Text>
36
+ </AvatarFallback>
37
+ </Avatar>
38
+ <View className='p-3' />
39
+ <CardTitle className='pb-2 text-center'>Rick Sanchez</CardTitle>
40
+ <View className='flex-row'>
41
+ <CardDescription className='text-base font-semibold'>Scientist</CardDescription>
42
+ <Tooltip delayDuration={150}>
43
+ <TooltipTrigger className='px-2 pb-0.5 active:opacity-50'>
44
+ <Info size={14} strokeWidth={2.5} className='w-4 h-4 text-foreground/70' />
45
+ </TooltipTrigger>
46
+ <TooltipContent className='py-2 px-4 shadow'>
47
+ <Text className='native:text-lg'>Freelance</Text>
48
+ </TooltipContent>
49
+ </Tooltip>
50
+ </View>
51
+ </CardHeader>
52
+ <CardContent>
53
+ <View className='flex-row justify-around gap-3'>
54
+ <View className='items-center'>
55
+ <Text className='text-sm text-muted-foreground'>Dimension</Text>
56
+ <Text className='text-xl font-semibold'>C-137</Text>
57
+ </View>
58
+ <View className='items-center'>
59
+ <Text className='text-sm text-muted-foreground'>Age</Text>
60
+ <Text className='text-xl font-semibold'>70</Text>
61
+ </View>
62
+ <View className='items-center'>
63
+ <Text className='text-sm text-muted-foreground'>Species</Text>
64
+ <Text className='text-xl font-semibold'>Human</Text>
65
+ </View>
66
+ </View>
67
+ </CardContent>
68
+ <CardFooter className='flex-col gap-3 pb-0'>
69
+ <View className='flex-row items-center overflow-hidden'>
70
+ <Text className='text-sm text-muted-foreground'>Productivity:</Text>
71
+ <LayoutAnimationConfig skipEntering>
72
+ <Animated.View
73
+ key={progress}
74
+ entering={FadeInUp}
75
+ exiting={FadeOutDown}
76
+ className='w-11 items-center'
77
+ >
78
+ <Text className='text-sm font-bold text-sky-600'>{progress}%</Text>
79
+ </Animated.View>
80
+ </LayoutAnimationConfig>
81
+ </View>
82
+ <Progress value={progress} className='h-2' indicatorClassName='bg-sky-600' />
83
+ <View />
84
+ <Button
85
+ variant='outline'
86
+ className='shadow shadow-foreground/5'
87
+ onPress={updateProgressValue}
88
+ >
89
+ <Text>Update</Text>
90
+ </Button>
91
+ </CardFooter>
92
+ </Card>
93
+ </View>
94
+ );
95
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "expo": {
3
+ "name": "Starter Base",
4
+ "slug": "starter-base",
5
+ "version": "1.0.0",
6
+ "orientation": "portrait",
7
+ "icon": "./assets/images/icon.png",
8
+ "scheme": "myapp",
9
+ "userInterfaceStyle": "automatic",
10
+ "newArchEnabled": true,
11
+ "splash": {
12
+ "image": "./assets/images/splash.png",
13
+ "resizeMode": "contain",
14
+ "backgroundColor": "#ffffff"
15
+ },
16
+ "assetBundlePatterns": [
17
+ "**/*"
18
+ ],
19
+ "ios": {
20
+ "supportsTablet": true
21
+ },
22
+ "android": {
23
+ "adaptiveIcon": {
24
+ "foregroundImage": "./assets/images/adaptive-icon.png",
25
+ "backgroundColor": "#ffffff"
26
+ }
27
+ },
28
+ "web": {
29
+ "bundler": "metro",
30
+ "output": "static",
31
+ "favicon": "./assets/images/favicon.png"
32
+ },
33
+ "plugins": [
34
+ "expo-router"
35
+ ],
36
+ "experiments": {
37
+ "typedRoutes": true
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = function (api) {
2
+ api.cache(true);
3
+ return {
4
+ presets: [['babel-preset-expo', { jsxImportSource: 'nativewind' }], 'nativewind/babel'],
5
+ };
6
+ };
@@ -0,0 +1,38 @@
1
+ import { Pressable, View } from 'react-native';
2
+ import { setAndroidNavigationBar } from '~/lib/android-navigation-bar';
3
+ import { MoonStar } from '~/lib/icons/MoonStar';
4
+ import { Sun } from '~/lib/icons/Sun';
5
+ import { useColorScheme } from '~/lib/useColorScheme';
6
+ import { cn } from '~/lib/utils';
7
+
8
+ export function ThemeToggle() {
9
+ const { isDarkColorScheme, setColorScheme } = useColorScheme();
10
+
11
+ function toggleColorScheme() {
12
+ const newTheme = isDarkColorScheme ? 'light' : 'dark';
13
+ setColorScheme(newTheme);
14
+ setAndroidNavigationBar(newTheme);
15
+ }
16
+
17
+ return (
18
+ <Pressable
19
+ onPress={toggleColorScheme}
20
+ className='web:ring-offset-background web:transition-colors web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2'
21
+ >
22
+ {({ pressed }) => (
23
+ <View
24
+ className={cn(
25
+ 'flex-1 aspect-square pt-0.5 justify-center items-start web:px-5',
26
+ pressed && 'opacity-70'
27
+ )}
28
+ >
29
+ {isDarkColorScheme ? (
30
+ <MoonStar className='text-foreground' size={23} strokeWidth={1.25} />
31
+ ) : (
32
+ <Sun className='text-foreground' size={24} strokeWidth={1.25} />
33
+ )}
34
+ </View>
35
+ )}
36
+ </Pressable>
37
+ );
38
+ }
@@ -0,0 +1,45 @@
1
+ import * as AvatarPrimitive from '@rn-primitives/avatar';
2
+ import * as React from 'react';
3
+ import { cn } from '~/lib/utils';
4
+
5
+ const AvatarPrimitiveRoot = AvatarPrimitive.Root;
6
+ const AvatarPrimitiveImage = AvatarPrimitive.Image;
7
+ const AvatarPrimitiveFallback = AvatarPrimitive.Fallback;
8
+
9
+ const Avatar = React.forwardRef<AvatarPrimitive.RootRef, AvatarPrimitive.RootProps>(
10
+ ({ className, ...props }, ref) => (
11
+ <AvatarPrimitiveRoot
12
+ ref={ref}
13
+ className={cn('relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', className)}
14
+ {...props}
15
+ />
16
+ )
17
+ );
18
+ Avatar.displayName = AvatarPrimitiveRoot.displayName;
19
+
20
+ const AvatarImage = React.forwardRef<AvatarPrimitive.ImageRef, AvatarPrimitive.ImageProps>(
21
+ ({ className, ...props }, ref) => (
22
+ <AvatarPrimitiveImage
23
+ ref={ref}
24
+ className={cn('aspect-square h-full w-full', className)}
25
+ {...props}
26
+ />
27
+ )
28
+ );
29
+ AvatarImage.displayName = AvatarPrimitiveImage.displayName;
30
+
31
+ const AvatarFallback = React.forwardRef<AvatarPrimitive.FallbackRef, AvatarPrimitive.FallbackProps>(
32
+ ({ className, ...props }, ref) => (
33
+ <AvatarPrimitiveFallback
34
+ ref={ref}
35
+ className={cn(
36
+ 'flex h-full w-full items-center justify-center rounded-full bg-muted',
37
+ className
38
+ )}
39
+ {...props}
40
+ />
41
+ )
42
+ );
43
+ AvatarFallback.displayName = AvatarPrimitiveFallback.displayName;
44
+
45
+ export { Avatar, AvatarFallback, AvatarImage };
@@ -0,0 +1,88 @@
1
+ import { cva, type VariantProps } from 'class-variance-authority';
2
+ import * as React from 'react';
3
+ import { Pressable } from 'react-native';
4
+ import { TextClassContext } from '~/components/ui/text';
5
+ import { cn } from '~/lib/utils';
6
+
7
+ const buttonVariants = cva(
8
+ 'group flex items-center justify-center rounded-md web:ring-offset-background web:transition-colors web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2',
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default: 'bg-primary web:hover:opacity-90 active:opacity-90',
13
+ destructive: 'bg-destructive web:hover:opacity-90 active:opacity-90',
14
+ outline:
15
+ 'border border-input bg-background web:hover:bg-accent web:hover:text-accent-foreground active:bg-accent',
16
+ secondary: 'bg-secondary web:hover:opacity-80 active:opacity-80',
17
+ ghost: 'web:hover:bg-accent web:hover:text-accent-foreground active:bg-accent',
18
+ link: 'web:underline-offset-4 web:hover:underline web:focus:underline ',
19
+ },
20
+ size: {
21
+ default: 'h-10 px-4 py-2 native:h-12 native:px-5 native:py-3',
22
+ sm: 'h-9 rounded-md px-3',
23
+ lg: 'h-11 rounded-md px-8 native:h-14',
24
+ icon: 'h-10 w-10',
25
+ },
26
+ },
27
+ defaultVariants: {
28
+ variant: 'default',
29
+ size: 'default',
30
+ },
31
+ }
32
+ );
33
+
34
+ const buttonTextVariants = cva(
35
+ 'web:whitespace-nowrap text-sm native:text-base font-medium text-foreground web:transition-colors',
36
+ {
37
+ variants: {
38
+ variant: {
39
+ default: 'text-primary-foreground',
40
+ destructive: 'text-destructive-foreground',
41
+ outline: 'group-active:text-accent-foreground',
42
+ secondary: 'text-secondary-foreground group-active:text-secondary-foreground',
43
+ ghost: 'group-active:text-accent-foreground',
44
+ link: 'text-primary group-active:underline',
45
+ },
46
+ size: {
47
+ default: '',
48
+ sm: '',
49
+ lg: 'native:text-lg',
50
+ icon: '',
51
+ },
52
+ },
53
+ defaultVariants: {
54
+ variant: 'default',
55
+ size: 'default',
56
+ },
57
+ }
58
+ );
59
+
60
+ type ButtonProps = React.ComponentPropsWithoutRef<typeof Pressable> &
61
+ VariantProps<typeof buttonVariants>;
62
+
63
+ const Button = React.forwardRef<React.ElementRef<typeof Pressable>, ButtonProps>(
64
+ ({ className, variant, size, ...props }, ref) => {
65
+ return (
66
+ <TextClassContext.Provider
67
+ value={cn(
68
+ props.disabled && 'web:pointer-events-none',
69
+ buttonTextVariants({ variant, size })
70
+ )}
71
+ >
72
+ <Pressable
73
+ className={cn(
74
+ props.disabled && 'opacity-50 web:pointer-events-none',
75
+ buttonVariants({ variant, size, className })
76
+ )}
77
+ ref={ref}
78
+ role='button'
79
+ {...props}
80
+ />
81
+ </TextClassContext.Provider>
82
+ );
83
+ }
84
+ );
85
+ Button.displayName = 'Button';
86
+
87
+ export { Button, buttonTextVariants, buttonVariants };
88
+ export type { ButtonProps };
@@ -0,0 +1,57 @@
1
+ import type { TextRef, ViewRef } from '@rn-primitives/types';
2
+ import * as React from 'react';
3
+ import { Text, TextProps, View, ViewProps } from 'react-native';
4
+ import { TextClassContext } from '~/components/ui/text';
5
+ import { cn } from '~/lib/utils';
6
+
7
+ const Card = React.forwardRef<ViewRef, ViewProps>(({ className, ...props }, ref) => (
8
+ <View
9
+ ref={ref}
10
+ className={cn(
11
+ 'rounded-lg border border-border bg-card shadow-sm shadow-foreground/10',
12
+ className
13
+ )}
14
+ {...props}
15
+ />
16
+ ));
17
+ Card.displayName = 'Card';
18
+
19
+ const CardHeader = React.forwardRef<ViewRef, ViewProps>(({ className, ...props }, ref) => (
20
+ <View ref={ref} className={cn('flex flex-col space-y-1.5 p-6', className)} {...props} />
21
+ ));
22
+ CardHeader.displayName = 'CardHeader';
23
+
24
+ const CardTitle = React.forwardRef<TextRef, React.ComponentPropsWithoutRef<typeof Text>>(
25
+ ({ className, ...props }, ref) => (
26
+ <Text
27
+ role='heading'
28
+ aria-level={3}
29
+ ref={ref}
30
+ className={cn(
31
+ 'text-2xl text-card-foreground font-semibold leading-none tracking-tight',
32
+ className
33
+ )}
34
+ {...props}
35
+ />
36
+ )
37
+ );
38
+ CardTitle.displayName = 'CardTitle';
39
+
40
+ const CardDescription = React.forwardRef<TextRef, TextProps>(({ className, ...props }, ref) => (
41
+ <Text ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />
42
+ ));
43
+ CardDescription.displayName = 'CardDescription';
44
+
45
+ const CardContent = React.forwardRef<ViewRef, ViewProps>(({ className, ...props }, ref) => (
46
+ <TextClassContext.Provider value='text-card-foreground'>
47
+ <View ref={ref} className={cn('p-6 pt-0', className)} {...props} />
48
+ </TextClassContext.Provider>
49
+ ));
50
+ CardContent.displayName = 'CardContent';
51
+
52
+ const CardFooter = React.forwardRef<ViewRef, ViewProps>(({ className, ...props }, ref) => (
53
+ <View ref={ref} className={cn('flex flex-row items-center p-6 pt-0', className)} {...props} />
54
+ ));
55
+ CardFooter.displayName = 'CardFooter';
56
+
57
+ export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };
@@ -0,0 +1,61 @@
1
+ import * as ProgressPrimitive from '@rn-primitives/progress';
2
+ import * as React from 'react';
3
+ import { Platform, View } from 'react-native';
4
+ import Animated, {
5
+ Extrapolation,
6
+ interpolate,
7
+ useAnimatedStyle,
8
+ useDerivedValue,
9
+ withSpring,
10
+ } from 'react-native-reanimated';
11
+ import { cn } from '~/lib/utils';
12
+
13
+ const Progress = React.forwardRef<
14
+ ProgressPrimitive.RootRef,
15
+ ProgressPrimitive.RootProps & {
16
+ indicatorClassName?: string;
17
+ }
18
+ >(({ className, value, indicatorClassName, ...props }, ref) => {
19
+ return (
20
+ <ProgressPrimitive.Root
21
+ ref={ref}
22
+ className={cn('relative h-4 w-full overflow-hidden rounded-full bg-secondary', className)}
23
+ {...props}
24
+ >
25
+ <Indicator value={value} className={indicatorClassName} />
26
+ </ProgressPrimitive.Root>
27
+ );
28
+ });
29
+ Progress.displayName = ProgressPrimitive.Root.displayName;
30
+
31
+ export { Progress };
32
+
33
+ function Indicator({ value, className }: { value: number | undefined | null; className?: string }) {
34
+ const progress = useDerivedValue(() => value ?? 0);
35
+
36
+ const indicator = useAnimatedStyle(() => {
37
+ return {
38
+ width: withSpring(
39
+ `${interpolate(progress.value, [0, 100], [1, 100], Extrapolation.CLAMP)}%`,
40
+ { overshootClamping: true }
41
+ ),
42
+ };
43
+ });
44
+
45
+ if (Platform.OS === 'web') {
46
+ return (
47
+ <View
48
+ className={cn('h-full w-full flex-1 bg-primary web:transition-all', className)}
49
+ style={{ transform: `translateX(-${100 - (value ?? 0)}%)` }}
50
+ >
51
+ <ProgressPrimitive.Indicator className={cn('h-full w-full ', className)} />
52
+ </View>
53
+ );
54
+ }
55
+
56
+ return (
57
+ <ProgressPrimitive.Indicator asChild>
58
+ <Animated.View style={indicator} className={cn('h-full bg-foreground', className)} />
59
+ </ProgressPrimitive.Indicator>
60
+ );
61
+ }
@@ -0,0 +1,24 @@
1
+ import * as Slot from '@rn-primitives/slot';
2
+ import type { SlottableTextProps, TextRef } from '@rn-primitives/types';
3
+ import * as React from 'react';
4
+ import { Text as RNText } from 'react-native';
5
+ import { cn } from '~/lib/utils';
6
+
7
+ const TextClassContext = React.createContext<string | undefined>(undefined);
8
+
9
+ const Text = React.forwardRef<TextRef, SlottableTextProps>(
10
+ ({ className, asChild = false, ...props }, ref) => {
11
+ const textClass = React.useContext(TextClassContext);
12
+ const Component = asChild ? Slot.Text : RNText;
13
+ return (
14
+ <Component
15
+ className={cn('text-base text-foreground web:select-text', textClass, className)}
16
+ ref={ref}
17
+ {...props}
18
+ />
19
+ );
20
+ }
21
+ );
22
+ Text.displayName = 'Text';
23
+
24
+ export { Text, TextClassContext };
@@ -0,0 +1,39 @@
1
+ import * as TooltipPrimitive from '@rn-primitives/tooltip';
2
+ import * as React from 'react';
3
+ import { Platform, StyleSheet } from 'react-native';
4
+ import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
5
+ import { TextClassContext } from '~/components/ui/text';
6
+ import { cn } from '~/lib/utils';
7
+
8
+ const Tooltip = TooltipPrimitive.Root;
9
+
10
+ const TooltipTrigger = TooltipPrimitive.Trigger;
11
+
12
+ const TooltipContent = React.forwardRef<
13
+ TooltipPrimitive.ContentRef,
14
+ TooltipPrimitive.ContentProps & { portalHost?: string }
15
+ >(({ className, sideOffset = 4, portalHost, ...props }, ref) => (
16
+ <TooltipPrimitive.Portal hostName={portalHost}>
17
+ <TooltipPrimitive.Overlay style={Platform.OS !== 'web' ? StyleSheet.absoluteFill : undefined}>
18
+ <Animated.View
19
+ entering={Platform.select({ web: undefined, default: FadeIn })}
20
+ exiting={Platform.select({ web: undefined, default: FadeOut })}
21
+ >
22
+ <TextClassContext.Provider value='text-sm native:text-base text-popover-foreground'>
23
+ <TooltipPrimitive.Content
24
+ ref={ref}
25
+ sideOffset={sideOffset}
26
+ className={cn(
27
+ 'z-50 overflow-hidden rounded-md border border-border bg-popover px-3 py-1.5 shadow-md shadow-foreground/5 web:animate-in web:fade-in-0 web:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
28
+ className
29
+ )}
30
+ {...props}
31
+ />
32
+ </TextClassContext.Provider>
33
+ </Animated.View>
34
+ </TooltipPrimitive.Overlay>
35
+ </TooltipPrimitive.Portal>
36
+ ));
37
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
38
+
39
+ export { Tooltip, TooltipContent, TooltipTrigger };
@@ -0,0 +1,49 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ @layer base {
6
+ :root {
7
+ --background: 0 0% 100%;
8
+ --foreground: 240 10% 3.9%;
9
+ --card: 0 0% 100%;
10
+ --card-foreground: 240 10% 3.9%;
11
+ --popover: 0 0% 100%;
12
+ --popover-foreground: 240 10% 3.9%;
13
+ --primary: 240 5.9% 10%;
14
+ --primary-foreground: 0 0% 98%;
15
+ --secondary: 240 4.8% 95.9%;
16
+ --secondary-foreground: 240 5.9% 10%;
17
+ --muted: 240 4.8% 95.9%;
18
+ --muted-foreground: 240 3.8% 46.1%;
19
+ --accent: 240 4.8% 95.9%;
20
+ --accent-foreground: 240 5.9% 10%;
21
+ --destructive: 0 84.2% 60.2%;
22
+ --destructive-foreground: 0 0% 98%;
23
+ --border: 240 5.9% 90%;
24
+ --input: 240 5.9% 90%;
25
+ --ring: 240 5.9% 10%;
26
+ }
27
+
28
+ .dark:root {
29
+ --background: 240 10% 3.9%;
30
+ --foreground: 0 0% 98%;
31
+ --card: 240 10% 3.9%;
32
+ --card-foreground: 0 0% 98%;
33
+ --popover: 240 10% 3.9%;
34
+ --popover-foreground: 0 0% 98%;
35
+ --primary: 0 0% 98%;
36
+ --primary-foreground: 240 5.9% 10%;
37
+ --secondary: 240 3.7% 15.9%;
38
+ --secondary-foreground: 0 0% 98%;
39
+ --muted: 240 3.7% 15.9%;
40
+ --muted-foreground: 240 5% 64.9%;
41
+ --accent: 240 3.7% 15.9%;
42
+ --accent-foreground: 0 0% 98%;
43
+ --destructive: 0 72% 51%;
44
+ --destructive-foreground: 0 0% 98%;
45
+ --border: 240 3.7% 15.9%;
46
+ --input: 240 3.7% 15.9%;
47
+ --ring: 240 4.9% 83.9%;
48
+ }
49
+ }