Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ position: PropTypes.oneOf([
]) // the position of the alerts in the page
timeout: PropTypes.number // timeout to alert remove itself, if set to 0 it never removes itself
type: PropTypes.oneOf(['info', 'success', 'error']) // the default alert type used when calling this.props.alert.show
transition: PropTypes.oneOf(['fade', 'scale']) // the transition animation
transition: PropTypes.oneOf(['fade', 'scale', 'enter_from_right' 'enter_from_left' 'enter_from_top' 'enter_from_bottom']) // the transition animation
containerStyle: PropTypes.Object // style to be applied in the alerts container
template: PropTypes.oneOfType([PropTypes.element, PropTypes.func]).isRequired // the alert template to be used
```
Expand Down Expand Up @@ -171,7 +171,11 @@ export const types = {

export const transitions = {
FADE: 'fade',
SCALE: 'scale'
SCALE: 'scale',
ENTER_FROM_RIGHT: 'enter_from_right',
ENTER_FROM_LEFT: 'enter_from_left',
ENTER_FROM_TOP: 'enter_from_top',
ENTER_FROM_BOTTOM: 'enter_from_bottom',
}
```

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-alert",
"description": "A simple react alert component",
"version": "7.0.2",
"version": "7.1.0",
"author": "Reinaldo Schiehll <rn.schiehll@gmail.com>",
"main": "dist/cjs/react-alert.js",
"module": "dist/esm/react-alert.js",
Expand All @@ -19,6 +19,7 @@
"react-component"
],
"scripts": {
"prepack": "yarn build",
"build": "node ./scripts/build.js",
"test": "jest --coverage --no-cache",
"test:watch": "jest --watch --coverage --no-cache",
Expand Down
38 changes: 38 additions & 0 deletions src/Transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Transition as AlertTransition } from 'react-transition-group'
import { transitions } from './options'

const duration = 250
const durationFrom = 500

const defaultStyle = {
[transitions.FADE]: {
Expand All @@ -12,6 +13,22 @@ const defaultStyle = {
[transitions.SCALE]: {
transform: 'scale(1)',
transition: `all ${duration}ms ease-in-out`
},
[transitions.ENTER_FROM_RIGHT]: {
transform: 'translateX(0)',
transition: `transform ${durationFrom}ms ease-in-out`
},
[transitions.ENTER_FROM_LEFT]: {
transform: 'translateX(-100%)',
transition: `transform ${durationFrom}ms ease-in-out`
},
[transitions.ENTER_FROM_TOP]: {
transform: 'translateY(-100%)',
transition: `transform ${durationFrom}ms ease-in-out`
},
[transitions.ENTER_FROM_BOTTOM]: {
transform: 'translateY(100%)',
transition: `transform ${durationFrom}ms ease-in-out`
}
}

Expand All @@ -25,6 +42,27 @@ const transitionStyles = {
entered: { transform: 'scale(1)' },
exiting: { transform: 'scale(0)' },
exited: { transform: 'scale(1)' }
},
[transitions.ENTER_FROM_RIGHT]: {
entering: { transform: 'translateX(0)' },
entered: { transform: 'translateX(0)' },
exiting: { transform: 'translateX(100%)' },
exited: { transform: 'translateX(100%)' }
},
[transitions.ENTER_FROM_LEFT]: {
entering: { transform: 'translateX(0)' },
entered: { transform: 'translateX(-100%)' },
exited: { transform: 'translateX(0)' }
},
[transitions.ENTER_FROM_TOP]: {
entering: { transform: 'translateY(0)' },
entered: { transform: 'translateY(-100%)' },
exited: { transform: 'translateY(0)' }
},
[transitions.ENTER_FROM_BOTTOM]: {
entering: { transform: 'translateY(0)' },
entered: { transform: 'translateY(100%)' },
exited: { transform: 'translateY(0)' }
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ export const types = {

export const transitions = {
FADE: 'fade',
SCALE: 'scale'
SCALE: 'scale',
ENTER_FROM_RIGHT: 'enter_from_right',
ENTER_FROM_LEFT: 'enter_from_left',
ENTER_FROM_TOP: 'enter_from_top',
ENTER_FROM_BOTTOM: 'enter_from_bottom'
}