Skip to content

Commit fb2a3a4

Browse files
committed
feat: update UI components and styles
- Updated `AnimatedBeam` component: - Changed `gradientStartColor` from `#ffaa40` to `#000000` and `gradientStopColor` from `#9c40ff` to `#9c0000`. - Improved path calculation logic by ensuring refs are not null and added reverse logic for path calculation. - Adjusted dependencies in `useEffect` for better performance. - Modified `BackgroundBeams` component: - Changed width and height classes for animated divs from `w-[50rem]` and `h-[50rem]` to `w-200` and `h-200`, and from `w-[30rem]` and `h-[30rem]` to `w-120` and `h-120`. - Refactored `BorderBeam` component: - Updated mask styles for better clarity and consistency. - Enhanced `CardSpotlight` component: - Added `opacity` and `transitionDuration` props for better control over spotlight effects. - Implemented touch event handling for mobile devices. - Improved `Spotlight` component: - Added width and height state management for better responsiveness. - Implemented scaling for mouse coordinates based on component dimensions. - Fixed `TextGenerateEffect` component: - Ensured `animate` and `duration` are included in the dependency array of `useEffect`. - Updated `Field` components: - Adjusted class names for better styling consistency and improved accessibility. - Refined `Kbd` component: - Updated class names for tooltip content styling. - Updated `NavigationMenu`: - Moved `navigationMenuTriggerStyle` to a separate file for better organization. - Refactored `Pagination` component: - Updated import paths for button variants. - Enhanced `SelectTrigger` component: - Improved class names for better styling consistency. - Refactored `Sidebar` components: - Moved sidebar context and variants to separate files for better organization and maintainability. - Added new `badge-variants`, `button-group-variants`, and `button-variants` files for better styling management. - Created `navigation-menu-variants` and `sidebar-variants` files for improved organization of styles. - Added `SidebarContext` for better state management in sidebar components.
1 parent 56a4ede commit fb2a3a4

37 files changed

Lines changed: 475 additions & 409 deletions

package-lock.json

Lines changed: 161 additions & 129 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
},
4444
"dependencies": {
4545
"@ai-sdk/google": "^2.0.52",
46-
"@ai-sdk/google-vertex": "^4.0.3",
47-
"@ai-sdk/openai": "^3.0.2",
48-
"@ai-sdk/openai-compatible": "^2.0.2",
49-
"@ai-sdk/react": "^3.0.7",
46+
"@ai-sdk/google-vertex": "^4.0.6",
47+
"@ai-sdk/openai": "^3.0.4",
48+
"@ai-sdk/openai-compatible": "^2.0.3",
49+
"@ai-sdk/react": "^3.0.11",
5050
"@dotenvx/dotenvx": "^1.51.4",
5151
"@e2b/code-interpreter": "^2.3.3",
5252
"@emotion/react": "^11.14.0",
@@ -104,7 +104,7 @@
104104
"@vercel/otel": "^2.1.0",
105105
"@xyflow/react": "^12.10.0",
106106
"a2a-ai-provider": "^0.4.0-alpha.2",
107-
"ai": "^5.0.117",
107+
"ai": "^5.0.118",
108108
"ai-sdk-ollama": "^3.0.1",
109109
"ai-sdk-provider-claude-code": "^3.1.0",
110110
"ai-sdk-provider-gemini-cli": "^2.0.1",
@@ -199,8 +199,8 @@
199199
"@types/react-dom": "^19.2.3",
200200
"@types/strip-comments": "^2.0.4",
201201
"@types/unist": "^3.0.3",
202-
"@typescript-eslint/eslint-plugin": "^8.51.0",
203-
"@typescript-eslint/parser": "^8.51.0",
202+
"@typescript-eslint/eslint-plugin": "^8.52.0",
203+
"@typescript-eslint/parser": "^8.52.0",
204204
"@vitest/coverage-v8": "^4.0.16",
205205
"eslint": "^9.39.2",
206206
"eslint-config-prettier": "^10.1.8",
@@ -212,19 +212,21 @@
212212
"tailwindcss": "^4.1.18",
213213
"tw-animate-css": "^1.4.0",
214214
"typescript": "^5.9.3",
215-
"typescript-eslint": "^8.51.0",
215+
"typescript-eslint": "^8.52.0",
216216
"typescript-language-server": "^5.1.3",
217217
"vitest": "^4.0.16"
218218
},
219219
"overrides": {
220220
"jsondiffpatch": "0.7.3",
221-
"ai": "^5.0.117",
221+
"ai": "^5.0.118",
222222
"morgan": "^1.10.1",
223223
"js-yaml": "^4.1.1",
224224
"multer": "^2.0.2",
225225
"body-parser": "^2.2.1",
226226
"jws": "^4.0.1",
227227
"qs": "^6.14.1",
228-
"eslint": "^9.39.2"
228+
"eslint": "^9.39.2",
229+
"typescript-eslint": "^8.52.0",
230+
"@typescript-eslint/parser": "^8.52.0"
229231
}
230-
}
232+
}

