parent
							
								
									547a5bac9d
								
							
						
					
					
						commit
						3a929dbedd
					
				@ -1,6 +1,4 @@
 | 
				
			|||||||
import React from 'react';
 | 
					import React from 'react';
 | 
				
			||||||
import Motion from '../features/ui/util/optional_motion';
 | 
					 | 
				
			||||||
import spring from 'react-motion/lib/spring';
 | 
					 | 
				
			||||||
import PropTypes from 'prop-types';
 | 
					import PropTypes from 'prop-types';
 | 
				
			||||||
import classNames from 'classnames';
 | 
					import classNames from 'classnames';
 | 
				
			||||||
import Icon from 'mastodon/components/icon';
 | 
					import Icon from 'mastodon/components/icon';
 | 
				
			||||||
@ -37,6 +35,21 @@ export default class IconButton extends React.PureComponent {
 | 
				
			|||||||
    tabIndex: '0',
 | 
					    tabIndex: '0',
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  state = {
 | 
				
			||||||
 | 
					    activate: false,
 | 
				
			||||||
 | 
					    deactivate: false,
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  componentWillReceiveProps (nextProps) {
 | 
				
			||||||
 | 
					    if (!nextProps.animate) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (this.props.active && !nextProps.active) {
 | 
				
			||||||
 | 
					      this.setState({ activate: false, deactivate: true });
 | 
				
			||||||
 | 
					    } else if (!this.props.active && nextProps.active) {
 | 
				
			||||||
 | 
					      this.setState({ activate: true, deactivate: false });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  handleClick = (e) =>  {
 | 
					  handleClick = (e) =>  {
 | 
				
			||||||
    e.preventDefault();
 | 
					    e.preventDefault();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -75,7 +88,6 @@ export default class IconButton extends React.PureComponent {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    const {
 | 
					    const {
 | 
				
			||||||
      active,
 | 
					      active,
 | 
				
			||||||
      animate,
 | 
					 | 
				
			||||||
      className,
 | 
					      className,
 | 
				
			||||||
      disabled,
 | 
					      disabled,
 | 
				
			||||||
      expanded,
 | 
					      expanded,
 | 
				
			||||||
@ -87,57 +99,37 @@ export default class IconButton extends React.PureComponent {
 | 
				
			|||||||
      title,
 | 
					      title,
 | 
				
			||||||
    } = this.props;
 | 
					    } = this.props;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const {
 | 
				
			||||||
 | 
					      activate,
 | 
				
			||||||
 | 
					      deactivate,
 | 
				
			||||||
 | 
					    } = this.state;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const classes = classNames(className, 'icon-button', {
 | 
					    const classes = classNames(className, 'icon-button', {
 | 
				
			||||||
      active,
 | 
					      active,
 | 
				
			||||||
      disabled,
 | 
					      disabled,
 | 
				
			||||||
      inverted,
 | 
					      inverted,
 | 
				
			||||||
 | 
					      activate,
 | 
				
			||||||
 | 
					      deactivate,
 | 
				
			||||||
      overlayed: overlay,
 | 
					      overlayed: overlay,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!animate) {
 | 
					 | 
				
			||||||
      // Perf optimization: avoid unnecessary <Motion> components unless
 | 
					 | 
				
			||||||
      // we actually need to animate.
 | 
					 | 
				
			||||||
      return (
 | 
					 | 
				
			||||||
        <button
 | 
					 | 
				
			||||||
          aria-label={title}
 | 
					 | 
				
			||||||
          aria-pressed={pressed}
 | 
					 | 
				
			||||||
          aria-expanded={expanded}
 | 
					 | 
				
			||||||
          title={title}
 | 
					 | 
				
			||||||
          className={classes}
 | 
					 | 
				
			||||||
          onClick={this.handleClick}
 | 
					 | 
				
			||||||
          onMouseDown={this.handleMouseDown}
 | 
					 | 
				
			||||||
          onKeyDown={this.handleKeyDown}
 | 
					 | 
				
			||||||
          onKeyPress={this.handleKeyPress}
 | 
					 | 
				
			||||||
          style={style}
 | 
					 | 
				
			||||||
          tabIndex={tabIndex}
 | 
					 | 
				
			||||||
          disabled={disabled}
 | 
					 | 
				
			||||||
        >
 | 
					 | 
				
			||||||
          <Icon id={icon} fixedWidth aria-hidden='true' />
 | 
					 | 
				
			||||||
        </button>
 | 
					 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
      <Motion defaultStyle={{ rotate: active ? -360 : 0 }} style={{ rotate: animate ? spring(active ? -360 : 0, { stiffness: 120, damping: 7 }) : 0 }}>
 | 
					      <button
 | 
				
			||||||
        {({ rotate }) => (
 | 
					        aria-label={title}
 | 
				
			||||||
          <button
 | 
					        aria-pressed={pressed}
 | 
				
			||||||
            aria-label={title}
 | 
					        aria-expanded={expanded}
 | 
				
			||||||
            aria-pressed={pressed}
 | 
					        title={title}
 | 
				
			||||||
            aria-expanded={expanded}
 | 
					        className={classes}
 | 
				
			||||||
            title={title}
 | 
					        onClick={this.handleClick}
 | 
				
			||||||
            className={classes}
 | 
					        onMouseDown={this.handleMouseDown}
 | 
				
			||||||
            onClick={this.handleClick}
 | 
					        onKeyDown={this.handleKeyDown}
 | 
				
			||||||
            onMouseDown={this.handleMouseDown}
 | 
					        onKeyPress={this.handleKeyPress}
 | 
				
			||||||
            onKeyDown={this.handleKeyDown}
 | 
					        style={style}
 | 
				
			||||||
            onKeyPress={this.handleKeyPress}
 | 
					        tabIndex={tabIndex}
 | 
				
			||||||
            style={style}
 | 
					        disabled={disabled}
 | 
				
			||||||
            tabIndex={tabIndex}
 | 
					      >
 | 
				
			||||||
            disabled={disabled}
 | 
					        <Icon id={icon} fixedWidth aria-hidden='true' />
 | 
				
			||||||
          >
 | 
					      </button>
 | 
				
			||||||
            <Icon id={icon} style={{ transform: `rotate(${rotate}deg)` }} fixedWidth aria-hidden='true' />
 | 
					 | 
				
			||||||
          </button>
 | 
					 | 
				
			||||||
        )}
 | 
					 | 
				
			||||||
      </Motion>
 | 
					 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1591,6 +1591,20 @@ a.account__display-name {
 | 
				
			|||||||
  color: $gold-star;
 | 
					  color: $gold-star;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.no-reduce-motion .icon-button.star-icon {
 | 
				
			||||||
 | 
					  &.activate {
 | 
				
			||||||
 | 
					    & > .fa-star {
 | 
				
			||||||
 | 
					      animation: spring-rotate-in 1s linear;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  &.deactivate {
 | 
				
			||||||
 | 
					    & > .fa-star {
 | 
				
			||||||
 | 
					      animation: spring-rotate-out 1s linear;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.notification__display-name {
 | 
					.notification__display-name {
 | 
				
			||||||
  color: inherit;
 | 
					  color: inherit;
 | 
				
			||||||
  font-weight: 500;
 | 
					  font-weight: 500;
 | 
				
			||||||
@ -3373,6 +3387,50 @@ a.status-card.compact:hover {
 | 
				
			|||||||
  animation: loader-figure 1.15s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
 | 
					  animation: loader-figure 1.15s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@keyframes spring-rotate-in {
 | 
				
			||||||
 | 
					  0% {
 | 
				
			||||||
 | 
					    transform: rotate(0deg);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  30% {
 | 
				
			||||||
 | 
					    transform: rotate(-484.8deg);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  60% {
 | 
				
			||||||
 | 
					    transform: rotate(-316.7deg);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  90% {
 | 
				
			||||||
 | 
					    transform: rotate(-375deg);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  100% {
 | 
				
			||||||
 | 
					    transform: rotate(-360deg);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@keyframes spring-rotate-out {
 | 
				
			||||||
 | 
					  0% {
 | 
				
			||||||
 | 
					    transform: rotate(-360deg);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  30% {
 | 
				
			||||||
 | 
					    transform: rotate(124.8deg);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  60% {
 | 
				
			||||||
 | 
					    transform: rotate(-43.27deg);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  90% {
 | 
				
			||||||
 | 
					    transform: rotate(15deg);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  100% {
 | 
				
			||||||
 | 
					    transform: rotate(0deg);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@keyframes loader-figure {
 | 
					@keyframes loader-figure {
 | 
				
			||||||
  0% {
 | 
					  0% {
 | 
				
			||||||
    width: 0;
 | 
					    width: 0;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user