import React from 'react';
-import { Motion, spring } from 'react-motion';
+import Motion from 'react-motion/lib/Motion';
+import spring from 'react-motion/lib/spring';
import PropTypes from 'prop-types';
const Collapsable = ({ fullHeight, isVisible, children }) => (
</div>
<div className='column-collapsable__content' style={{ height: `${fullHeight}px` }}>
- {children}
+ {!collapsed && children}
</div>
</div>
);
};
state = {
- direction: 'left'
+ direction: 'left',
+ expanded: false,
};
setRef = (c) => {
this.dropdown.hide();
}
+ handleShow = () => this.setState({ expanded: true })
+
+ handleHide = () => this.setState({ expanded: false })
+
renderItem = (item, i) => {
if (item === null) {
return <li key={ 'sep' + i } className='dropdown__sep' />;
render () {
const { icon, items, size, direction, ariaLabel } = this.props;
+ const { expanded } = this.state;
const directionClass = (direction === "left") ? "dropdown__left" : "dropdown__right";
+ const dropdownItems = expanded && (
+ <ul className='dropdown__content-list'>
+ {items.map(this.renderItem)}
+ </ul>
+ );
+
return (
- <Dropdown ref={this.setRef}>
+ <Dropdown ref={this.setRef} onShow={this.handleShow} onHide={this.handleHide}>
<DropdownTrigger className='icon-button' style={{ fontSize: `${size}px`, width: `${size}px`, lineHeight: `${size}px` }} aria-label={ariaLabel}>
<i className={ `fa fa-fw fa-${icon} dropdown__icon` } aria-hidden={true} />
</DropdownTrigger>
<DropdownContent className={directionClass}>
- <ul className='dropdown__content-list'>
- {items.map(this.renderItem)}
- </ul>
+ {dropdownItems}
</DropdownContent>
</Dropdown>
);
import React from 'react';
-import { Motion, spring } from 'react-motion';
+import Motion from 'react-motion/lib/Motion';
+import spring from 'react-motion/lib/spring';
import PropTypes from 'prop-types';
class IconButton extends React.PureComponent {
}
componentDidUpdate (prevProps) {
- if (this.node.scrollTop > 0 && (prevProps.statusIds.size < this.props.statusIds.size && prevProps.statusIds.first() !== this.props.statusIds.first() && !!this._oldScrollPosition)) {
+ if ((prevProps.statusIds.size < this.props.statusIds.size && prevProps.statusIds.first() !== this.props.statusIds.first() && !!this._oldScrollPosition) && this.node.scrollTop > 0) {
this.node.scrollTop = this.node.scrollHeight - this._oldScrollPosition;
}
}
import escapeTextContentForBrowser from 'escape-html';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import IconButton from '../../../components/icon_button';
-import { Motion, spring } from 'react-motion';
+import Motion from 'react-motion/lib/Motion';
+import spring from 'react-motion/lib/spring';
import { connect } from 'react-redux';
import ImmutablePureComponent from 'react-immutable-pure-component';
<div ref={this.setRef} className={`privacy-dropdown ${open ? 'active' : ''}`}>
<div className='privacy-dropdown__value'><IconButton className='privacy-dropdown__value-icon' icon={valueOption.icon} title={intl.formatMessage(messages.change_privacy)} size={18} active={open} inverted onClick={this.handleToggle} style={iconStyle}/></div>
<div className='privacy-dropdown__dropdown'>
- {options.map(item =>
+ {open && options.map(item =>
<div role='button' tabIndex='0' key={item.value} data-index={item.value} onClick={this.handleClick} className={`privacy-dropdown__option ${item.value === value ? 'active' : ''}`}>
<div className='privacy-dropdown__option__icon'><i className={`fa fa-fw fa-${item.icon}`} /></div>
<div className='privacy-dropdown__option__content'>
import IconButton from '../../../components/icon_button';
import { defineMessages, injectIntl } from 'react-intl';
import UploadProgressContainer from '../containers/upload_progress_container';
-import { Motion, spring } from 'react-motion';
+import Motion from 'react-motion/lib/Motion';
+import spring from 'react-motion/lib/spring';
const messages = defineMessages({
undo: { id: 'upload_form.undo', defaultMessage: 'Undo' }
import React from 'react';
import PropTypes from 'prop-types';
-import { Motion, spring } from 'react-motion';
+import Motion from 'react-motion/lib/Motion';
+import spring from 'react-motion/lib/spring';
import { FormattedMessage } from 'react-intl';
class UploadProgress extends React.PureComponent {
import PropTypes from 'prop-types';
import TextIconButton from '../components/text_icon_button';
import { changeComposeSensitivity } from '../../../actions/compose';
-import { Motion, spring } from 'react-motion';
+import Motion from 'react-motion/lib/Motion';
+import spring from 'react-motion/lib/spring';
import { injectIntl, defineMessages } from 'react-intl';
const messages = defineMessages({
import Link from 'react-router/lib/Link';
import { injectIntl, defineMessages } from 'react-intl';
import SearchContainer from './containers/search_container';
-import { Motion, spring } from 'react-motion';
+import Motion from 'react-motion/lib/Motion';
+import spring from 'react-motion/lib/spring';
import SearchResultsContainer from './containers/search_results_container';
const messages = defineMessages({
import VideoModal from './video_modal';
import BoostModal from './boost_modal';
import ConfirmationModal from './confirmation_modal';
-import { TransitionMotion, spring } from 'react-motion';
+import TransitionMotion from 'react-motion/lib/TransitionMotion';
+import spring from 'react-motion/lib/spring';
const MODAL_COMPONENTS = {
'MEDIA': MediaModal,
import ImmutablePropTypes from 'react-immutable-proptypes';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import Permalink from '../../../components/permalink';
-import { TransitionMotion, spring } from 'react-motion';
+import TransitionMotion from 'react-motion/lib/TransitionMotion';
+import spring from 'react-motion/lib/spring';
import ComposeForm from '../../compose/components/compose_form';
import Search from '../../compose/components/search';
import NavigationBar from '../../compose/components/navigation_bar';
import React from 'react';
import PropTypes from 'prop-types';
-import { Motion, spring } from 'react-motion';
+import Motion from 'react-motion/lib/Motion';
+import spring from 'react-motion/lib/spring';
import { FormattedMessage } from 'react-intl';
class UploadArea extends React.PureComponent {
expect(wrapper.find(DropdownTrigger).find('i')).to.have.className(`fa-${icon}`)
});
- it('renders list elements for each props.items', () => {
+ it('is not expanded by default', () => {
+ expect(wrapper.state('expanded')).to.be.equal(false);
+ })
+
+ it('does not render the list elements if not expanded', () => {
+ const lis = wrapper.find(DropdownContent).find('li');
+ expect(lis.length).to.be.equal(0);
+ })
+
+ it('sets expanded to true when clicking the trigger', () => {
+ const wrapper = mount(<DropdownMenu icon={icon} items={items} size={size} />);
+ wrapper.find(DropdownTrigger).first().simulate('click');
+ expect(wrapper.state('expanded')).to.be.equal(true);
+ })
+
+ // Error: ReactWrapper::state() can only be called on the root
+ /*it('sets expanded to false when clicking outside', () => {
+ const wrapper = mount((
+ <div>
+ <DropdownMenu icon={icon} items={items} size={size} />
+ <span />
+ </div>
+ ));
+
+ wrapper.find(DropdownTrigger).first().simulate('click');
+ expect(wrapper.find(DropdownMenu).first().state('expanded')).to.be.equal(true);
+
+ wrapper.find('span').first().simulate('click');
+ expect(wrapper.find(DropdownMenu).first().state('expanded')).to.be.equal(false);
+ })*/
+
+ it('renders list elements for each props.items if expanded', () => {
+ const wrapper = mount(<DropdownMenu icon={icon} items={items} size={size} />);
+ wrapper.find(DropdownTrigger).first().simulate('click');
const lis = wrapper.find(DropdownContent).find('li');
expect(lis.length).to.be.equal(items.length);
});
it('uses the action passed in via props.items as click handler', () => {
const wrapper = mount(<DropdownMenu icon={icon} items={items} size={size} />);
-
+ wrapper.find(DropdownTrigger).first().simulate('click');
wrapper.find(DropdownContent).find('li a').first().simulate('click');
expect(action.calledOnce).to.equal(true);
});