-
-
+
diff --git a/apps/desktop/layer/renderer/src/modules/timeline-column/FeedList.electron.tsx b/apps/desktop/layer/renderer/src/modules/timeline-column/FeedList.electron.tsx
index bc9da71f8..97cee63cd 100644
--- a/apps/desktop/layer/renderer/src/modules/timeline-column/FeedList.electron.tsx
+++ b/apps/desktop/layer/renderer/src/modules/timeline-column/FeedList.electron.tsx
@@ -1,4 +1,5 @@
import { useDraggable } from "@dnd-kit/core"
+import { Checkbox } from "@follow/components/ui/checkbox/index.js"
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
import { cn, isKeyForMultiSelectPressed } from "@follow/utils/utils"
import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react"
@@ -229,6 +230,7 @@ const FeedListImpl = forwardRef
>
)}
+
{(hasListData || hasInboxData) && (
& {
- onCheckedChange?: (checked: boolean) => void
- }
->(({ className, onCheckedChange, ...props }, ref) => (
-
{
- onCheckedChange?.(event.target.checked)
- props.onChange?.(event)
- }}
- />
-))
+type CheckboxProps = React.ComponentProps
& HTMLMotionProps<"button">
+
+function Checkbox({ className, onCheckedChange, ...props }: CheckboxProps) {
+ const [isChecked, setIsChecked] = React.useState(props?.checked ?? props?.defaultChecked ?? false)
+
+ React.useEffect(() => {
+ if (props?.checked !== undefined) setIsChecked(props.checked)
+ }, [props?.checked])
+
+ const handleCheckedChange = React.useCallback(
+ (checked: boolean) => {
+ setIsChecked(checked)
+ onCheckedChange?.(checked)
+ },
+ [onCheckedChange],
+ )
+
+ return (
+
+
+
+
+
+
+
+
+
+ )
+}
+
Checkbox.displayName = CheckboxPrimitive.Root.displayName
+
+export { Checkbox, type CheckboxProps }
diff --git a/packages/internal/components/src/ui/radio-group/Radio.tsx b/packages/internal/components/src/ui/radio-group/Radio.tsx
deleted file mode 100644
index d60419045..000000000
--- a/packages/internal/components/src/ui/radio-group/Radio.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { cn } from "@follow/utils/utils"
-import type { FC, ReactNode } from "react"
-import { useId } from "react"
-import { useEventCallback } from "usehooks-ts"
-
-import { useRadioContext, useRadioGroupValue } from "./context"
-
-export const Radio: FC<
- React.DetailedHTMLProps, HTMLInputElement> & {
- label: ReactNode
- wrapperClassName?: string
- labelClassName?: string
- }
-> = (props) => {
- const { id, label, className, wrapperClassName, labelClassName, value, onChange, ...rest } = props
- const { onChange: ctxOnChange } = useRadioContext() || {}
- const fallbackId = useId()
-
- const ctxValue = useRadioGroupValue()
-
- const handleChange: React.ChangeEventHandler = useEventCallback((e) => {
- ctxOnChange?.(e.target.value)
- onChange?.(e)
- })
- return (
-
- )
-}
diff --git a/packages/internal/components/src/ui/radio-group/index.ts b/packages/internal/components/src/ui/radio-group/index.ts
index d1e49febe..754e44fc2 100644
--- a/packages/internal/components/src/ui/radio-group/index.ts
+++ b/packages/internal/components/src/ui/radio-group/index.ts
@@ -1,3 +1,4 @@
export * from "./context"
-export * from "./Radio"
+export * as MotionRadio from "./motion"
+export * from "./RadioCard"
export * from "./RadioGroup"
diff --git a/packages/internal/components/src/ui/radio-group/motion.tsx b/packages/internal/components/src/ui/radio-group/motion.tsx
new file mode 100644
index 000000000..8e0f27fee
--- /dev/null
+++ b/packages/internal/components/src/ui/radio-group/motion.tsx
@@ -0,0 +1,99 @@
+"use client"
+
+import { Spring } from "@follow/components/constants/spring"
+import { cn } from "@follow/utils/utils"
+import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
+import type { HTMLMotionProps, Transition } from "motion/react"
+import { AnimatePresence, m } from "motion/react"
+import * as React from "react"
+
+type RadioGroupProps = React.ComponentProps & {
+ transition?: Transition
+}
+
+function RadioGroup({ className, ...props }: RadioGroupProps) {
+ return (
+
+ )
+}
+
+type RadioGroupIndicatorProps = React.ComponentProps & {
+ transition: Transition
+}
+
+function RadioGroupIndicator({ className, transition, ...props }: RadioGroupIndicatorProps) {
+ return (
+
+
+
+
+
+
+
+ )
+}
+
+type RadioGroupItemProps = React.ComponentProps &
+ HTMLMotionProps<"button"> & {
+ transition?: Transition
+ label?: string
+ }
+
+function RadioGroupItem({
+ className,
+ transition = Spring.presets.smooth,
+ label,
+ ...props
+}: RadioGroupItemProps) {
+ const id = React.useId()
+ return (
+
+
+
+
+
+ {label && }
+
+
+ )
+}
+
+export { RadioGroup, RadioGroupItem, type RadioGroupItemProps, type RadioGroupProps }
diff --git a/packages/internal/components/src/ui/switch/index.tsx b/packages/internal/components/src/ui/switch/index.tsx
index d9e6fd07a..491493a8f 100644
--- a/packages/internal/components/src/ui/switch/index.tsx
+++ b/packages/internal/components/src/ui/switch/index.tsx
@@ -1,24 +1,110 @@
+"use client"
+
import { cn } from "@follow/utils/utils"
-import * as SwitchPrimitives from "@radix-ui/react-switch"
+import type { SwitchProps as SwitchPrimitiveProps } from "@headlessui/react"
+import { Switch as SwitchPrimitive } from "@headlessui/react"
+import type { HTMLMotionProps } from "motion/react"
+import { m as motion } from "motion/react"
import * as React from "react"
-export const Switch = React.forwardRef<
- React.ElementRef,
- React.ComponentPropsWithoutRef
->(({ className, ...props }, ref) => (
-
-
-
-))
-Switch.displayName = SwitchPrimitives.Root.displayName
+type SwitchProps =
+ SwitchPrimitiveProps &
+ Omit, "children"> & {
+ leftIcon?: React.ReactNode
+ rightIcon?: React.ReactNode
+ thumbIcon?: React.ReactNode
+ onCheckedChange?: (checked: boolean) => void
+ as?: TTag
+ }
+
+function Switch({
+ className,
+ leftIcon,
+ rightIcon,
+ thumbIcon,
+ onChange,
+ onCheckedChange,
+ as = motion.button,
+ ...props
+}: SwitchProps) {
+ const [isChecked, setIsChecked] = React.useState(props.checked ?? props.defaultChecked ?? false)
+ const [isTapped, setIsTapped] = React.useState(false)
+
+ React.useEffect(() => {
+ setIsChecked(props.checked ?? props.defaultChecked ?? false)
+ }, [props.checked, props.defaultChecked])
+
+ const handleChange = React.useCallback(
+ (checked: boolean) => {
+ setIsChecked(checked)
+ onCheckedChange?.(checked)
+ onChange?.(checked)
+ },
+ [onCheckedChange, onChange],
+ )
+
+ return (
+ // @ts-expect-error
+ setIsTapped(true)}
+ onTapCancel={() => setIsTapped(false)}
+ onTap={() => setIsTapped(false)}
+ {...props}
+ >
+ {leftIcon && (
+
+ {typeof leftIcon !== "string" ? leftIcon : null}
+
+ )}
+
+ {rightIcon && (
+
+ {typeof rightIcon !== "string" ? rightIcon : null}
+
+ )}
+
+
+ {thumbIcon && typeof thumbIcon !== "string" ? thumbIcon : null}
+
+
+ )
+}
+
+export { Switch, type SwitchProps }