src/components/ai-elements/reasoning.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import { cn } from "@/lib/utils";
1010
import { BrainIcon, ChevronDownIcon } from "lucide-react";
1111
import type { ComponentProps, ReactNode } from "react";
12-
import { createContext, memo, useContext, useEffect, useState } from "react";
12+
import { createContext, memo, useContext, useEffect, useRef, useState } from "react";
1313
import { Streamdown } from "streamdown";
1414
import { Shimmer } from "./shimmer";
1515

@@ -69,19 +69,17 @@ export const Reasoning = memo(
6969
});
7070

7171
const [hasAutoClosed, setHasAutoClosed] = useState(false);
72-
const [startTime, setStartTime] = useState<number | null>(null);
72+
const startTimeRef = useRef<number | null>(null);
7373

7474
// Track duration when streaming starts and ends
7575
useEffect(() => {
7676
if (isStreaming) {
77-
if (startTime === null) {
78-
setStartTime(Date.now());
79-
}
80-
} else if (startTime !== null) {
81-
setDuration(Math.ceil((Date.now() - startTime) / MS_IN_S));
82-
setStartTime(null);
77+
startTimeRef.current ??= Date.now();
78+
} else if (startTimeRef.current !== null) {
79+
setDuration(Math.ceil((Date.now() - startTimeRef.current) / MS_IN_S));
80+
startTimeRef.current = null;
8381
}
84-
}, [isStreaming, startTime, setDuration]);
82+
}, [isStreaming, setDuration]);
8583

