diff --git a/app/(site)/docs/components/progress/page.tsx b/app/(site)/docs/components/progress/page.tsx new file mode 100644 index 0000000..6a584a1 --- /dev/null +++ b/app/(site)/docs/components/progress/page.tsx @@ -0,0 +1,89 @@ +import { ComponentPreview } from "@/components/docs/component-preview"; + +export default function ProgressPage() { + return ( + \n Click me\n \n );\n}", + "language": "tsx" + } +]} + componentCode={`import * as React from "react"; +import { View, Animated, Easing } from "react-native"; +import { cn } from "@/lib/utils"; + +interface ProgressProps { + value?: number; + max?: number; + className?: string; + indicatorClassName?: string; +} + +const Progress = React.forwardRef( + ({ value = 0, max = 100, className, indicatorClassName, ...props }, ref) => { + const animatedValue = React.useRef(new Animated.Value(0)).current; + + React.useEffect(() => { + Animated.timing(animatedValue, { + toValue: value, + duration: 500, + easing: Easing.bezier(0.4, 0.0, 0.2, 1), + useNativeDriver: false, + }).start(); + }, [value, animatedValue]); + + const width = animatedValue.interpolate({ + inputRange: [0, max], + outputRange: ["0%", "100%"], + extrapolate: "clamp", + }); + + return ( + + + + ); + } +); + +Progress.displayName = "Progress"; + +export { Progress }; +`} + previewCode={`import { Progress } from "@nativeui/ui"; + +export default function ProgressDemo() { + return ( +
+ Default Progress + Delete + Outline + Secondary + Ghost + Link +
+ ); +}`} + registryName="progress" + packageName="@nativeui/ui" + /> + ); +} diff --git a/public/r/progress.json b/public/r/progress.json new file mode 100644 index 0000000..9a81bb6 --- /dev/null +++ b/public/r/progress.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://ui.shadcn.com/schema/registry-item.json", + "name": "progress", + "type": "registry:component", + "title": "Progress", + "description": "A progress component for React Native applications.", + "dependencies": [ + "react-native" + ], + "registryDependencies": [], + "files": [ + { + "path": "registry/progress/progress.tsx", + "content": "import * as React from \"react\";\nimport { View, Animated, Easing } from \"react-native\";\nimport { cn } from \"@/lib/utils\";\n\ninterface ProgressProps {\n value?: number;\n max?: number;\n className?: string;\n indicatorClassName?: string;\n}\n\nconst Progress = React.forwardRef(\n ({ value = 0, max = 100, className, indicatorClassName, ...props }, ref) => {\n const animatedValue = React.useRef(new Animated.Value(0)).current;\n\n React.useEffect(() => {\n Animated.timing(animatedValue, {\n toValue: value,\n duration: 500,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: false,\n }).start();\n }, [value, animatedValue]);\n\n const width = animatedValue.interpolate({\n inputRange: [0, max],\n outputRange: [\"0%\", \"100%\"],\n extrapolate: \"clamp\",\n });\n\n return (\n \n \n \n );\n }\n);\n\nProgress.displayName = \"Progress\";\n\nexport { Progress };\n", + "type": "registry:component" + } + ] +} \ No newline at end of file diff --git a/registry.json b/registry.json index 4a66e47..0e9cb0a 100644 --- a/registry.json +++ b/registry.json @@ -301,6 +301,20 @@ ], "dependencies": ["react-native"], "registryDependencies": [] + }, + { + "name": "progress", + "type": "registry:component", + "title": "Progress", + "description": "A progress component for React Native applications.", + "files": [ + { + "path": "registry/progress/progress.tsx", + "type": "registry:component" + } + ], + "dependencies": ["react-native"], + "registryDependencies": [] } ] } diff --git a/registry/progress/progress.tsx b/registry/progress/progress.tsx new file mode 100644 index 0000000..995a4bd --- /dev/null +++ b/registry/progress/progress.tsx @@ -0,0 +1,54 @@ +import * as React from "react"; +import { View, Animated, Easing } from "react-native"; +import { cn } from "@/lib/utils"; + +interface ProgressProps { + value?: number; + max?: number; + className?: string; + indicatorClassName?: string; +} + +const Progress = React.forwardRef( + ({ value = 0, max = 100, className, indicatorClassName, ...props }, ref) => { + const animatedValue = React.useRef(new Animated.Value(0)).current; + + React.useEffect(() => { + Animated.timing(animatedValue, { + toValue: value, + duration: 500, + easing: Easing.bezier(0.4, 0.0, 0.2, 1), + useNativeDriver: false, + }).start(); + }, [value, animatedValue]); + + const width = animatedValue.interpolate({ + inputRange: [0, max], + outputRange: ["0%", "100%"], + extrapolate: "clamp", + }); + + return ( + + + + ); + } +); + +Progress.displayName = "Progress"; + +export { Progress };