Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/remove-clsx-from-react.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@knocklabs/react": patch
---

Remove the `clsx` runtime dependency from `@knocklabs/react`. The guide components now compose `className` natively, dropping `clsx` from the package's install graph.
1 change: 0 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"@telegraph/tokens": ">=0.2.0",
"@telegraph/tooltip": ">=0.2.2",
"@telegraph/typography": ">=0.4.0",
"clsx": "^2.1.1",
"lodash.debounce": "^4.0.8",
"lucide-react": "^0.544.0"
},
Expand Down
48 changes: 38 additions & 10 deletions packages/react/src/modules/guide/components/Banner/Banner.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ColorMode, useGuide } from "@knocklabs/react-core";
import clsx from "clsx";
import React from "react";

import { maybeNavigateToUrlWithDelay } from "../helpers";
Expand All @@ -13,7 +12,10 @@ const Root: React.FC<
React.PropsWithChildren<React.ComponentPropsWithRef<"div">>
> = ({ children, className, ...props }) => {
return (
<div className={clsx("knock-guide-banner", className)} {...props}>
<div
className={["knock-guide-banner", className].filter(Boolean).join(" ")}
{...props}
>
{children}
</div>
);
Expand All @@ -24,7 +26,12 @@ const Content: React.FC<
React.PropsWithChildren<React.ComponentPropsWithRef<"div">>
> = ({ children, className, ...props }) => {
return (
<div className={clsx("knock-guide-banner__message", className)} {...props}>
<div
className={["knock-guide-banner__message", className]
.filter(Boolean)
.join(" ")}
{...props}
>
{children}
</div>
);
Expand All @@ -35,7 +42,12 @@ const Title: React.FC<
{ title: string } & React.ComponentPropsWithRef<"div">
> = ({ title, className, ...props }) => {
return (
<div className={clsx("knock-guide-banner__title", className)} {...props}>
<div
className={["knock-guide-banner__title", className]
.filter(Boolean)
.join(" ")}
{...props}
>
{title}
</div>
);
Expand All @@ -49,7 +61,9 @@ const Body: React.FC<{ body: string } & React.ComponentPropsWithRef<"div">> = ({
}) => {
return (
<div
className={clsx("knock-guide-banner__body", className)}
className={["knock-guide-banner__body", className]
.filter(Boolean)
.join(" ")}
dangerouslySetInnerHTML={{ __html: body }}
{...props}
/>
Expand All @@ -61,7 +75,12 @@ const Actions: React.FC<
React.PropsWithChildren<React.ComponentPropsWithRef<"div">>
> = ({ children, className, ...props }) => {
return (
<div className={clsx("knock-guide-banner__actions", className)} {...props}>
<div
className={["knock-guide-banner__actions", className]
.filter(Boolean)
.join(" ")}
{...props}
>
{children}
</div>
);
Expand All @@ -73,7 +92,9 @@ const PrimaryButton: React.FC<
> = ({ text, action, className, ...props }) => {
return (
<button
className={clsx("knock-guide-banner__action", className)}
className={["knock-guide-banner__action", className]
.filter(Boolean)
.join(" ")}
{...props}
>
{text}
Expand All @@ -87,10 +108,12 @@ const SecondaryButton: React.FC<
> = ({ text, action, className, ...props }) => {
return (
<button
className={clsx(
className={[
"knock-guide-banner__action knock-guide-banner__action--secondary",
className,
)}
]
.filter(Boolean)
.join(" ")}
{...props}
>
{text}
Expand All @@ -104,7 +127,12 @@ const DismissButton: React.FC<React.ComponentPropsWithRef<"button">> = ({
...props
}) => {
return (
<button className={clsx("knock-guide-banner__close", className)} {...props}>
<button
className={["knock-guide-banner__close", className]
.filter(Boolean)
.join(" ")}
{...props}
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="18"
Expand Down
67 changes: 54 additions & 13 deletions packages/react/src/modules/guide/components/Card/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ColorMode, useGuide } from "@knocklabs/react-core";
import clsx from "clsx";
import React from "react";

import { isValidHttpUrl, maybeNavigateToUrlWithDelay } from "../helpers";
Expand All @@ -20,7 +19,10 @@ const Root: React.FC<
React.PropsWithChildren<React.ComponentPropsWithRef<"div">>
> = ({ children, className, ...props }) => {
return (
<div className={clsx("knock-guide-card", className)} {...props}>
<div
className={["knock-guide-card", className].filter(Boolean).join(" ")}
{...props}
>
{children}
</div>
);
Expand All @@ -31,7 +33,12 @@ const Content: React.FC<
React.PropsWithChildren<React.ComponentPropsWithRef<"div">>
> = ({ children, className, ...props }) => {
return (
<div className={clsx("knock-guide-card__message", className)} {...props}>
<div
className={["knock-guide-card__message", className]
.filter(Boolean)
.join(" ")}
{...props}
>
{children}
</div>
);
Expand All @@ -42,7 +49,12 @@ const Header: React.FC<
React.PropsWithChildren<React.ComponentPropsWithRef<"div">>
> = ({ children, className, ...props }) => {
return (
<div className={clsx("knock-guide-card__header", className)} {...props}>
<div
className={["knock-guide-card__header", className]
.filter(Boolean)
.join(" ")}
{...props}
>
{children}
</div>
);
Expand All @@ -53,7 +65,12 @@ const Headline: React.FC<
{ headline: string } & React.ComponentPropsWithRef<"div">
> = ({ headline, className, ...props }) => {
return (
<div className={clsx("knock-guide-card__headline", className)} {...props}>
<div
className={["knock-guide-card__headline", className]
.filter(Boolean)
.join(" ")}
{...props}
>
{headline}
</div>
);
Expand All @@ -64,7 +81,12 @@ const Title: React.FC<
{ title: string } & React.ComponentPropsWithRef<"div">
> = ({ title, className, ...props }) => {
return (
<div className={clsx("knock-guide-card__title", className)} {...props}>
<div
className={["knock-guide-card__title", className]
.filter(Boolean)
.join(" ")}
{...props}
>
{title}
</div>
);
Expand All @@ -78,7 +100,9 @@ const Body: React.FC<{ body: string } & React.ComponentPropsWithRef<"div">> = ({
}) => {
return (
<div
className={clsx("knock-guide-card__body", className)}
className={["knock-guide-card__body", className]
.filter(Boolean)
.join(" ")}
dangerouslySetInnerHTML={{ __html: body }}
{...props}
/>
Expand All @@ -91,7 +115,7 @@ const Img: React.FC<
> = ({ children, className, alt, ...props }) => {
return (
<img
className={clsx("knock-guide-card__img", className)}
className={["knock-guide-card__img", className].filter(Boolean).join(" ")}
alt={alt || ""}
{...props}
>
Expand All @@ -105,7 +129,12 @@ const Actions: React.FC<
React.PropsWithChildren<React.ComponentPropsWithRef<"div">>
> = ({ children, className, ...props }) => {
return (
<div className={clsx("knock-guide-card__actions", className)} {...props}>
<div
className={["knock-guide-card__actions", className]
.filter(Boolean)
.join(" ")}
{...props}
>
{children}
</div>
);
Expand All @@ -116,7 +145,12 @@ const PrimaryButton: React.FC<
ButtonContent & React.ComponentPropsWithRef<"button">
> = ({ text, action, className, ...props }) => {
return (
<button className={clsx("knock-guide-card__action", className)} {...props}>
<button
className={["knock-guide-card__action", className]
.filter(Boolean)
.join(" ")}
{...props}
>
{text}
</button>
);
Expand All @@ -128,10 +162,12 @@ const SecondaryButton: React.FC<
> = ({ text, action, className, ...props }) => {
return (
<button
className={clsx(
className={[
"knock-guide-card__action knock-guide-card__action--secondary",
className,
)}
]
.filter(Boolean)
.join(" ")}
{...props}
>
{text}
Expand All @@ -145,7 +181,12 @@ const DismissButton: React.FC<React.ComponentPropsWithRef<"button">> = ({
...props
}) => {
return (
<button className={clsx("knock-guide-card__close", className)} {...props}>
<button
className={["knock-guide-card__close", className]
.filter(Boolean)
.join(" ")}
{...props}
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="18"
Expand Down
Loading
Loading