8684
// Auto-open when streaming starts, auto-close when streaming ends (once only)
8785
useEffect(() => {
@@ -171,7 +169,7 @@ export const ReasoningContent = memo(
171169
<CollapsibleContent
172170
className={cn(
173171
"mt-4 text-sm",
174-
"data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",
172+
"closed:fade-out-0 closed:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",
175173
className
176174
)}
177175
{...props}

ui/avatar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function Avatar({
2727
}: AvatarProps) {
2828
const [hasError, setHasError] = React.useState(false)
2929

30-
const initials = fallback || alt?.split(" ").map((n) => n[0]).join("").slice(0, 2).toUpperCase()
30+
const initials = fallback ?? alt?.split(" ").map((n) => n[0]).join("").slice(0, 2).toUpperCase()
3131

3232
return (
3333
<div
@@ -38,7 +38,7 @@ export function Avatar({
3838
)}
3939
{...props}
4040
>
41-
{src && !hasError ? (
41+
{(src !== null) && !hasError ? (
4242
<img
4343
src={src}
4444
alt={alt}

ui/badge-variants.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { cva } from "class-variance-authority"
2+
3+
export const badgeVariants = cva(
4+
"inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
5+
{
6+
variants: {
7+
variant: {
8+
default:
9+
"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
10+
secondary:
11+
"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
12+
destructive:
13+
"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
14+
outline:
15+
"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
16+
},
17+
},
18+
defaultVariants: {
19+
variant: "default",
20+
},
21+
}
22+
)

ui/badge.tsx

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
11
import * as React from "react"
22
import { Slot } from "@radix-ui/react-slot"
3-
import { cva, type VariantProps } from "class-variance-authority"
3+
import type { VariantProps } from "class-variance-authority"
44

55
import { cn } from "@/lib/utils"
6-
7-
const badgeVariants = cva(
8-
"inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
9-
{
10-
variants: {
11-
variant: {
12-
default:
13-
"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
14-
secondary:
15-
"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
16-
destructive:
17-
"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
18-
outline:
19-
"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
20-
},
21-
},
22-
defaultVariants: {
23-
variant: "default",
24-
},
25-
}
26-
)
6+
import { badgeVariants } from "./badge-variants"
277

288
function Badge({
299
className,
@@ -43,4 +23,4 @@ function Badge({
4323
)
4424
}
4525

46-
export { Badge, badgeVariants }
26+
export { Badge }

ui/breadcrumb.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) {
1313
<ol
1414
data-slot="breadcrumb-list"
1515
className={cn(
16-
"text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",
16+
"text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm wrap-break-word sm:gap-2.5",
1717
className
1818
)}
1919
{...props}

ui/button-group-variants.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { cva } from "class-variance-authority"
2+
3+
export const buttonGroupVariants = cva(
4+
"flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",
5+
{
6+
variants: {
7+
orientation: {
8+
horizontal:
9+
"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
10+
vertical:
11+
"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none",
12+
},
13+
},
14+
defaultVariants: {
15+
orientation: "horizontal",
16+
},
17+
}
18+
)

ui/button-group.tsx

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
11
import { Slot } from "@radix-ui/react-slot"
2-
import { cva, type VariantProps } from "class-variance-authority"
2+
import type { VariantProps } from "class-variance-authority"
33

44
import { cn } from "@/lib/utils"
55
import { Separator } from "@/ui/separator"
6-
7-
const buttonGroupVariants = cva(
8-
"flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",
9-
{
10-
variants: {
11-
orientation: {
12-
horizontal:
13-
"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
14-
vertical:
15-
"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none",
16-
},
17-
},
18-
defaultVariants: {
19-
orientation: "horizontal",
20-
},
21-
}
22-
)
6+
import { buttonGroupVariants } from "./button-group-variants"
237

248
function ButtonGroup({
259
className,
@@ -67,7 +51,7 @@ function ButtonGroupSeparator({
6751
data-slot="button-group-separator"
6852
orientation={orientation}
6953
className={cn(
70-
"bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto",
54+
"bg-input relative m-0! self-stretch data-[orientation=vertical]:h-auto",
7155
className
7256
)}
7357
{...props}
@@ -79,5 +63,4 @@ export {
7963
ButtonGroup,
8064
ButtonGroupSeparator,
8165
ButtonGroupText,
82-
buttonGroupVariants,
8366
}

ui/button-variants.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { cva } from "class-variance-authority"
2+
3+
export const buttonVariants = cva(
4+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
5+
{
6+
variants: {
7+
variant: {
8+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
9+
destructive:
10+
"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
11+
outline:
12+
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
13+
secondary:
14+
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
15+
ghost:
16+
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
17+
link: "text-primary underline-offset-4 hover:underline",
18+
},
19+
size: {
20+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
21+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
22+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
23+
icon: "size-9",
24+
"icon-sm": "size-8",
25+
"icon-lg": "size-10",
26+
},
27+
},
28+
defaultVariants: {
29+
variant: "default",
30+
size: "default",
31+
},
32+
}
33+
)

0 commit comments

Comments
 (0)