Skip to content

Commit

Permalink
feat: add viewStyle and innerViewWrapperStyle props
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed May 7, 2019
1 parent a36df60 commit c26ae43
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,13 @@ Any extra class names to add to the root element.
##### `style: Object`

Extra inline styles to add to the root element.

##### `viewStyle: Object`

Extra inline styles to add to the view wrapper elements.

##### `innerViewWrapperStyle: Object`

Extra inline styles to add to the inner div between the `viewStyle` div and your
view content element. (The inner div was added to ensure perfect height
animation.)
15 changes: 13 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export type Props = {
sizeTransitionTimingFunction: string,
prefixer: Prefixer,
style: Object,
viewStyle?: ?Object,
innerViewWrapperStyle?: ?Object,
className?: string,
}

Expand Down Expand Up @@ -73,10 +75,16 @@ export default class Fader extends React.Component<Props, State> {
children: any,
transitionState: TransitionState
): React.Element<'div'> => {
const { animateWidth, prefixer } = this.props
const {
animateWidth,
prefixer,
viewStyle,
innerViewWrapperStyle,
} = this.props
const style: Object = {
display: animateWidth ? 'inline-flex' : 'flex',
transitionProperty: 'opacity',
...viewStyle,
}
switch (transitionState) {
case 'out':
Expand All @@ -98,7 +106,10 @@ export default class Fader extends React.Component<Props, State> {
data-transition-state={transitionState}
style={prefixer.prefix(style)}
>
<div style={{ width: '100%' }} ref={c => (this.wrappedChildrenRef = c)}>
<div
style={prefixer.prefix({ width: '100%', ...innerViewWrapperStyle })}
ref={c => (this.wrappedChildrenRef = c)}
>
<TransitionContext state={transitionState}>
{children}
</TransitionContext>
Expand Down

0 comments on commit c26ae43

Please sign in to comment.