0.8.10 • Published 22 days ago

@synerise/ds-alert v0.8.10

Weekly downloads
187
License
ISC
Repository
github
Last release
22 days ago

id: alert

title: Alert

Alert UI Component

Installation

npm i @synerise/ds-alert
or
yarn add @synerise/ds-alert

Usage

import Alert from '@synerise/ds-alert'

<Alert 
    mode="background-outline"
    showIcon
    type="success"
    message="Success!"
    description="Success description"
    showMoreLabel="Show more"
    onShowMore={() => {}}
/>

Notifications

Notifications API offer three things:

  • <Notification/> component for styled content,
  • notificationApi.useNotification() for building a tunnel for the the right ContextApi (notifications use both React.createPortal plus they are mounted in container mounted in document.body for making it possible to position them correctly),
    • Pro-users: change getContainer for sending notifications in other scrollable sections (@synerise/ds-modal, @synerise/ds-section).
  • and notificationOpen for scheduling showing notificaitons.

The simplest notification call

import notificationApi from '@synerise/ds-alert'

notification.open({message: 'Message content'});

Styled notification

import { Notification, notificationApi} from '@synerise/ds-alert'

notificationApi.open({
  duration: 4.5,
  message: <Notification>Message content</Notification>
});

Differently positioned notification

antd-notification is mounted in docuemnt.body by default. In order to style using scoped css - getContainer has to be a styled-components-scoped element, this is done in mountInstance, see source code for more.

import { Notification, notificationApi, notificationOpen } from '@synerise/ds-alert';

const [api, contextHolder] = notificationApi.useNotification();
notificationOpen({
  message: <Notification>You have new message.</Notification>,
  placement: 'topLeft'
}, api, contextHolder);

Usage recommendations

It is recommended to call notificationOpen from React.useEffect. Of course you can mount styled <Notification/> component by yourself, but then you need to manage its rendering lifecycle.

Demo

API

PropertyDescriptionTypeDefault
afterCloseCalled when close animation is finished() => void-
closableWhether Alert can be closedboolean-
closeTextClose text to showstring\ ReactNode-
descriptionAdditional content of Alertstring\ ReactNode-
iconCustom icon, effective when showIcon is trueReactNode-
messageContent of Alertstring\ ReactNode-
showIconWhether to show iconbooleanfalse
typeType of Alert styles, options: success, info, warning, errorstringinfo
onCloseCallback when Alert is closed(e: MouseEvent) => void-
modeWhether to render alert with outline, background, or transparent, options: background, background-outline, outline, clearstringbackground
colorSet the color that overrides the standard color of alert, options: blue, grey, green, yellow, red, pink, mars, orange, fern, cyan, purple, violetstring

Alert.InlineAlert

PropertyDescriptionTypeDefault
typeType of InlineAlert, options: success, alert, warningstringwarning
messageMessage of alertstring \ React.ReactNode-

Alert.SectionMessage

PropertyDescriptionTypeDefault
typeType of SectionMessage, options: notice, negative, positive,neutral,supply,service,entitystringnegative
messageMessage of section messsageReact.ReactNode-
customColortype of colors,options:red, blue, green,yellow,grey,purple,violet, cyan,fern,orange, mars,pinkstring-
customColorIcontype of colors,options:red, blue, green,yellow,grey,purple,violet, cyan,fern,orange, mars,pinkstring-
colortype of colors,options: red, green,yellow,grey,purple,violet, cyanstring-
modetype of modes, options: background, background-outline,outline,clearstring-
showMoreLabelprop to show labelReact.ReactNode-
onShowMorecallback executed after clickingvoid-
newClientprop to show buttonReact.ReactNode/boolean-
moreButtonsprop to show buttonsReact.ReactNode/boolean-
withEmphasisprop to show bolder textReact.ReactNode-
withLinkprop to show highlited textReact.ReactNode-
unorderedListprop to show unordered listReact.ReactNode-
withCloseprop to show close buttonReact.ReactNode-
customIconprop to set custom iconReact.ReactNode-
textButtontext for buttonstring-

Alert.AlertSemanticColor

PropertyDescriptionTypeDefault
typeType of AlertSemanticColor, options: notice, negative, positive,informative,neutral,supply,service,entitystringpositive
colortype of colors,options: red, green,yellow,grey,purple,violet, cyan,bluestring-
modetype of modes, options: background, background-outline,outline,shadowstring-

Alert.IconAlert

PropertyDescriptionTypeDefault
typeType of Alert styles, options: success, info, warning, errorstringwarning
messageMessage of Icon AlertReact.ReactNode-
disabledprop to set disabled iconboolean-
withEmphasisprop to show bolder textReact.ReactNode-
withLinkprop to show highlited textReact.ReactNode-
iconAlertprop to set custom iconboolean-
hoverButtonprop to set hover state buttonboolean-
customIconprop to set custom iconReact.ReactNode-

Alert.Toast

PropertyDescriptionTypeDefault
typeType of Alert styles, options: success, info, warning, errorstringwarning
messageMessage of Icon AlertReact.ReactNode-
buttonprop to set buttonReact.ReactNode-
expandedprop to set show expanded contentboolean-
onExpandprop on click to show contentisExpanded:boolean => void-
customColortype of colors,options:red, blue, green,yellow,grey,purple,violet, cyan,fern,orange, mars,pinkstring-
customColorIcontype of colors,options:red, blue, green,yellow,grey,purple,violet, cyan,fern,orange, mars,pinkstring-
colortype of colors,options: red, green,yellow,grey,bluestring-
colorIcontype of colors,options: white, black,yellow,grey,bluestring-
customColorTexttype of colors,options:red, blue, green,yellow,grey,purple,violet, cyan,fern,orange, mars,pinkstring-
withCloseprop to show close buttonReact.ReactNode-
customIconprop to set custom iconReact.ReactNode-
expanderprop to set expanded iconReact.ReactNode-
expanderContentprop to set custom iconReact.ReactNode-
onCloseClickCallback when Toast is closed(e: MouseEvent) => void-
showprop to show Toastboolean-

