Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 0 additions & 135 deletions app/(site)/content/components/button/button.mdx

This file was deleted.

150 changes: 70 additions & 80 deletions app/(site)/docs/components/button/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,81 +4,60 @@ export default function ButtonPage() {
return (
<ComponentPreview
name="Button"
description="A button component that can be used to trigger actions or navigate to different pages."
description="A button component for React Native applications."
examples={[
{
title: "Default",
value: "default",
content: `import { Button } from "@nativeui/ui";

export default function ButtonDemo() {
return (
<Button>
Click me
</Button>
);
}`,
language: "tsx",
},
{
title: "Variants",
value: "variants",
content: `import { Button } from "@nativeui/ui";

export default function ButtonVariants() {
return (
<div className="flex flex-col gap-4">
<Button variant="default">Default</Button>
<Button variant="destructive">Destructive</Button>
<Button variant="outline">Outline</Button>
<Button variant="secondary">Secondary</Button>
<Button variant="ghost">Ghost</Button>
<Button variant="link">Link</Button>
</div>
);
}`,
language: "tsx",
},
{
title: "Sizes",
value: "sizes",
content: `import { Button } from "@nativeui/ui";

export default function ButtonSizes() {
return (
<div className="flex items-center gap-4">
<Button size="sm">Small</Button>
<Button size="default">Default</Button>
<Button size="lg">Large</Button>
<Button size="icon">👋</Button>
</div>
);
}`,
language: "tsx",
},
]}
{
"title": "Default",
"value": "default",
"content": "import { Button } from \"@nativeui/ui\";\n\nexport default function ButtonDemo() {\n return (\n <Button>\n Click me\n </Button>\n );\n}",
"language": "tsx"
},
{
"title": "Variants",
"value": "variants",
"content": "import { Button } from \"@nativeui/ui\";\n\nexport default function ButtonVariants() {\n return (\n <div className=\"flex flex-col gap-4\">\n <Button variant=\"default\">Default</Button>\n <Button variant=\"dark\">Dark</Button>\n <Button variant=\"destructive\">Destructive</Button>\n <Button variant=\"outline\">Outline</Button>\n <Button variant=\"secondary\">Secondary</Button>\n <Button variant=\"ghost\">Ghost</Button>\n <Button variant=\"link\">Link</Button>\n </div>\n );\n}",
"language": "tsx"
},
{
"title": "Sizes",
"value": "sizes",
"content": "import { Button } from \"@nativeui/ui\";\n\nexport default function ButtonSizes() {\n return (\n <div className=\"flex items-center gap-4\">\n <Button size=\"default\">Default</Button>\n <Button size=\"sm\">Sm</Button>\n <Button size=\"lg\">Lg</Button>\n <Button size=\"icon\">👋</Button>\n </div>\n );\n}",
"language": "tsx"
}
]}
componentCode={`import * as React from "react";
import { Pressable, Text } from "react-native";
import { cva, type VariantProps } from "class-variance-authority";
import {
Pressable,
PressableProps as RNPressableProps,
View,
ViewStyle,
PressableStateCallbackType,
} from "react-native";
import { cn } from "@/lib/utils";

const buttonVariants = cva(
"flex items-center justify-center rounded-md",
import { cva, type VariantProps } from "class-variance-authority";

export const buttonVariants = cva(
"flex-row items-center justify-center rounded-md",
{
variants: {
variant: {
default: "bg-primary",
destructive: "bg-destructive",
outline: "border border-input bg-background",
secondary: "bg-secondary",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
default:
"bg-primary text-primary-foreground dark:bg-primary dark:text-primary-foreground shadow",
destructive:
"bg-destructive text-destructive-foreground dark:bg-destructive dark:text-destructive-foreground shadow-sm",
outline:
"border border-input bg-background text-foreground dark:border-input dark:bg-background dark:text-foreground shadow-sm",
secondary:
"bg-secondary text-secondary-foreground dark:bg-secondary dark:text-secondary-foreground shadow-sm",
ghost: "text-foreground dark:text-foreground",
link: "text-primary dark:text-primary underline",
},
size: {
default: "h-10 px-4 py-2",
sm: "h-9 rounded-md px-3",
lg: "h-11 rounded-md px-8",
icon: "h-10 w-10",
default: "h-12 px-6",
sm: "h-10 px-4",
lg: "h-14 px-8",
icon: "h-12 w-12",
},
},
defaultVariants: {
Expand All @@ -89,26 +68,37 @@ const buttonVariants = cva(
);

export interface ButtonProps
extends React.ComponentPropsWithoutRef<typeof Pressable>,
extends Omit<RNPressableProps, "style">,
VariantProps<typeof buttonVariants> {
className?: string;
style?: ViewStyle;
asChild?: boolean;
}

const Button = React.forwardRef<
React.ElementRef<typeof Pressable>,
ButtonProps
>(({ className, variant, size, asChild = false, ...props }, ref) => {
return (
<Pressable
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
);
});
const Button = React.forwardRef<View, ButtonProps>(
({ className, variant, size, asChild = false, children, ...props }, ref) => {
return (
<Pressable
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
>
{(state: PressableStateCallbackType) => (
<View
className={\`flex-row items-center justify-center gap-2 ""\`}
>
{typeof children === "function" ? children(state) : children}
</View>
)}
</Pressable>
);
}
);

Button.displayName = "Button";

export { Button, buttonVariants };`}
export { Button };
`}
previewCode={`import { Button } from "@nativeui/ui";

export default function ButtonDemo() {
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"registry:build": "shadcn build"
"registry:build": "shadcn build",
"build:registry": "node scripts/build-registry.js",
"generate:docs": "node scripts/generate-component-docs.js",
"update:components": "node scripts/update-components.js",
"create:component": "node scripts/create-component.js"
},
"dependencies": {
"@mdx-js/loader": "^3.1.0",
Expand Down Expand Up @@ -56,6 +60,7 @@
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "15.2.3",
"glob": "^11.0.2",
"shadcn": "2.4.0-canary.17",
"tailwindcss": "^4",
"typescript": "^5"
Expand Down
Loading