This repository was archived by the owner on Jun 17, 2023. It is now read-only.
File tree 4 files changed +71
-2
lines changed
4 files changed +71
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ const AlertDismissExampleSource = require('!!raw!../examples/AlertDismiss');
20
20
import AlertUncontrolledDismissExample from '../examples/AlertUncontrolledDismiss' ;
21
21
const AlertUncontrolledDismissExampleSource = require ( '!!raw!../examples/AlertUncontrolledDismiss' ) ;
22
22
23
+ import { AlertFadelessExample , UncontrolledAlertFadelessExample } from '../examples/AlertFadeless' ;
24
+ const AlertFadelessExampleSource = require ( '!!raw!../examples/AlertFadeless' ) ;
25
+
23
26
export default class AlertsPage extends React . Component {
24
27
render ( ) {
25
28
return (
@@ -93,6 +96,20 @@ export default class AlertsPage extends React.Component {
93
96
{ AlertUncontrolledDismissExampleSource }
94
97
</ PrismCode >
95
98
</ pre >
99
+
100
+ < SectionTitle > Alerts without fade</ SectionTitle >
101
+ < p >
102
+ Fade can be disbaled using < code > fade=false</ code > .
103
+ </ p >
104
+ < div className = "docs-example" >
105
+ < AlertFadelessExample />
106
+ < UncontrolledAlertFadelessExample />
107
+ </ div >
108
+ < pre >
109
+ < PrismCode className = "language-jsx" >
110
+ { AlertFadelessExampleSource }
111
+ </ PrismCode >
112
+ </ pre >
96
113
</ div >
97
114
) ;
98
115
}
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { UncontrolledAlert } from 'reactstrap' ;
3
+ import Alert from '../../../src/Alert' ;
4
+
5
+ export class AlertFadelessExample extends React . Component {
6
+
7
+ constructor ( props ) {
8
+ super ( props ) ;
9
+
10
+ this . state = {
11
+ visible : true
12
+ } ;
13
+
14
+ this . onDismiss = this . onDismiss . bind ( this ) ;
15
+ }
16
+
17
+ onDismiss ( ) {
18
+ this . setState ( { visible : false } ) ;
19
+ }
20
+
21
+ render ( ) {
22
+ return (
23
+ < div >
24
+ < Alert color = "primary" isOpen = { this . state . visible } toggle = { this . onDismiss } fade = { false } >
25
+ I am a primary alert and I can be dismissed without animating!
26
+ </ Alert >
27
+ </ div >
28
+ ) ;
29
+ }
30
+ }
31
+
32
+ export function UncontrolledAlertFadelessExample ( ) {
33
+ return (
34
+ < div >
35
+ < UncontrolledAlert color = "info" fade = { false } >
36
+ I am an alert and I can be dismissed without animating!
37
+ </ UncontrolledAlert >
38
+ </ div >
39
+ ) ;
40
+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ const propTypes = {
11
11
closeAriaLabel : PropTypes . string ,
12
12
cssModule : PropTypes . object ,
13
13
color : PropTypes . string ,
14
+ fade : PropTypes . bool ,
14
15
isOpen : PropTypes . bool ,
15
16
toggle : PropTypes . func ,
16
17
tag : PropTypes . oneOfType ( [ PropTypes . func , PropTypes . string ] ) ,
@@ -22,6 +23,7 @@ const defaultProps = {
22
23
isOpen : true ,
23
24
tag : 'div' ,
24
25
closeAriaLabel : 'Close' ,
26
+ fade : true ,
25
27
transition : {
26
28
...Fade . defaultProps ,
27
29
unmountOnExit : true ,
@@ -40,6 +42,7 @@ function Alert(props) {
40
42
toggle,
41
43
children,
42
44
transition,
45
+ fade,
43
46
...attributes
44
47
} = props ;
45
48
@@ -52,8 +55,15 @@ function Alert(props) {
52
55
53
56
const closeClasses = mapToCssModules ( classNames ( 'close' , closeClassName ) , cssModule ) ;
54
57
58
+ const alertTransition = {
59
+ ...Fade . defaultProps ,
60
+ ...transition ,
61
+ baseClass : fade ? transition . baseClass : '' ,
62
+ timeout : fade ? transition . timeout : 0 ,
63
+ } ;
64
+
55
65
return (
56
- < Fade { ...attributes } { ...transition } tag = { Tag } className = { classes } in = { isOpen } role = "alert" >
66
+ < Fade { ...attributes } { ...alertTransition } tag = { Tag } className = { classes } in = { isOpen } role = "alert" >
57
67
{ toggle ?
58
68
< button type = "button" className = { closeClasses } aria-label = { closeAriaLabel } onClick = { toggle } >
59
69
< span aria-hidden = "true" > ×</ span >
Original file line number Diff line number Diff line change 1
1
import React , { Component } from 'react' ;
2
2
import Alert from './Alert' ;
3
3
4
- export default class UncontrolledAlert extends Component {
4
+ class UncontrolledAlert extends Component {
5
5
constructor ( props ) {
6
6
super ( props ) ;
7
7
@@ -17,3 +17,5 @@ export default class UncontrolledAlert extends Component {
17
17
return < Alert isOpen = { this . state . isOpen } toggle = { this . toggle } { ...this . props } /> ;
18
18
}
19
19
}
20
+
21
+ export default UncontrolledAlert ;
You can’t perform that action at this time.
0 commit comments