Skip to content

Commit

Permalink
Relax Callout prop requirements (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
kafkas authored Sep 14, 2023
1 parent e6023d9 commit 0bc6b9f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/ui/app/src/mdx/components/Callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,30 @@ import { InfoIcon } from "../../commons/icons/InfoIcon";
import { WarningIcon } from "../../commons/icons/WarningIcon";
import styles from "./Callout.module.scss";

type Intent = "info" | "warning" | "success";

export declare namespace Callout {
export interface Props {
intent: "info" | "warning" | "success";
intent: string;
}
}

function parseIntent(type: unknown): Intent {
if (typeof type !== "string") {
return "info";
} else if (type.toLowerCase() === "info") {
return "info";
} else if (type.toLowerCase() === "warning") {
return "warning";
} else if (type.toLowerCase() === "success") {
return "success";
} else {
return "info";
}
}

export const Callout: React.FC<React.PropsWithChildren<Callout.Props>> = ({ intent, children }) => {
export const Callout: React.FC<React.PropsWithChildren<Callout.Props>> = ({ intent: intentRaw, children }) => {
const intent = parseIntent(intentRaw);
return (
<div
className={classNames("flex space-x-3 px-4 pt-4 pb-1 border rounded-lg", {
Expand Down

1 comment on commit 0bc6b9f

@vercel
Copy link

@vercel vercel bot commented on 0bc6b9f Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

fern-dev – ./packages/ui/fe-bundle

fern-dev-git-main-buildwithfern.vercel.app
fern-dev-buildwithfern.vercel.app
app-dev.buildwithfern.com
devtest.buildwithfern.com

Please sign in to comment.