parent
7317b7b231
commit
358e3a4c32
|
@ -1,22 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import Motion from 'flavours/glitch/util/optional_motion';
|
|
||||||
import spring from 'react-motion/lib/spring';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
const Collapsable = ({ fullHeight, isVisible, children }) => (
|
|
||||||
<Motion defaultStyle={{ opacity: !isVisible ? 0 : 100, height: isVisible ? fullHeight : 0 }} style={{ opacity: spring(!isVisible ? 0 : 100), height: spring(!isVisible ? 0 : fullHeight) }}>
|
|
||||||
{({ opacity, height }) =>
|
|
||||||
(<div style={{ height: `${height}px`, overflow: 'hidden', opacity: opacity / 100, display: Math.floor(opacity) === 0 ? 'none' : 'block' }}>
|
|
||||||
{children}
|
|
||||||
</div>)
|
|
||||||
}
|
|
||||||
</Motion>
|
|
||||||
);
|
|
||||||
|
|
||||||
Collapsable.propTypes = {
|
|
||||||
fullHeight: PropTypes.number.isRequired,
|
|
||||||
isVisible: PropTypes.bool.isRequired,
|
|
||||||
children: PropTypes.node.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Collapsable;
|
|
|
@ -3,9 +3,6 @@ import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { defineMessages, FormattedMessage } from 'react-intl';
|
import { defineMessages, FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
// Components.
|
|
||||||
import Collapsable from 'flavours/glitch/components/collapsable';
|
|
||||||
|
|
||||||
// Utils.
|
// Utils.
|
||||||
import {
|
import {
|
||||||
assignHandlers,
|
assignHandlers,
|
||||||
|
@ -59,11 +56,8 @@ export default class ComposerSpoiler extends React.PureComponent {
|
||||||
|
|
||||||
// The result.
|
// The result.
|
||||||
return (
|
return (
|
||||||
<Collapsable
|
<div className={`composer--spoiler ${hidden ? '' : 'composer--spoiler--visible'}`}>
|
||||||
isVisible={!hidden}
|
<label>
|
||||||
fullHeight={50}
|
|
||||||
>
|
|
||||||
<label className='composer--spoiler'>
|
|
||||||
<span {...hiddenComponent}>
|
<span {...hiddenComponent}>
|
||||||
<FormattedMessage {...messages.placeholder} />
|
<FormattedMessage {...messages.placeholder} />
|
||||||
</span>
|
</span>
|
||||||
|
@ -76,7 +70,7 @@ export default class ComposerSpoiler extends React.PureComponent {
|
||||||
value={text}
|
value={text}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
</Collapsable>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,20 @@
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.no-reduce-motion .composer--spoiler {
|
||||||
|
transition: height 0.4s ease, opacity 0.4s ease;
|
||||||
|
}
|
||||||
|
|
||||||
.composer--spoiler {
|
.composer--spoiler {
|
||||||
|
height: 0;
|
||||||
|
transform-origin: bottom;
|
||||||
|
opacity: 0.0;
|
||||||
|
|
||||||
|
&.composer--spoiler--visible {
|
||||||
|
height: 47px;
|
||||||
|
opacity: 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
input {
|
input {
|
||||||
display: block;
|
display: block;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
Loading…
Reference in New Issue