[Glitch] Port changes to IconButton
Port changes to IconButton from 27a0d02d0d960163e98595b05412c0d03a4875d0 to glitch-soc Signed-off-by: Thibaut Girka <thib@sitedethib.com>
This commit is contained in:
		
							parent
							
								
									fe1de4e49b
								
							
						
					
					
						commit
						a4b15e2cf0
					
				@ -11,6 +11,8 @@ export default class IconButton extends React.PureComponent {
 | 
				
			|||||||
    title: PropTypes.string.isRequired,
 | 
					    title: PropTypes.string.isRequired,
 | 
				
			||||||
    icon: PropTypes.string.isRequired,
 | 
					    icon: PropTypes.string.isRequired,
 | 
				
			||||||
    onClick: PropTypes.func,
 | 
					    onClick: PropTypes.func,
 | 
				
			||||||
 | 
					    onMouseDown: PropTypes.func,
 | 
				
			||||||
 | 
					    onKeyDown: PropTypes.func,
 | 
				
			||||||
    size: PropTypes.number,
 | 
					    size: PropTypes.number,
 | 
				
			||||||
    active: PropTypes.bool,
 | 
					    active: PropTypes.bool,
 | 
				
			||||||
    pressed: PropTypes.bool,
 | 
					    pressed: PropTypes.bool,
 | 
				
			||||||
@ -43,6 +45,18 @@ export default class IconButton extends React.PureComponent {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  handleMouseDown = (e) => {
 | 
				
			||||||
 | 
					    if (!this.props.disabled && this.props.onMouseDown) {
 | 
				
			||||||
 | 
					      this.props.onMouseDown(e);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  handleKeyDown = (e) => {
 | 
				
			||||||
 | 
					    if (!this.props.disabled && this.props.onKeyDown) {
 | 
				
			||||||
 | 
					      this.props.onKeyDown(e);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  render () {
 | 
					  render () {
 | 
				
			||||||
    let style = {
 | 
					    let style = {
 | 
				
			||||||
      fontSize: `${this.props.size}px`,
 | 
					      fontSize: `${this.props.size}px`,
 | 
				
			||||||
@ -105,6 +119,8 @@ export default class IconButton extends React.PureComponent {
 | 
				
			|||||||
          title={title}
 | 
					          title={title}
 | 
				
			||||||
          className={classes}
 | 
					          className={classes}
 | 
				
			||||||
          onClick={this.handleClick}
 | 
					          onClick={this.handleClick}
 | 
				
			||||||
 | 
					          onMouseDown={this.handleMouseDown}
 | 
				
			||||||
 | 
					          onKeyDown={this.handleKeyDown}
 | 
				
			||||||
          style={style}
 | 
					          style={style}
 | 
				
			||||||
          tabIndex={tabIndex}
 | 
					          tabIndex={tabIndex}
 | 
				
			||||||
          disabled={disabled}
 | 
					          disabled={disabled}
 | 
				
			||||||
@ -124,6 +140,8 @@ export default class IconButton extends React.PureComponent {
 | 
				
			|||||||
            title={title}
 | 
					            title={title}
 | 
				
			||||||
            className={classes}
 | 
					            className={classes}
 | 
				
			||||||
            onClick={this.handleClick}
 | 
					            onClick={this.handleClick}
 | 
				
			||||||
 | 
					            onMouseDown={this.handleMouseDown}
 | 
				
			||||||
 | 
					            onKeyDown={this.handleKeyDown}
 | 
				
			||||||
            style={style}
 | 
					            style={style}
 | 
				
			||||||
            tabIndex={tabIndex}
 | 
					            tabIndex={tabIndex}
 | 
				
			||||||
            disabled={disabled}
 | 
					            disabled={disabled}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user