Skip to content
Merged
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
10 changes: 10 additions & 0 deletions clients/fidesui/src/components/feedback/Alert.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ export const Banner: Story = {
description: PARAGRAPH_LOREM,
banner: true,
},
argTypes: {
type: {
control: "select",
options: Object.values(ALERT_TYPE),
},
showIcon: {
control: "boolean",
},
icon: iconControl,
},
};

export const Compact: Story = {
Expand Down
11 changes: 10 additions & 1 deletion clients/fidesui/src/hoc/CustomAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ export interface CustomAlertProps extends AlertProps {}

const withCustomProps = (WrappedComponent: typeof Alert) => {
const WrappedAlert = React.forwardRef<AlertRef, CustomAlertProps>(
({ showIcon, icon, type = "info", description, ...props }, ref) => {
(
{ showIcon = false, icon, type = "info", banner, description, ...props },
ref,
) => {
// Override Ant's banner-specific defaults so all alert types
// behave consistently.
const carbonIcon =
showIcon && icon === undefined
? getDefaultAlertIcon(type, !!description)
Expand All @@ -20,6 +25,7 @@ const withCustomProps = (WrappedComponent: typeof Alert) => {
showIcon={showIcon}
icon={carbonIcon}
type={type}
banner={banner}
description={description}
{...props}
/>
Expand All @@ -39,6 +45,9 @@ const withCustomProps = (WrappedComponent: typeof Alert) => {
* injected based on the alert `type`. Icons are sized at 16px for compact
* alerts and 24px when a `description` is present.
*
* Banner mode (`banner={true}`) uses the same defaults as all other alert
* types (`showIcon=false`, `type="info"`), overriding Ant's internal defaults.
*
* All standard Alert props are supported. Passing a custom `icon` overrides
* the Carbon default.
*/
Expand Down
Loading