diff --git a/packages/components/src/components/Banner/Banner.stories.tsx b/packages/components/src/components/Banner/Banner.stories.tsx index 3349a7f91ef7..0ac84f57b025 100644 --- a/packages/components/src/components/Banner/Banner.stories.tsx +++ b/packages/components/src/components/Banner/Banner.stories.tsx @@ -41,6 +41,7 @@ export const Banner: StoryObj = { args: { children: 'Insert text here.', filled: true, + isLoading: false, variant: 'warning', icon: undefined, rightContent: Click, diff --git a/packages/components/src/components/Banner/Banner.tsx b/packages/components/src/components/Banner/Banner.tsx index 5cf523ed6e77..ff54cef1d6d6 100755 --- a/packages/components/src/components/Banner/Banner.tsx +++ b/packages/components/src/components/Banner/Banner.tsx @@ -28,6 +28,7 @@ import { useMediaQuery } from '../../utils/useMediaQuery'; import { useElevation } from '../ElevationContext/ElevationContext'; import { Column, Row } from '../Flex/Flex'; import { variables } from '../../config'; +import { Spinner } from '../loaders/Spinner/Spinner'; export const allowedBannerFrameProps = ['margin'] as const satisfies FramePropsKeys[]; type AllowedFrameProps = Pick; @@ -44,6 +45,7 @@ export type BannerProps = AllowedFrameProps & { 'data-testid'?: string; spacingX?: SpacingX; color?: Color; + isLoading?: boolean; }; type WrapperParams = TransientProps & { @@ -94,6 +96,7 @@ export const Banner = ({ rightContent, spacingX = 'lg', 'data-testid': dataTest, + isLoading = false, ...rest }: BannerProps) => { const theme = useTheme(); @@ -133,7 +136,8 @@ export const Banner = ({ data-testid={dataTest} {...frameProps} > - {withIcon && ( + {isLoading && } + {!isLoading && withIcon && ( ; - -interface NotificationCardProps { - children: ReactNode; - variant: NotificationCardVariant; - isLoading?: boolean; - button?: ButtonType; - className?: string; - ['data-testid']?: string; - icon?: IconName; -} - -const getIcon = (variant: NotificationCardVariant): IconName | null => { - switch (variant) { - case 'info': - return 'info'; - case 'warning': - return 'warningTriangle'; - case 'destructive': - return 'warningTriangle'; - default: - return null; - } -}; -const getButtonVariant = (variant: NotificationCardVariant) => { - switch (variant) { - case 'info': - return 'info'; - case 'warning': - return 'warning'; - case 'destructive': - return 'destructive'; - default: - return 'tertiary'; - } -}; - -const getMainColor = (variant: NotificationCardVariant, theme: DefaultTheme) => { - switch (variant) { - case 'info': - return theme.backgroundAlertBlueBold; - case 'warning': - return theme.backgroundAlertYellowBold; - case 'destructive': - return theme.backgroundAlertRedBold; - default: - return 'transparent'; - } -}; -const getBackgroundColor = ({ - $elevation, - $variant, - theme, -}: { - $elevation: Elevation; - $variant: NotificationCardVariant; - theme: DefaultTheme; -}) => { - const elevationPart = $elevation === -1 ? 'Negative' : $elevation; - - switch ($variant) { - case 'info': - return theme[`backgroundAlertBlueSubtleOnElevation${elevationPart}`]; - case 'warning': - return theme[`backgroundAlertYellowSubtleOnElevation${elevationPart}`]; - case 'destructive': - return theme[`backgroundAlertRedSubtleOnElevation${elevationPart}`]; - default: - return 'transparent'; - } -}; - -const Wrapper = styled.div<{ $elevation: Elevation; $variant: NotificationCardVariant }>` - display: flex; - border-radius: ${borders.radii.sm}; - padding: ${spacingsPx.sm} ${spacingsPx.lg}; - align-items: center; - background: ${getBackgroundColor}; - margin-bottom: ${spacingsPx.xs}; - gap: ${spacingsPx.md}; -`; - -const IconWrapper = styled.div` - @media screen and (max-width: ${variables.SCREEN_SIZE.SM}) { - display: none; - } -`; - -const Body = styled.div` - display: flex; - justify-content: space-between; - align-items: center; - width: 100%; - color: ${({ theme }) => theme.textDefault}; - ${typography.hint} -`; - -const CardButton = ({ href, ...props }: ButtonType) => { - if (href) { - return ( - -