Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ereburg committed Dec 9, 2024
1 parent 5191ff0 commit 44250c9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 30 deletions.
20 changes: 3 additions & 17 deletions utils/vara-ui/src/components/alert/alert.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
flex-direction: column;
background-color: #fff;
box-shadow: 0 10px 20px 0 rgba(92, 92, 92, 0.15);
user-select: none;
}

.header {
Expand Down Expand Up @@ -147,6 +146,7 @@
font-size: 17px;
font-weight: 700;
line-height: 1.4;
color: #000000;
}

.body,
Expand All @@ -158,15 +158,6 @@
top: 16px;
right: 16px;
}

&.success,
&.error,
&.info,
&.loading {
.title {
color: #000;
}
}
}

// Theming
Expand Down Expand Up @@ -219,13 +210,8 @@

// Variants
.notification {
&.success,
&.error,
&.info,
&.loading {
.title {
color: #fff;
}
.title {
color: #fff;
}
}
}
16 changes: 7 additions & 9 deletions utils/vara-ui/src/components/alert/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ import styles from './alert.module.scss';
import CrossSVG from '../../assets/images/cross.svg?react';
import { alertIcons } from './icons.tsx';

type IAlertVariants = 'alert' | 'notification';
type IAlertTypes = 'info' | 'error' | 'loading' | 'success';
type IAlertIcons = Record<IAlertVariants, Record<IAlertTypes, ReactNode>>;
type AlertVariants = 'alert' | 'notification';
type AlertTypes = 'info' | 'error' | 'loading' | 'success';

type Options = {
type: IAlertTypes;
variant?: IAlertVariants;
type: AlertTypes;
variant?: AlertVariants;
style?: CSSProperties;
title?: string;
timeout?: number;
isClosed?: boolean;
icons?: IAlertIcons;
};

type AlertType = {
Expand All @@ -32,12 +30,12 @@ type Props = {

function Alert({ alert, close }: Props) {
const { content, options, footer } = alert;
const { variant = 'alert', type = 'info', title, style, isClosed, icons = alertIcons } = options;
const { variant = 'alert', type = 'info', title, style, isClosed } = options;

return (
<div className={cx(styles.wrapper, styles[variant], styles[type])} style={style}>
<header className={cx(styles.header)}>
{type && <div className={styles.icon}>{icons[variant][type]}</div>}
{type && <div className={styles.icon}>{alertIcons[variant][type]}</div>}

<h2 className={styles.title}>{title || type}</h2>

Expand All @@ -56,4 +54,4 @@ function Alert({ alert, close }: Props) {
}

export { Alert };
export type { Props as AlertProps, IAlertVariants, IAlertTypes, IAlertIcons };
export type { Props as AlertProps, AlertVariants, AlertTypes };
7 changes: 5 additions & 2 deletions utils/vara-ui/src/components/alert/icons.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import type { IAlertIcons } from './alert.tsx';
import { ReactNode } from 'react';
import SuccessIcon from '../../assets/images/success.svg?react';
import ErrorIcon from '../../assets/images/error.svg?react';
import InfoIcon from '../../assets/images/info.svg?react';
import LoadingIcon from '../../assets/images/loading.svg?react';
import WarningIcon from '../../assets/images/warning.svg?react';
import type { AlertTypes, AlertVariants } from './alert.tsx';

const alertIcons: IAlertIcons = {
type AlertIcons = Record<AlertVariants, Record<AlertTypes, ReactNode>>;

const alertIcons: AlertIcons = {
alert: {
success: <SuccessIcon />,
error: <ErrorIcon />,
Expand Down
4 changes: 2 additions & 2 deletions utils/vara-ui/src/components/alert/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Alert, AlertProps, IAlertTypes, IAlertIcons, IAlertVariants } from './alert';
import { Alert, AlertProps, AlertTypes, AlertVariants } from './alert';
import alertStyles from './alert.module.scss';
import { alertIcons } from './icons.tsx';

export { Alert, alertStyles, alertIcons };
export type { AlertProps, IAlertTypes, IAlertIcons, IAlertVariants };
export type { AlertProps, AlertTypes, AlertVariants };

0 comments on commit 44250c9

Please sign in to comment.