Skip to content

Commit 140bc7f

Browse files
committed
migrate Emoji to tailwind
1 parent ca9ba07 commit 140bc7f

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/components/Emoji.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
1+
import { ComponentProps } from "react"
12
import dynamic from "next/dynamic"
2-
import type { BaseProps } from "react-emoji-render"
3-
import { Box, type BoxProps } from "@chakra-ui/react"
43

4+
import { cn } from "@/lib/utils/cn"
55
import { IS_DEV } from "@/lib/utils/env"
66

77
const Twemoji = dynamic(
88
() => import("react-emoji-render").then((mod) => mod.Twemoji),
99
{ ssr: false }
1010
)
1111

12-
export type EmojiProps = Omit<BoxProps, "children"> & BaseProps
12+
export type EmojiProps = ComponentProps<typeof Twemoji>
1313

14-
const Emoji = (props: EmojiProps) => (
15-
<Box
16-
as={Twemoji}
14+
const Emoji = ({ className, ...props }: EmojiProps) => (
15+
<Twemoji
1716
// The emoji lib is switching the protocol based on the existence of the
1817
// `location` object. That condition in DEV causes hydration mismatches.
1918
// https://github.com/tommoor/react-emoji-render/blob/master/src/index.js#L8
2019
// Hence, here we are defining how we want it to handle the protocol to
2120
// avoid differences in SSR
2221
options={{ protocol: IS_DEV ? "http" : "https" }}
2322
svg
24-
display="inline-block"
25-
lineHeight="none"
26-
sx={{
27-
"& > img": {
28-
margin: "0 !important",
29-
display: "initial",
30-
},
31-
}}
23+
className={cn("inline-block leading-none [&>img]:!m-0", className)}
3224
{...props}
3325
/>
3426
)

0 commit comments

Comments
 (0)