import PropTypes from 'prop-types'; import { PureComponent } from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import { Link } from 'react-router-dom'; import SwipeableViews from 'react-swipeable-views'; import ArrowRightAltIcon from '@/material-icons/400-24px/arrow_right_alt.svg?react'; import { ColumnBackButton } from 'flavours/glitch/components/column_back_button'; import { CopyPasteText } from 'flavours/glitch/components/copy_paste_text'; import { Icon } from 'flavours/glitch/components/icon'; import { me, domain } from 'flavours/glitch/initial_state'; import { useAppSelector } from 'flavours/glitch/store'; const messages = defineMessages({ shareableMessage: { id: 'onboarding.share.message', defaultMessage: 'I\'m {username} on #Mastodon! Come follow me at {url}' }, }); class TipCarousel extends PureComponent { static propTypes = { children: PropTypes.node, }; state = { index: 0, }; handleSwipe = index => { this.setState({ index }); }; handleChangeIndex = e => { this.setState({ index: Number(e.currentTarget.getAttribute('data-index')) }); }; handleKeyDown = e => { switch(e.key) { case 'ArrowLeft': e.preventDefault(); this.setState(({ index }, { children }) => ({ index: Math.abs(index - 1) % children.length })); break; case 'ArrowRight': e.preventDefault(); this.setState(({ index }, { children }) => ({ index: (index + 1) % children.length })); break; } }; render () { const { children } = this.props; const { index } = this.state; return (