Skip to content

Commit

Permalink
Merge pull request #32 from sirbrillig/add/vanisher
Browse files Browse the repository at this point in the history
Add `Vanisher` component to animate alert transitions
  • Loading branch information
sirbrillig authored Sep 10, 2017
2 parents aa0afb1 + c68a3d3 commit 8ec1424
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
5 changes: 3 additions & 2 deletions components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const LastChecked = require( '../components/last-checked' );
const OfflineNotice = require( '../components/offline-notice' );
const FetchingInProgress = require( '../components/fetching-in-progress' );
const createUpdater = require( '../components/updater' );
const Vanisher = require( '../components/vanisher' );
const UpdatingLastChecked = createUpdater( LastChecked );
const UpdatingOfflineNotice = createUpdater( OfflineNotice );

Expand Down Expand Up @@ -33,8 +34,8 @@ function Header( { openUrl, lastSuccessfulCheck, lastChecked, fetchInterval, sho
el( 'div', { className: 'header__secondary' },
lastSuccessfulCheck && el( UpdatingLastChecked, { lastSuccessfulCheck } )
),
offline && el( UpdatingOfflineNotice, { fetchNotifications, lastChecked, fetchInterval } ),
fetchingInProgress && el( FetchingInProgress )
el( Vanisher, { isVisible: offline }, el( UpdatingOfflineNotice, { fetchNotifications, lastChecked, fetchInterval } ) ),
el( Vanisher, { isVisible: fetchingInProgress }, el( FetchingInProgress ) )
);
}

Expand Down
9 changes: 9 additions & 0 deletions components/vanisher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const React = require( 'react' );
const el = React.createElement;

function Vanisher( { isVisible, children } ) {
const className = isVisible ? 'vanisher vanisher--visible' : 'vanisher vanisher--invisible';
return el( 'div', { className }, children );
}

module.exports = Vanisher;
16 changes: 16 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,22 @@
width: 100%;
height: 100%;
}

.vanisher {
width: 100%;
overflow: hidden;
transition: max-height 1s;
}

.vanisher--visible {
max-height: 300px;
transition: max-height 1s;
}

.vanisher--invisible {
max-height: 0;
transition: max-height 1s;
}
</style>
</head>
<body>
Expand Down

0 comments on commit 8ec1424

Please sign in to comment.