Skip to content

Commit b531d53

Browse files
authored
InfoBox width Prop (#1373)
## Description <!-- Please provide a brief description of the changes made in this pull request. Include any relevant context or reasoning for the changes. --> Simple PR to add a `width` prop to the infobox container. Occasionally I find that I want the infobox to fill the available space, rather than fit to content. Currently this is not possible. The work around is to wrap in a div/blockstack with `width-full`. This change allows for such scenarios in future. ## Related Issue and Pull requests <!-- Link to any related issues using the format #<issue-number> --> ## Type of Change <!-- Please delete options that are not relevant --> - [x] Improvement ## Checklist <!-- Please ensure the following are completed before submitting the PR --> - [ ] I have tested this does not break current pipelines / runs functionality - [ ] I have tested the changes on staging ## Screenshots (if applicable) <!-- Include any screenshots that might help explain the changes or provide visual context --> ## Test Instructions <!-- Detail steps and prerequisites for testing the changes in this PR --> ## Additional Comments <!-- Add any additional context or information that reviewers might need to know regarding this PR -->
1 parent 197781c commit b531d53

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/components/shared/InfoBox.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { cn } from "@/lib/utils";
44

55
interface InfoBoxProps {
66
title: string;
7+
width?: "full" | "fit" | "auto";
78
className?: string;
89
children: ReactNode;
910
variant?: "info" | "error" | "warning" | "success" | "ghost";
@@ -35,15 +36,24 @@ const variantStyles: Record<
3536
},
3637
};
3738

39+
const widthStyles: Record<NonNullable<InfoBoxProps["width"]>, string> = {
40+
full: "w-full",
41+
auto: "w-auto",
42+
fit: "w-fit",
43+
};
44+
3845
export const InfoBox = ({
3946
title,
47+
width = "fit",
4048
className,
4149
children,
4250
variant = "info",
4351
}: InfoBoxProps) => {
4452
const styles = variantStyles[variant];
53+
const widthClass = widthStyles[width];
54+
4555
return (
46-
<div className={cn("border rounded-md p-2", styles.container)}>
56+
<div className={cn("border rounded-md p-2", styles.container, widthClass)}>
4757
<div className={cn("text-sm font-semibold mb-1", styles.title)}>
4858
{title}
4959
</div>

0 commit comments

Comments
 (0)