Skip to content

Commit 96d484d

Browse files
committed
chore(Alert): update to 5.0.0
1 parent 94869ab commit 96d484d

4 files changed

Lines changed: 90 additions & 3 deletions

File tree

src/Alert/Alert.stories.tsx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,75 @@ ErrorColor.args = {
152152
status: 'error',
153153
}
154154

155+
export const SoftStyle: Story<AlertProps> = (args) => {
156+
return (
157+
<div className="preview bg-base-100 relative flex min-h-[6rem] max-w-4xl min-w-[18rem] flex-wrap items-center justify-center gap-2 overflow-x-hidden bg-cover bg-top p-4 xl:py-10">
158+
<Alert {...args} status="info">
159+
12 unread messages. Tap to see.
160+
</Alert>
161+
<Alert {...args} status="success">
162+
Your purchase has been confirmed!
163+
</Alert>
164+
<Alert {...args} status="warning">
165+
Warning: Invalid email address!
166+
</Alert>
167+
<Alert {...args} status="error">
168+
Error! Task failed successfully.
169+
</Alert>
170+
</div>
171+
)
172+
}
173+
SoftStyle.args = {
174+
variant: 'soft',
175+
className: 'w-full',
176+
}
177+
178+
export const OutlineStyle: Story<AlertProps> = (args) => {
179+
return (
180+
<div className="preview bg-base-100 relative flex min-h-[6rem] max-w-4xl min-w-[18rem] flex-wrap items-center justify-center gap-2 overflow-x-hidden bg-cover bg-top p-4 xl:py-10">
181+
<Alert {...args} status="info">
182+
12 unread messages. Tap to see.
183+
</Alert>
184+
<Alert {...args} status="success">
185+
Your purchase has been confirmed!
186+
</Alert>
187+
<Alert {...args} status="warning">
188+
Warning: Invalid email address!
189+
</Alert>
190+
<Alert {...args} status="error">
191+
Error! Task failed successfully.
192+
</Alert>
193+
</div>
194+
)
195+
}
196+
OutlineStyle.args = {
197+
variant: 'outline',
198+
className: 'w-full',
199+
}
200+
201+
export const DashStyle: Story<AlertProps> = (args) => {
202+
return (
203+
<div className="preview bg-base-100 relative flex min-h-[6rem] max-w-4xl min-w-[18rem] flex-wrap items-center justify-center gap-2 overflow-x-hidden bg-cover bg-top p-4 xl:py-10">
204+
<Alert {...args} status="info">
205+
12 unread messages. Tap to see.
206+
</Alert>
207+
<Alert {...args} status="success">
208+
Your purchase has been confirmed!
209+
</Alert>
210+
<Alert {...args} status="warning">
211+
Warning: Invalid email address!
212+
</Alert>
213+
<Alert {...args} status="error">
214+
Error! Task failed successfully.
215+
</Alert>
216+
</div>
217+
)
218+
}
219+
DashStyle.args = {
220+
variant: 'dash',
221+
className: 'w-full',
222+
}
223+
155224
export const WithButtons: Story<AlertProps> = (args) => {
156225
return (
157226
<Alert

src/Alert/Alert.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,39 @@ import React, { forwardRef, ReactNode } from 'react'
22
import clsx from 'clsx'
33
import { twMerge } from 'tailwind-merge'
44

5-
import { IComponentBaseProps, ComponentStatus } from '../types'
5+
import {
6+
IComponentBaseProps,
7+
ComponentLayout,
8+
ComponentStatus,
9+
ComponentVariant,
10+
} from '../types'
611

712
export type AlertProps = React.HTMLAttributes<HTMLDivElement> &
813
IComponentBaseProps & {
914
icon?: ReactNode
15+
layout?: ComponentLayout
1016
status?: ComponentStatus
17+
variant?: ComponentVariant
1118
}
1219

1320
const Alert = forwardRef<HTMLDivElement, AlertProps>(
1421
(
15-
{ children, icon, status, dataTheme, className, ...props },
22+
{ children, icon, layout, status, variant, dataTheme, className, ...props },
1623
ref
1724
): JSX.Element => {
1825
const classes = twMerge(
1926
'alert',
2027
className,
2128
clsx({
29+
'alert-vertical': layout === 'vertical',
30+
'alert-horizontal': layout === 'horizontal',
2231
'alert-info': status === 'info',
2332
'alert-success': status === 'success',
2433
'alert-warning': status === 'warning',
2534
'alert-error': status === 'error',
35+
'alert-soft': variant === 'soft',
36+
'alert-dash': variant === 'dash',
37+
'alert-outline': variant === 'outline',
2638
})
2739
)
2840

src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export const componentLayouts = ['vertical', 'horizontal'] as const
12
export const componentPositions = ['top', 'bottom', 'left', 'right'] as const
23
export const componentShapes = ['circle', 'square'] as const
34
export const componentSizes = ['lg', 'md', 'sm', 'xs'] as const
@@ -7,6 +8,7 @@ export const componentStatuses = [
78
'warning',
89
'error',
910
] as const
11+
export const componentVariants = ['soft', 'dash', 'outline'] as const
1012
export const brandColors = [
1113
'neutral',
1214
'primary',

src/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import {
2-
componentStatuses,
32
componentColors,
3+
componentLayouts,
44
componentPositions,
55
componentSizes,
66
componentShapes,
7+
componentStatuses,
8+
componentVariants,
79
bgColors,
810
brandColors,
911
} from './constants'
@@ -21,6 +23,8 @@ export type ComponentPosition = typeof componentPositions[number]
2123
export type ComponentShape = typeof componentShapes[number]
2224
export type ComponentSize = typeof componentSizes[number]
2325
export type ComponentStatus = typeof componentStatuses[number]
26+
export type ComponentVariant = typeof componentVariants[number]
27+
export type ComponentLayout = typeof componentLayouts[number]
2428
export type ComponentBrandColors = typeof brandColors[number]
2529
export type ComponentBgColors = typeof bgColors[number]
2630

0 commit comments

Comments
 (0)