Skip to content

Commit 6caecce

Browse files
fix(Alert): remove redundant boolean from onDismiss prop type (#1539)
* refactor(Alert): update onDismiss prop type and remove default values from stories - Changed the type of `onDismiss` prop in Alert component from boolean to a function type - Removed `onDismiss` default values from various Alert stories to align with the updated prop type * chore: add changeset
1 parent 47bde19 commit 6caecce

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

.changeset/yummy-feet-attend.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"flowbite-react": patch
3+
---
4+
5+
refactor(Alert): `onDismiss` prop
6+
7+
- Changed the type of `onDismiss` prop in Alert component from boolean to a function type
8+
- Removed `onDismiss` default values from various Alert stories to align with the updated prop type

apps/storybook/src/Alert.stories.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const Template: StoryFn<AlertProps> = (props) => <Alert {...props} />;
1919
export const DefaultAlert = Template.bind({});
2020
DefaultAlert.storyName = "Default";
2121
DefaultAlert.args = {
22-
onDismiss: false,
2322
children: (
2423
<>
2524
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Soluta minima rerum veritatis optio atque impedit, enim
@@ -32,7 +31,6 @@ export const AlertWithIcons = Template.bind({});
3231
AlertWithIcons.storyName = "With icons";
3332
AlertWithIcons.args = {
3433
icon: HiInformationCircle,
35-
onDismiss: false,
3634
children: (
3735
<>
3836
More info about this info alert goes here. This example text is going to run a bit longer so that you can see how
@@ -54,15 +52,13 @@ AlertRounded.storyName = "Not rounded";
5452
AlertRounded.args = {
5553
color: "warning",
5654
rounded: false,
57-
onDismiss: false,
5855
children: <>Info alert! Change a few things up and try submitting again.</>,
5956
};
6057

6158
export const AlertWithBorderAccent = Template.bind({});
6259
AlertWithBorderAccent.storyName = "Border accent";
6360
AlertWithBorderAccent.args = {
6461
color: "warning",
65-
onDismiss: false,
6662
withBorderAccent: true,
6763
children: <>Info alert! Change a few things up and try submitting again.</>,
6864
};
@@ -72,7 +68,6 @@ AlertWithAdditionalContent.storyName = "Additional content";
7268
AlertWithAdditionalContent.args = {
7369
color: "info",
7470
icon: HiInformationCircle,
75-
onDismiss: false,
7671
withBorderAccent: true,
7772
additionalContent: (
7873
<>

packages/ui/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,5 @@
141141
"default": true
142142
}
143143
},
144-
"required": ["components", "path", "prefix", "rsc", "tsx"]
144+
"required": ["components", "dark", "path", "prefix", "rsc", "tsx"]
145145
}

packages/ui/src/components/Alert/Alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface AlertProps extends Omit<ComponentProps<"div">, "color">, Themin
3030
additionalContent?: ReactNode;
3131
color?: DynamicStringEnumKeysOf<FlowbiteColors>;
3232
icon?: FC<ComponentProps<"svg">>;
33-
onDismiss?: boolean | (() => void);
33+
onDismiss?: ComponentProps<"button">["onClick"];
3434
rounded?: boolean;
3535
withBorderAccent?: boolean;
3636
}

0 commit comments

Comments
 (0)