forked from treehouse/mastodon
Make .column-collapse animation simple (#3086)
* Always set `overflow: auto` to allow scroll just after opening * Remove bounce animation which may cause unintended behavior due to max-height * Use CSS transition instead of react-motion * Some CSS refactoring including className changingsignup-info-prompt
parent
9bddb946f0
commit
3722f90865
|
@ -1,5 +1,4 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Motion, spring } from 'react-motion';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
class ColumnCollapsable extends React.PureComponent {
|
class ColumnCollapsable extends React.PureComponent {
|
||||||
|
@ -29,21 +28,16 @@ class ColumnCollapsable extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const { icon, title, fullHeight, children } = this.props;
|
const { icon, title, fullHeight, children } = this.props;
|
||||||
const { collapsed } = this.state;
|
const { collapsed } = this.state;
|
||||||
const collapsedClassName = collapsed ? 'collapsable-collapsed' : 'collapsable';
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='column-collapsable'>
|
<div className={`column-collapsable ${collapsed ? 'collapsed' : ''}`}>
|
||||||
<div role='button' tabIndex='0' title={`${title}`} className={`column-icon ${collapsedClassName}`} onClick={this.handleToggleCollapsed}>
|
<div role='button' tabIndex='0' title={`${title}`} className='column-collapsable__button column-icon' onClick={this.handleToggleCollapsed}>
|
||||||
<i className={`fa fa-${icon}`} />
|
<i className={`fa fa-${icon}`} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Motion defaultStyle={{ opacity: 0, height: 0 }} style={{ opacity: spring(collapsed ? 0 : 100), height: spring(collapsed ? 0 : fullHeight, collapsed ? undefined : { stiffness: 150, damping: 9 }) }}>
|
<div className='column-collapsable__content' style={{ height: `${fullHeight}px`, maxHeight: '70vh' }}>
|
||||||
{({ opacity, height }) =>
|
{children}
|
||||||
<div style={{ overflow: height === fullHeight ? 'auto' : 'hidden', height: `${height}px`, opacity: opacity / 100, maxHeight: '70vh' }}>
|
</div>
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</Motion>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,32 @@
|
||||||
|
|
||||||
.column-collapsable {
|
.column-collapsable {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
.column-collapsable__content {
|
||||||
|
overflow: auto;
|
||||||
|
transition: 300ms ease;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.collapsed .column-collapsable__content {
|
||||||
|
height: 0 !important;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.column-collapsable__button {
|
||||||
|
color: $primary-text-color;
|
||||||
|
background: lighten($ui-base-color, 8%);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: $primary-text-color;
|
||||||
|
background: lighten($ui-base-color, 8%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.collapsed .column-collapsable__button {
|
||||||
|
color: $ui-primary-color;
|
||||||
|
background: lighten($ui-base-color, 4%);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.column-icon {
|
.column-icon {
|
||||||
|
@ -1984,21 +2010,6 @@ button.icon-button.active i.fa-retweet {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.collapsable-collapsed {
|
|
||||||
color: $ui-primary-color;
|
|
||||||
background: lighten($ui-base-color, 4%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.collapsable {
|
|
||||||
color: $primary-text-color;
|
|
||||||
background: lighten($ui-base-color, 8%);
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: $primary-text-color;
|
|
||||||
background: lighten($ui-base-color, 8%);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-error-cover {
|
.video-error-cover {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: $base-overlay-background;
|
background: $base-overlay-background;
|
||||||
|
|
Loading…
Reference in New Issue