refactor: unified cn utils (#29916)

Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
This commit is contained in:
Stephen Zhou
2025-12-19 12:08:34 +08:00
committed by GitHub
parent 80f11471ae
commit a26881cb24
815 changed files with 1064 additions and 1227 deletions

View File

@@ -1,7 +1,7 @@
'use client'
import React, { useEffect, useState } from 'react'
import { Switch as OriginalSwitch } from '@headlessui/react'
import classNames from '@/utils/classnames'
import { cn } from '@/utils/classnames'
type SwitchProps = {
onChange?: (value: boolean) => void
@@ -60,23 +60,19 @@ const Switch = (
setEnabled(checked)
onChange?.(checked)
}}
className={classNames(
wrapStyle[size],
className={cn(wrapStyle[size],
enabled ? 'bg-components-toggle-bg' : 'bg-components-toggle-bg-unchecked',
'relative inline-flex shrink-0 cursor-pointer rounded-[5px] border-2 border-transparent transition-colors duration-200 ease-in-out',
disabled ? '!cursor-not-allowed !opacity-50' : '',
size === 'xs' && 'rounded-sm',
className,
)}
className)}
>
<span
aria-hidden="true"
className={classNames(
circleStyle[size],
className={cn(circleStyle[size],
enabled ? translateLeft[size] : 'translate-x-0',
size === 'xs' && 'rounded-[1px]',
'pointer-events-none inline-block rounded-[3px] bg-components-toggle-knob shadow ring-0 transition duration-200 ease-in-out',
)}
'pointer-events-none inline-block rounded-[3px] bg-components-toggle-knob shadow ring-0 transition duration-200 ease-in-out')}
/>
</OriginalSwitch>
)