Skip to content

Commit

Permalink
refactor(Transition): transitionAppear -> transitionOnShow
Browse files Browse the repository at this point in the history
  • Loading branch information
levithomason committed Jul 26, 2017
1 parent f2224e4 commit a242223
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/modules/Transition/Transition.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface TransitionProps {
reactKey?: string;

/** Run the enter animation when the component mounts, if it is initially shown. */
transitionAppear?: boolean;
transitionOnShow?: boolean;

/** Unmount the component (remove it from the DOM) when it is not shown. */
unmountOnHide?: boolean;
Expand Down
8 changes: 4 additions & 4 deletions src/modules/Transition/Transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class Transition extends Component {
reactKey: PropTypes.string,

/** Run the enter animation when the component mounts, if it is initially shown. */
transitionAppear: PropTypes.bool,
transitionOnShow: PropTypes.bool,

/** Unmount the component (remove it from the DOM) when it is not shown. */
unmountOnHide: PropTypes.bool,
Expand All @@ -80,7 +80,7 @@ export default class Transition extends Component {
duration: 500,
visible: true,
mountOnShow: true,
transitionAppear: false,
transitionOnShow: false,
unmountOnHide: false,
}

Expand Down Expand Up @@ -219,12 +219,12 @@ export default class Transition extends Component {
const {
visible,
mountOnShow,
transitionAppear,
transitionOnShow,
unmountOnHide,
} = this.props

if (visible) {
if (transitionAppear) {
if (transitionOnShow) {
return {
initial: Transition.EXITED,
next: Transition.ENTERING,
Expand Down
8 changes: 4 additions & 4 deletions src/modules/Transition/TransitionGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ export default class TransitionGroup extends React.Component {
}

// item hasn't changed transition states, copy over the last transition props;
const { props: { visible, transitionAppear } } = prevChild
const { props: { visible, transitionOnShow } } = prevChild

children[key] = cloneElement(child, { visible, transitionAppear })
children[key] = cloneElement(child, { visible, transitionOnShow })
})

this.setState({ children })
Expand All @@ -98,7 +98,7 @@ export default class TransitionGroup extends React.Component {
})
}

wrapChild = (child, transitionAppear = false) => {
wrapChild = (child, transitionOnShow = false) => {
const { animation, duration } = this.props
const { key } = child

Expand All @@ -110,7 +110,7 @@ export default class TransitionGroup extends React.Component {
key={key}
onHide={this.handleOnHide}
reactKey={key}
transitionAppear={transitionAppear}
transitionOnShow={transitionOnShow}
/>
)
}
Expand Down
34 changes: 17 additions & 17 deletions test/specs/modules/Transition/Transition-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Transition', () => {
SUI.DIRECTIONAL_TRANSITIONS.forEach(animation => {
it(`directional ${animation}`, () => {
wrapperShallow(
<Transition animation={animation} transitionAppear={false}>
<Transition animation={animation} transitionOnShow={false}>
<p />
</Transition>
)
Expand All @@ -45,7 +45,7 @@ describe('Transition', () => {
SUI.STATIC_TRANSITIONS.forEach(animation => {
it(`static ${animation}`, () => {
wrapperShallow(
<Transition animation={animation} transitionAppear={false}>
<Transition animation={animation} transitionOnShow={false}>
<p />
</Transition>
)
Expand Down Expand Up @@ -74,14 +74,14 @@ describe('Transition', () => {
})

it('adds classes when ENTERED', () => {
wrapperShallow(<Transition transitionAppear={false}><p /></Transition>)
wrapperShallow(<Transition transitionOnShow={false}><p /></Transition>)

wrapper.should.have.className('visible')
wrapper.should.have.className('transition')
})

it('adds classes when ENTERING', () => {
wrapperShallow(<Transition transitionAppear={false}><p /></Transition>)
wrapperShallow(<Transition transitionOnShow={false}><p /></Transition>)
wrapper.setState({ animating: true, status: Transition.ENTERING })

wrapper.should.have.className('animating')
Expand All @@ -98,7 +98,7 @@ describe('Transition', () => {
})

it('adds classes when EXITING', () => {
wrapperShallow(<Transition transitionAppear={false}><p /></Transition>)
wrapperShallow(<Transition transitionOnShow={false}><p /></Transition>)
wrapper.setState({ animating: true, status: Transition.EXITING })

wrapper.should.have.className('animating')
Expand Down Expand Up @@ -179,7 +179,7 @@ describe('Transition', () => {

describe('visible', () => {
it('updates status when set to false while ENTERING', () => {
wrapperShallow(<Transition transitionAppear={false}><p /></Transition>)
wrapperShallow(<Transition transitionOnShow={false}><p /></Transition>)
wrapper.setState({ status: Transition.ENTERING })
wrapper.setProps({ visible: false })

Expand All @@ -188,7 +188,7 @@ describe('Transition', () => {

it('updates status when set to false while ENTERED', () => {
wrapperShallow(
<Transition transitionAppear={false}>
<Transition transitionOnShow={false}>
<p />
</Transition>
)
Expand All @@ -213,7 +213,7 @@ describe('Transition', () => {
wrapperMount(
<Transition
duration={10}
transitionAppear
transitionOnShow
onHide={done}
>
<p />
Expand Down Expand Up @@ -255,7 +255,7 @@ describe('Transition', () => {
<Transition
duration={0}
onComplete={handleComplete}
transitionAppear
transitionOnShow
>
<p />
</Transition>
Expand All @@ -279,7 +279,7 @@ describe('Transition', () => {
<Transition
duration={0}
onHide={handleHide}
transitionAppear={false}
transitionOnShow={false}
>
<p />
</Transition>
Expand All @@ -304,7 +304,7 @@ describe('Transition', () => {
<Transition
duration={0}
onShow={handleShow}
transitionAppear
transitionOnShow
>
<p />
</Transition>
Expand All @@ -328,7 +328,7 @@ describe('Transition', () => {
<Transition
duration={0}
onStart={handleStart}
transitionAppear
transitionOnShow
>
<p />
</Transition>
Expand All @@ -349,10 +349,10 @@ describe('Transition', () => {
})
})

describe('transitionAppear', () => {
describe('transitionOnShow', () => {
it('sets statuses when is true', () => {
wrapperShallow(
<Transition transitionAppear>
<Transition transitionOnShow>
<p />
</Transition>
)
Expand All @@ -363,7 +363,7 @@ describe('Transition', () => {

it('updates status after mount when is true', () => {
wrapperMount(
<Transition transitionAppear>
<Transition transitionOnShow>
<p />
</Transition>
).should.have.state('status', Transition.ENTERING)
Expand All @@ -381,7 +381,7 @@ describe('Transition', () => {
<Transition
duration={0}
onHide={onHide}
transitionAppear={false}
transitionOnShow={false}
unmountOnHide
>
<p />
Expand All @@ -400,7 +400,7 @@ describe('Transition', () => {
<Transition
duration={5}
onHide={onHide}
transitionAppear={false}
transitionOnShow={false}
unmountOnHide={false}
>
<p />
Expand Down
4 changes: 2 additions & 2 deletions test/specs/modules/Transition/TransitionGroup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('TransitionGroup', () => {
})
})

it('wraps new child to Transition and sets transitionAppear to true', () => {
it('wraps new child to Transition and sets transitionOnShow to true', () => {
wrapperShallow(
<TransitionGroup>
<div key='first' />
Expand All @@ -59,7 +59,7 @@ describe('TransitionGroup', () => {
const child = wrapper.childAt(1)
child.key().should.equal('.$second')
child.type().should.equal(Transition)
child.should.have.prop('transitionAppear', true)
child.should.have.prop('transitionOnShow', true)
})

it('skips invalid children', () => {
Expand Down

0 comments on commit a242223

Please sign in to comment.