Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(blade): Alert custom icon added #2059

Merged
merged 10 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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/slimy-toys-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@razorpay/blade': major
---

Alert Custom icon added
11 changes: 9 additions & 2 deletions packages/blade/src/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ReactChild, ReactElement } from 'react';
import type { ComponentType, ReactChild, ReactElement } from 'react';
import { Fragment, useState } from 'react';

import { StyledAlert } from './StyledAlert';
Expand Down Expand Up @@ -69,6 +69,12 @@ type AlertProps = {
*/
onDismiss?: () => void;

/**
* Can be used to render an icon
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
leading?: ComponentType<any>;

/**
* Can be set to `high` for a more prominent look. Not to be confused with a11y emphasis.
*
Expand Down Expand Up @@ -128,6 +134,7 @@ const Alert = ({
color = 'neutral',
actions,
testID,
leading,
...styledProps
}: AlertProps): ReactElement | null => {
const { theme } = useTheme();
Expand All @@ -137,7 +144,7 @@ const Alert = ({
const isDesktop = matchedDeviceType === 'desktop';
const isMobile = !isDesktop;

const Icon = intentIconMap[color];
const Icon = leading || intentIconMap[color];
let iconOffset: DotNotationSpacingStringToken = 'spacing.1';

// certain special cases below needs special care for near perfect alignment
Expand Down
Loading