File tree Expand file tree Collapse file tree 4 files changed +77
-0
lines changed Expand file tree Collapse file tree 4 files changed +77
-0
lines changed Original file line number Diff line number Diff line change 1+ import { Meta } from "@storybook/react" ;
2+ import { Alert } from "./Alert" ;
3+ import React from "react" ;
4+
5+ export default {
6+ title : "Alert" ,
7+ component : Alert
8+ } as Meta
9+
10+ export const AlertExample = ( ) => {
11+ return < Alert color = { "error" } >
12+ This is an alert message!
13+ </ Alert >
14+ }
Original file line number Diff line number Diff line change 1+ @use " ../../styles/helpers" ;
2+ @use " ../../styles/box" ;
3+ @use " ../../styles/variables" ;
4+
5+ .alert {
6+ padding : variables .$md ;
7+ font-size : variables .$sm ;
8+ position : relative ;
9+ display : flex ;
10+ align-items : center ;
11+ gap : variables .$xxs ;
12+
13+ & {
14+ @include helpers .fontStyle ();
15+ @include helpers .borderRadius ();
16+ }
17+
18+ > svg {
19+ min-width : variables .$md ;
20+ min-height : variables .$md ;
21+ }
22+ }
23+
24+ @each $name , $color in variables .$colors {
25+ .alert--#{$name } {
26+ @include box .box ($color );
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ import React from "react" ;
2+ import { Code0Component , Color , mergeCode0Props } from "../../utils" ;
3+ import {
4+ IconAlertCircle ,
5+ IconCircleCheck ,
6+ IconCircleDot ,
7+ IconCircleX ,
8+ IconInfoCircle ,
9+ IconProps
10+ } from "@tabler/icons-react" ;
11+ import "./Alert.style.scss"
12+
13+ export interface AlertProps extends Code0Component < HTMLDivElement > {
14+ color ?: Color
15+ children : React . ReactNode
16+ }
17+
18+ export const Alert : React . FC < AlertProps > = ( props ) => {
19+ const { color = "secondary" , children, ...rest } = props
20+
21+ const icons : Record < Color , React . ReactElement < IconProps > > = {
22+ "primary" : < IconCircleDot size = { 16 } /> ,
23+ "secondary" : < IconCircleDot size = { 16 } /> ,
24+ "info" : < IconInfoCircle size = { 16 } /> ,
25+ "success" : < IconCircleCheck size = { 16 } /> ,
26+ "warning" : < IconAlertCircle size = { 16 } /> ,
27+ "error" : < IconCircleX size = { 16 } /> ,
28+ }
29+
30+ return < div { ...mergeCode0Props ( `alert alert--${ color } ` , rest ) } >
31+ { icons [ color ] }
32+ { children }
33+ </ div >
34+ }
Original file line number Diff line number Diff line change 1+ export * from "./components/alert/Alert"
12export * from "./components/avatar/Avatar"
23export * from "./components/badge/Badge"
34export * from "./components/breadcrumb/Breadcrumb"
You can’t perform that action at this time.
0 commit comments