Files
new-api/web/default/src/components/auto-skeleton.tsx
T
t0ng7u 948780e3fa 🎨 fix(theme): align UI controls with global radius tokens
Remove hard-coded and capped border radius overrides so shared controls and feature actions consistently follow the active theme radius.

- Replace fixed radius utilities with semantic theme-aware radius tokens
- Remove redundant `rounded-full` and pixel-based overrides from header, toolbar, Playground, and utility actions
- Drop unused `StatusBadge` rounded prop usage
- Keep existing component behavior intact while improving global theme consistency
2026-05-08 01:50:03 +08:00

66 lines
1.6 KiB
TypeScript
Vendored

import type { ReactNode } from 'react'
import type { UseQueryResult } from '@tanstack/react-query'
import { AutoSkeleton } from 'auto-skeleton-react'
import { useThemeRadiusPx } from '@/lib/theme-radius'
import { ErrorState } from '@/components/error-state'
interface ContentSkeletonProps {
loading: boolean
children: ReactNode
borderRadius?: number
minTextHeight?: number
maxDepth?: number
className?: string
}
export function ContentSkeleton(props: ContentSkeletonProps) {
const themeRadius = useThemeRadiusPx()
return (
<div className={props.className}>
<AutoSkeleton
loading={props.loading}
config={{
animation: 'none',
baseColor: 'var(--skeleton-base)',
highlightColor: 'var(--skeleton-highlight)',
borderRadius: props.borderRadius ?? themeRadius,
minTextHeight: props.minTextHeight ?? 14,
maxDepth: props.maxDepth ?? 10,
}}
>
{props.children}
</AutoSkeleton>
</div>
)
}
interface QuerySkeletonProps {
query: UseQueryResult<unknown, unknown>
children: ReactNode
className?: string
errorTitle?: string
errorDescription?: string
}
export function QuerySkeleton(props: QuerySkeletonProps) {
if (props.query.isError) {
return (
<ErrorState
title={props.errorTitle}
description={props.errorDescription}
onRetry={() => props.query.refetch()}
/>
)
}
return (
<ContentSkeleton
loading={props.query.isLoading}
className={props.className}
>
{props.children}
</ContentSkeleton>
)
}