File tree Expand file tree Collapse file tree 5 files changed +65
-4
lines changed
Expand file tree Collapse file tree 5 files changed +65
-4
lines changed Original file line number Diff line number Diff line change 3030 ],
3131 "dependencies" : {
3232 "focus-trap-react" : " ^3.0.3" ,
33- "nebula-components" : " ^0.4.1 " ,
33+ "nebula-components" : " ^0.4.3 " ,
3434 "nebula-css" : " ^2.7.1" ,
3535 "no-scroll" : " ^2.1.0"
3636 },
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import { mount } from 'enzyme'
3+
4+ import { NAMESPACE } from '../../../constants'
5+ import { FadeIn } from '../'
6+
7+ describe ( '<FadeIn />' , ( ) => {
8+ it ( 'adds a class once mounted' , ( ) => {
9+ jest . useFakeTimers ( )
10+ const $ = mount (
11+ < FadeIn >
12+ < div className = "test" > _</ div >
13+ </ FadeIn >
14+ )
15+
16+ expect ( $ . hasClass ( 'test' ) ) . toBe ( true )
17+ expect ( $ . hasClass ( `${ NAMESPACE } c-fade-in` ) ) . toBe ( true )
18+ expect ( $ . hasClass ( `${ NAMESPACE } c-fade-in--has-mounted` ) ) . toBe ( false )
19+
20+ jest . runAllTimers ( )
21+ expect ( $ . hasClass ( `${ NAMESPACE } c-fade-in--has-mounted` ) ) . toBe ( true )
22+ } )
23+ } )
Original file line number Diff line number Diff line change 1+ import React , { Component } from 'react'
2+ import T from 'prop-types'
3+
4+ import { NAMESPACE } from '../../constants'
5+ import { classNames } from '../../utils'
6+
7+ class FadeIn extends Component {
8+ state = {
9+ hasMounted : false
10+ }
11+
12+ componentDidMount ( ) {
13+ setTimeout ( ( ) => {
14+ this . setState ( { hasMounted : true } )
15+ } , 0 )
16+ }
17+
18+ render ( ) {
19+ // eslint-disable-next-line react/prop-types
20+ const { children, ...rest } = this . props
21+ return React . cloneElement ( this . props . children , {
22+ className : classNames (
23+ children . props . className ,
24+ ` ${ NAMESPACE } c-fade-in` ,
25+ { [ `${ NAMESPACE } c-fade-in--has-mounted` ] : this . state . hasMounted }
26+ ) ,
27+ ...rest
28+ } )
29+ }
30+ }
31+
32+ FadeIn . propTypes = {
33+ children : T . node . isRequired
34+ }
35+
36+ export { FadeIn }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { Button } from './components/Button/'
1111import { ButtonDropdown } from './components/ButtonDropdown/'
1212import { Card } from './components/Card/'
1313import { ClickOutside } from './components/ClickOutside/'
14+ import { FadeIn } from './components/FadeIn'
1415import { Flyout } from './components/Flyout/'
1516import { Foldable } from './components/Foldable/'
1617import { Form } from './components/Form/'
@@ -35,6 +36,7 @@ export {
3536 Button ,
3637 ButtonDropdown ,
3738 Card ,
39+ FadeIn ,
3840 Flag ,
3941 Flyout ,
4042 Form ,
Original file line number Diff line number Diff line change @@ -2965,9 +2965,9 @@ natural-compare@^1.4.0:
29652965 version "1.4.0"
29662966 resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
29672967
2968- nebula-components@^0.3.0 :
2969- version "0.3.0 "
2970- resolved "https://registry.yarnpkg.com/nebula-components/-/nebula-components-0.3.0. tgz#4defcd55d2762d39d05579f9034a208726908866 "
2968+ nebula-components@^0.4.3 :
2969+ version "0.4.3 "
2970+ resolved "https://registry.yarnpkg.com/nebula-components/-/nebula-components-0.4.3. tgz#fd90968148df9ae5213c8937b91149901693d009 "
29712971 dependencies :
29722972 nebula-css "^2.7.1"
29732973
You can’t perform that action at this time.
0 commit comments