refactor: replace cn utility with clsx and update imports

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2025-02-14 17:26:42 +08:00
parent a96e341eeb
commit 62fea74c24
3 changed files with 12 additions and 6 deletions
@@ -1,4 +1,4 @@
import { cn } from "@follow/utils/utils"
import clsx from "clsx"
import { useId, useRef } from "react"
const size = {
@@ -26,7 +26,7 @@ export const createHeadingRenderer =
ref={ref}
{...rest}
data-rid={rid}
className={cn(rest.className, "group relative", size[level])}
className={clsx(rest.className, "group relative", size[level])}
>
{rest.children}
</As>
@@ -25,6 +25,7 @@ export const MarkdownImage = (props: HTMLProps<"img">) => {
const [isLoading, setIsLoading] = useState(true)
const ref = useContext(MarkdownRenderContainerRefContext)
const image = entry?.media.find((media) => media.url === src)
const { height: scaleHeight, width: scaleWidth } = useMemo(
() =>
calculateDimensions({
@@ -1,5 +1,4 @@
import { useIsDark } from "@follow/hooks"
import { cn } from "@follow/utils/utils"
import clsx from "clsx"
import { useIsomorphicLayoutEffect } from "foxact/use-isomorphic-layout-effect"
import { useAtomValue } from "jotai"
import type { FC } from "react"
@@ -10,6 +9,7 @@ import type {
DynamicImportLanguageRegistration,
DynamicImportThemeRegistration,
} from "shiki"
import { useMediaQuery } from "usehooks-ts"
import { codeThemeDarkAtom, codeThemeLightAtom } from "../../../atoms"
import { shiki, shikiTransformers } from "./shared"
@@ -27,6 +27,11 @@ export interface ShikiProps {
theme?: string
}
const useIsDark = () => {
const isDark = useMediaQuery("(prefers-color-scheme: dark)")
return isDark
}
let langModule: Record<BundledLanguage, DynamicImportLanguageRegistration> | null = null
let themeModule: Record<BundledTheme, DynamicImportThemeRegistration> | null = null
@@ -116,7 +121,7 @@ export const ShikiHighLighter: FC<ShikiProps> = (props) => {
if (!loaded) {
return (
<pre className={cn("bg-transparent", className)}>
<pre className={clsx("bg-transparent", className)}>
<code>{code}</code>
</pre>
)
@@ -154,7 +159,7 @@ const ShikiCode: FC<
return (
<div
className={cn(
className={clsx(
"group relative -mx-3 my-4",
styles["shiki-wrapper"],
transparent ? styles["transparent"] : null,