You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
989 B

  1. import React from 'react';
  2. import { FormattedMessage } from 'react-intl';
  3. import PropTypes from 'prop-types';
  4. export default class ColumnBackButtonSlim extends React.PureComponent {
  5. static contextTypes = {
  6. router: PropTypes.object,
  7. };
  8. handleClick = () => {
  9. // if history is exhausted, or we would leave mastodon, just go to root.
  10. if (window.history && (window.history.length === 1 || window.history.length === window._mastoInitialHistoryLen)) {
  11. this.context.router.history.push('/');
  12. } else {
  13. this.context.router.history.goBack();
  14. }
  15. }
  16. render () {
  17. return (
  18. <div className='column-back-button--slim'>
  19. <div role='button' tabIndex='0' onClick={this.handleClick} className='column-back-button column-back-button--slim-button'>
  20. <i className='fa fa-fw fa-chevron-left column-back-button__icon' />
  21. <FormattedMessage id='column_back_button.label' defaultMessage='Back' />
  22. </div>
  23. </div>
  24. );
  25. }
  26. }