Skip to content

Commit 5510c62

Browse files
committed
remove unnecessary func or classes
1 parent 2922e96 commit 5510c62

File tree

8 files changed

+64
-137
lines changed

8 files changed

+64
-137
lines changed

Diff for: app/blocks/sidebar/sidebar-01/app-sidebar.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
SidebarSectionGroup,
2121
useSidebar,
2222
} from "@/components/ui/sidebar"
23-
import { Switch } from "@/components/ui/switch"
2423
import {
2524
IconArchive,
2625
IconArrowDown,
@@ -39,14 +38,12 @@ import {
3938
IconListBullets,
4039
IconLogout,
4140
IconMessage,
42-
IconMoon,
4341
IconNotes,
4442
IconPackage,
4543
IconPlus,
4644
IconSettings,
4745
IconShield,
4846
IconShoppingBag,
49-
IconSun,
5047
IconTicket,
5148
} from "justd-icons"
5249
import { useTheme } from "next-themes"
@@ -242,7 +239,6 @@ export default function AppSidebar(props: React.ComponentProps<typeof Sidebar>)
242239
</Menu.Item>
243240
<Menu.Separator />
244241

245-
246242
<Menu.Item href="#contact">
247243
<IconHeadphones />
248244
Customer Support

Diff for: components/banner.tsx

-49
This file was deleted.

Diff for: components/ui/avatar.tsx

+19-23
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,12 @@
1-
import { type VariantProps, tv } from "tailwind-variants"
1+
import { twMerge } from "tailwind-merge"
22

3-
const avatar = tv({
4-
base: [
5-
"inline-grid shrink-0 align-middle [--avatar-radius:20%] [--ring-opacity:20%] *:col-start-1 *:row-start-1",
6-
"-outline-offset-1 outline-1 outline-fg/(--ring-opacity)",
7-
],
8-
variants: {
9-
shape: {
10-
square: "rounded-(--avatar-radius) *:rounded-(--avatar-radius)",
11-
circle: "rounded-full *:rounded-full",
12-
},
13-
size: {
14-
"extra-small": "size-5 *:size-5",
15-
small: "size-6 *:size-6",
16-
medium: "size-8 *:size-8",
17-
large: "size-10 *:size-10",
18-
"extra-large": "size-12 *:size-12",
19-
},
20-
},
21-
})
22-
23-
interface AvatarProps extends VariantProps<typeof avatar> {
3+
interface AvatarProps {
244
src?: string | null
255
initials?: string
266
alt?: string
277
className?: string
8+
shape?: "square" | "circle"
9+
size?: "extra-small" | "small" | "medium" | "large" | "extra-large"
2810
}
2911

3012
const Avatar = ({
@@ -37,7 +19,21 @@ const Avatar = ({
3719
...props
3820
}: AvatarProps & React.ComponentPropsWithoutRef<"span">) => {
3921
return (
40-
<span data-slot="avatar" {...props} className={avatar({ shape, size, className })}>
22+
<span
23+
data-slot="avatar"
24+
{...props}
25+
className={twMerge(
26+
"-outline-offset-1 inline-grid shrink-0 align-middle outline-1 outline-fg/(--ring-opacity) [--avatar-radius:20%] [--ring-opacity:20%] *:col-start-1 *:row-start-1",
27+
size === "extra-small" && "size-5 *:size-5",
28+
size === "small" && "size-6 *:size-6",
29+
size === "medium" && "size-8 *:size-8",
30+
size === "large" && "size-10 *:size-10",
31+
size === "extra-large" && "size-12 *:size-12",
32+
shape === "square" && "rounded-(--avatar-radius) *:rounded-(--avatar-radius)",
33+
shape === "circle" && "rounded-full *:rounded-full",
34+
className,
35+
)}
36+
>
4137
{initials && (
4238
<svg
4339
className="size-full select-none fill-current p-[5%] font-medium text-[48px] uppercase"

Diff for: components/ui/carousel.tsx

+8-23
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ import {
1111
type ListBoxItemProps,
1212
ListBoxSection,
1313
type ListBoxSectionProps,
14-
composeRenderProps,
1514
} from "react-aria-components"
1615

17-
import { twMerge } from "tailwind-merge"
18-
import { tv } from "tailwind-variants"
16+
import { twJoin, twMerge } from "tailwind-merge"
1917
import type { ButtonProps } from "./button"
2018
import { Button } from "./button"
2119
import { composeTailwindRenderProps } from "./primitive"
@@ -180,32 +178,19 @@ const CarouselContent = <T extends object>({ className, ...props }: ListBoxSecti
180178
)
181179
}
182180

183-
const carouselItem = tv({
184-
base: [
185-
"xd24r min-w-0 shrink-0 grow-0 basis-full focus:outline-hidden focus-visible:outline-hidden",
186-
"group relative",
187-
],
188-
variants: {
189-
orientation: {
190-
horizontal: "pl-4",
191-
vertical: "pt-4",
192-
},
193-
},
194-
})
195-
196181
const CarouselItem = ({ className, ...props }: ListBoxItemProps) => {
197182
const { orientation } = useCarousel()
198183

199184
return (
200185
<ListBoxItem
201186
aria-label={`Slide ${props.id}`}
202187
aria-roledescription="slide"
203-
className={composeRenderProps(className, (className, renderProps) =>
204-
carouselItem({
205-
...renderProps,
206-
orientation,
207-
className,
208-
}),
188+
className={composeTailwindRenderProps(
189+
className,
190+
twJoin(
191+
"xd24r group relative min-w-0 shrink-0 grow-0 basis-full focus:outline-hidden focus-visible:outline-hidden",
192+
orientation === "horizontal" ? "pl-4" : "pt-4",
193+
),
209194
)}
210195
{...props}
211196
/>
@@ -270,4 +255,4 @@ Carousel.Item = CarouselItem
270255
Carousel.Button = CarouselButton
271256

272257
export type { CarouselApi }
273-
export { Carousel }
258+
export { Carousel, CarouselContent, CarouselHandler, CarouselItem, CarouselButton }

Diff for: components/ui/container.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ interface ContainerProps extends React.HTMLAttributes<HTMLDivElement> {
88
const Container = ({ className, constrained = false, ref, ...props }: ContainerProps) => (
99
<div
1010
className={twMerge(
11-
"mx-auto w-full max-w-7xl lg:max-w-(--breakpoint-xl) 2xl:max-w-(--breakpoint-2xl)",
12-
constrained ? "sm:px-6 lg:px-8" : "px-4",
11+
"mx-auto w-full max-w-7xl lg:max-w-(--breakpoint-2xl)",
12+
constrained ? "sm:px-6" : "px-4 sm:px-6",
1313
className,
1414
)}
1515
{...props}

Diff for: components/ui/drawer.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from "motion/react"
1616
import type { DialogProps } from "react-aria-components"
1717
import { type ButtonProps, Modal, ModalOverlay } from "react-aria-components"
18-
import { twJoin, twMerge } from "tailwind-merge"
18+
import { twMerge } from "tailwind-merge"
1919

2020
import { Dialog } from "./dialog"
2121

@@ -102,10 +102,7 @@ const DrawerContentPrimitive = ({ children, ...props }: DrawerOverlayPrimitivePr
102102
isDismissable
103103
isOpen
104104
onOpenChange={closeDrawer}
105-
className={twJoin([
106-
"fixed top-0 left-0 isolate z-50 h-(--visual-viewport-height) w-full touch-none will-change-transform",
107-
"flex items-end [--visual-viewport-vertical-padding:100px]",
108-
])}
105+
className="fixed top-0 left-0 isolate z-50 flex h-(--visual-viewport-height) w-full touch-none items-end will-change-transform [--visual-viewport-vertical-padding:100px]"
109106
style={{
110107
backgroundColor: bg as any,
111108
}}

Diff for: components/ui/field.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,4 @@ const Input = ({ className, ref, ...props }: InputProps) => {
134134
}
135135

136136
export type { FieldProps, InputProps, FieldErrorProps }
137-
export { Description, FieldError, FieldGroup, Input, Label }
137+
export { Description, FieldError, FieldGroup, Input, Label, fieldStyles }

Diff for: components/ui/slider.tsx

+32-30
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import {
77
SliderOutput,
88
Slider as SliderPrimitive,
99
SliderStateContext,
10-
SliderThumb,
11-
SliderTrack,
10+
SliderThumb as SliderThumbPrimitive,
11+
SliderTrack as SliderTrackPrimitive,
1212
type SliderTrackProps,
1313
composeRenderProps,
1414
} from "react-aria-components"
1515
import { tv } from "tailwind-variants"
1616

17+
import { composeTailwindRenderProps } from "@/components/ui/primitive"
18+
import { twJoin, twMerge } from "tailwind-merge"
1719
import { Description, Label } from "./field"
1820
import { Tooltip } from "./tooltip"
1921

@@ -73,7 +75,7 @@ const Slider = ({
7375

7476
const renderThumb = (value: number) => {
7577
const thumb = (
76-
<Thumb
78+
<SliderThumb
7779
index={value}
7880
aria-label={props.thumbLabels?.[value]}
7981
onFocusChange={onFocusChange}
@@ -115,47 +117,38 @@ const Slider = ({
115117
</SliderOutput>
116118
)}
117119
</div>
118-
<Track>
120+
<SliderTrack>
119121
{({ state }) => (
120122
<>
121-
<Filler />
123+
<SliderFiller />
122124
{state.values.map((_, i) => (
123125
<React.Fragment key={i}>{renderThumb(i)}</React.Fragment>
124126
))}
125127
</>
126128
)}
127-
</Track>
129+
</SliderTrack>
128130
{props.description && <Description>{props.description}</Description>}
129131
</SliderPrimitive>
130132
)
131133
}
132134

133-
const controlsStyles = tv({
134-
slots: {
135-
filler: [
136-
"rounded-full bg-primary group-data-disabled/track:opacity-60",
137-
"group-data-[orientation=horizontal]/top-0 pointer-events-none absolute group-data-[orientation=vertical]/track:bottom-0 group-data-[orientation=horizontal]/track:h-full group-data-[orientation=vertical]/track:w-full",
138-
],
139-
track: [
140-
"[--slider:color-mix(in_oklab,var(--color-muted)_90%,black_10%)] dark:[--slider:color-mix(in_oklab,var(--color-muted)_90%,white_10%)]",
141-
"group/track relative cursor-pointer rounded-full bg-(--slider) disabled:cursor-default disabled:opacity-60",
142-
"grow group-data-[orientation=horizontal]:h-1.5 group-data-[orientation=horizontal]:w-full group-data-[orientation=vertical]:w-1.5 group-data-[orientation=vertical]:flex-1",
143-
],
144-
},
145-
})
146-
147-
const { track, filler } = controlsStyles()
148-
149-
const Track = (props: SliderTrackProps) => {
135+
const SliderTrack = ({ className, ...props }: SliderTrackProps) => {
150136
return (
151-
<SliderTrack
137+
<SliderTrackPrimitive
152138
{...props}
153-
className={composeRenderProps(props.className, (className) => track({ className }))}
139+
className={composeTailwindRenderProps(
140+
className,
141+
twJoin([
142+
"[--slider:color-mix(in_oklab,var(--color-muted)_90%,black_10%)] dark:[--slider:color-mix(in_oklab,var(--color-muted)_90%,white_10%)]",
143+
"group/track relative cursor-pointer rounded-full bg-(--slider) disabled:cursor-default disabled:opacity-60",
144+
"grow group-data-[orientation=horizontal]:h-1.5 group-data-[orientation=horizontal]:w-full group-data-[orientation=vertical]:w-1.5 group-data-[orientation=vertical]:flex-1",
145+
]),
146+
)}
154147
/>
155148
)
156149
}
157150

158-
const Filler = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => {
151+
const SliderFiller = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => {
159152
const state = React.useContext(SliderStateContext)
160153
const { orientation, getThumbPercent, values } = state || {}
161154

@@ -172,7 +165,16 @@ const Filler = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) =
172165
: { bottom: `${percent0}%`, height: `${Math.abs(percent0 - percent1)}%` }
173166
}
174167

175-
return <div {...props} style={getStyle()} className={filler({ className })} />
168+
return (
169+
<div
170+
{...props}
171+
style={getStyle()}
172+
className={twMerge(
173+
"group-data-[orientation=horizontal]/top-0 pointer-events-none absolute rounded-full bg-primary group-disabled/track:opacity-60 group-data-[orientation=vertical]/track:bottom-0 group-data-[orientation=horizontal]/track:h-full group-data-[orientation=vertical]/track:w-full",
174+
className,
175+
)}
176+
/>
177+
)
176178
}
177179

178180
const thumbStyles = tv({
@@ -191,9 +193,9 @@ const thumbStyles = tv({
191193
},
192194
},
193195
})
194-
const Thumb = ({ className, ...props }: SliderThumbProps) => {
196+
const SliderThumb = ({ className, ...props }: SliderThumbProps) => {
195197
return (
196-
<SliderThumb
198+
<SliderThumbPrimitive
197199
{...props}
198200
className={composeRenderProps(className, (className, renderProps) =>
199201
thumbStyles({ ...renderProps, className }),
@@ -203,4 +205,4 @@ const Thumb = ({ className, ...props }: SliderThumbProps) => {
203205
}
204206

205207
export type { SliderProps }
206-
export { Slider }
208+
export { Slider, SliderFiller, SliderTrack, SliderThumb }

0 commit comments

Comments
 (0)