Alert.BroadcastBar

PropertyDescriptionTypeDefault
typeType of Alert styles, options: success, warning, negativestringwarning
colortype of colors,options: red, green,yellowstring-
onCloseClickprop to close broadcastBarvoid-
withEmphasisprop to show bolder textReact.ReactNode-
withLinkprop to show highlited textReact.ReactNode-
withCloseprop to set closeIconReact.ReactNode-
buttonprop to set buttonboolean-
textButtonstring of buttonstring-
textstring of withEmphasis or withLinkstring-

Alert.Notification

PropertyDescriptionTypeDefault
childrenContent of the notificationstring\/React.ReactNode\/JSX.ElementJSX.Element
typetype of the notification, "info"/"success", see antd-notification, info by defaultkeyof NotificationInstance"info"
placementwhere to position the notification'bottomLeft' 'bottomRight' 'topLeft' 'topRight' 'bottom'"bottom"
onClose?Handler for clicking on the close button (close button is rendered only if this prop is provided)() => void-
buttonText?Text on the action buttonstring-
onButtonClick?Handler for onClick on the action button() => void-
icon?Icon on the action buttonDSIcon-
closeIconClassName?Class of the close icon namestring"ds-close-icon"
0.8.10

22 days ago

0.8.9

1 month ago

0.8.8

1 month ago

0.8.7

2 months ago

0.8.6

2 months ago

0.8.5

3 months ago

0.8.4

3 months ago

0.8.3

3 months ago

0.8.2

4 months ago

0.8.1

4 months ago

0.8.0

5 months ago

0.7.51

5 months ago

0.7.50

5 months ago

0.7.37

9 months ago

0.7.36

10 months ago

0.7.39

9 months ago

0.7.38

9 months ago

0.7.44

7 months ago

0.7.43

7 months ago

0.7.46

7 months ago

0.7.45

7 months ago

0.7.40

8 months ago

0.7.42

8 months ago

0.7.41

8 months ago

0.7.48

6 months ago

0.7.47

7 months ago

0.7.49

6 months ago

0.7.35

10 months ago

0.7.34

11 months ago

0.7.33

12 months ago

0.7.32

12 months ago

0.7.31

12 months ago

0.7.30

1 year ago

0.7.29

1 year ago

0.7.28

1 year ago

0.7.27

1 year ago

0.7.24

1 year ago

0.7.26

1 year ago

0.7.25

1 year ago

0.7.22

1 year ago

0.7.21

1 year ago

0.7.20

1 year ago

0.7.19

1 year ago

0.7.18

1 year ago

0.7.15

2 years ago

0.7.17

1 year ago

0.7.16

1 year ago

0.7.11

2 years ago

0.7.10

2 years ago

0.7.13

2 years ago

0.7.14

2 years ago

0.7.9

2 years ago

0.7.8

2 years ago

0.7.2

2 years ago

0.7.6

2 years ago

0.7.5

2 years ago

0.7.7

2 years ago

0.7.1

2 years ago

0.7.0

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.3.25

3 years ago

0.3.24

3 years ago

0.3.23

3 years ago

0.3.22

3 years ago

0.3.21

3 years ago

0.3.20

3 years ago

0.3.19

3 years ago

0.3.18

3 years ago

0.3.17

3 years ago

0.3.16

3 years ago

0.3.15

3 years ago

0.3.14

3 years ago

0.3.13

3 years ago

0.3.12

3 years ago

0.3.11

3 years ago

0.3.10

3 years ago

0.3.9

3 years ago

0.3.8

3 years ago

0.3.7

3 years ago

0.3.6

3 years ago

0.3.3

3 years ago

0.2.24

3 years ago

0.3.0

3 years ago

0.3.1

3 years ago

0.2.23

3 years ago

0.2.22

3 years ago

0.2.21

3 years ago

0.2.20

3 years ago

0.2.19

3 years ago

0.2.18

3 years ago

0.2.17

3 years ago

0.2.16

3 years ago

0.2.15

3 years ago

0.2.14

3 years ago

0.2.13

3 years ago

0.2.12

3 years ago

0.2.11

3 years ago

0.2.10

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.41

3 years ago

0.1.40

3 years ago

0.1.39

3 years ago

0.1.38

3 years ago

0.1.37

3 years ago

0.1.36

3 years ago

0.1.35

4 years ago

0.1.34

4 years ago

0.1.31

4 years ago

0.1.32

4 years ago

0.1.33

4 years ago

0.1.30

4 years ago

0.1.29

4 years ago

0.1.28

4 years ago

0.1.26

4 years ago

0.1.25

4 years ago

0.1.24

4 years ago

0.1.23

4 years ago

0.1.22

4 years ago

0.1.21

4 years ago

0.1.20

4 years ago

0.1.19

4 years ago

0.1.18

4 years ago

0.1.17

4 years ago

0.1.16

4 years ago

0.1.15

4 years ago

0.1.14

4 years ago

0.1.13

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.1

4 years ago