-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3072c96
commit f1e61d0
Showing
6 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { StoryBook, useControls, useCreateStore } from '@lobehub/ui'; | ||
import type { AlertProps } from '@yuntijs/ui'; | ||
import { Alert } from '@yuntijs/ui'; | ||
|
||
export default () => { | ||
const store = useCreateStore(); | ||
const control: AlertProps | any = useControls( | ||
{ | ||
message: | ||
'Info Description Info Description Info Description Info Description Info Description Info Description Info Description Info DescriptionInfo Description Info Description Info Description Info DescriptionInfo Description Info Description Info Description Info DescriptionInfo Description Info Description Info Description Info Description', | ||
showIcon: true, | ||
iconPlacement: { | ||
options: ['top', 'center'], | ||
value: 'center', | ||
}, | ||
type: { | ||
options: ['success', 'info', 'warning', 'error'], | ||
value: 'info', | ||
}, | ||
bordered: { | ||
options: ['dashed', 'solid', 'none'], | ||
value: 'dashed', | ||
}, | ||
closable: false, | ||
description: '', | ||
banner: false, | ||
}, | ||
{ store } | ||
); | ||
return ( | ||
<StoryBook levaStore={store}> | ||
<Alert {...control} /> | ||
</StoryBook> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Alert } from '@yuntijs/ui'; | ||
|
||
export default () => { | ||
return ( | ||
<Alert | ||
message="Info Description Info Description Info Description Info Description Info Description Info Description Info Description Info DescriptionInfo Description Info Description Info Description Info DescriptionInfo Description Info Description Info Description Info DescriptionInfo Description Info Description Info Description Info Description" | ||
showIcon | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
nav: Components | ||
group: Feedback | ||
title: Alert | ||
description: Display warning messages that require attention. | ||
--- | ||
|
||
## Usage | ||
|
||
based on antd [Alert](https://ant.design/components/alert-cn/) component. | ||
|
||
### Simple usage | ||
|
||
```jsx | pure | ||
import { Alert } from '@yuntijs/ui'; | ||
|
||
export default () => { | ||
return <Alert message="Info Description" showIcon />; | ||
}; | ||
``` | ||
|
||
<code src="./demos/index.tsx" center></code> | ||
|
||
## Playground | ||
|
||
<code src="./demos/Playground.tsx" nopadding></code> | ||
|
||
## APIs | ||
|
||
<API></API> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Alert as AntdAlert, type AlertProps as AntdAlertProps } from 'antd'; | ||
import React from 'react'; | ||
|
||
import { useStyles } from './style'; | ||
|
||
export interface CustomAlertProps { | ||
/** position of icon */ | ||
iconPlacement?: 'top' | 'center'; | ||
/** border type of Alert */ | ||
bordered?: 'dashed' | 'solid' | 'none'; | ||
} | ||
export interface AlertProps extends AntdAlertProps, CustomAlertProps {} | ||
|
||
type ComposedAlertProps = React.FC<AlertProps> & { | ||
ErrorBoundary: typeof AntdAlert.ErrorBoundary; | ||
}; | ||
|
||
export const Alert: ComposedAlertProps = props => { | ||
const { iconPlacement = 'center', bordered = 'dashed', className, ...otherProps } = props; | ||
|
||
const { styles, cx } = useStyles({ iconPlacement, bordered }); | ||
|
||
return <AntdAlert {...otherProps} className={cx(styles.custom, className)} />; | ||
}; | ||
Alert.ErrorBoundary = AntdAlert.ErrorBoundary; | ||
|
||
export default Alert; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { createStyles } from 'antd-style'; | ||
|
||
import { CustomAlertProps } from './index'; | ||
|
||
export const useStyles = createStyles( | ||
({ css }, { iconPlacement = 'center', bordered = 'dashed' }: CustomAlertProps) => { | ||
return { | ||
custom: css` | ||
border-style: ${bordered} !important; | ||
${iconPlacement === 'center' && | ||
css` | ||
display: flex; | ||
align-items: center; | ||
`} | ||
${iconPlacement === 'top' && | ||
css` | ||
display: flex; | ||
align-items: flex-start !important; | ||
&-icon { | ||
margin-top: 5px; | ||
} | ||
`} | ||
`, | ||
}; | ||
}, | ||
{ hashPriority: 'low' } | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters