import React, { Component } from 'react'; import { connect } from 'react-redux'; import { TransitionMotion, spring } from 'react-motion'; import AppInfo from 'components/auth/AppInfo'; import styles from './auth.scss'; const springConfig = [200, 20]; class AuthPage extends Component { displayName = 'AuthPage'; render() { var appInfo = { name: 'TLauncher', description: `Лучший альтернативный лаунчер для Minecraft с большим количеством версий и их модификаций, а также возмоностью входа как с лицензионным аккаунтом, так и без него.` }; var { path, children } = this.props; return (
{(items) => (
{Object.keys(items).map((path) => { const {children, x} = items[path]; const style = { position: 'absolute', top: 0, left: 0, width: '100%', transform: `translateX(${x}%)` }; return (
{children}
); })}
)}
); } willEnter(key, styles) { return { ...styles, x: spring(100, springConfig) }; } willLeave(key, styles) { return { ...styles, x: spring(-100, springConfig) }; } } import { FormattedMessage as Message } from 'react-intl'; import Helmet from 'react-helmet'; import ReactHeight from 'react-height'; import panelStyles from 'components/ui/panel.scss'; import buttons from 'components/ui/buttons.scss'; import icons from 'components/ui/icons.scss'; import { Panel, PanelBody, PanelFooter, PanelHeader } from 'components/ui/Panel'; import { Input, Checkbox } from 'components/ui/Form'; import messages from 'components/auth/Login.messages'; import regMessages from 'components/auth/Register.messages'; import {helpLinks as helpLinksStyles} from 'components/auth/helpLinks.scss'; import passwordMessages from 'components/auth/Password.messages'; const opacitySpringConfig = [200, 20]; const heightSpringConfig = [200, 18]; const transformSpringConfig = [500, 20]; // TODO: сделать более быстрый фейд на горизонтальном скролле class TheDemo extends Component { state = { isFirstPage: true, height: {} }; render() { var {isFirstPage} = this.state; var path = `page${isFirstPage ? '1' : '2'}`; return ( {(items) => { var keys = Object.keys(items).filter((key) => key !== 'common'); return (
{keys.map((key) => this.getHeader(key, items[key]))}
{keys.map((key) => this.getBody(key, items[key]))}
{keys.map((key) => this.getFooter(key, items[key]))}
{keys.map((key) => this.getLinks(key, items[key]))}
); }}
); } willEnter = (key, styles) => { var sign = this.state.isFirstPage ? -1 : 1; return { ...styles, transformSpring: spring(sign * 100, transformSpringConfig), opacitySpring: spring(1, opacitySpringConfig) }; }; willLeave = (key, styles) => { var sign = this.state.isFirstPage ? -1 : 1; return { ...styles, transformSpring: spring(sign * -100, transformSpringConfig), opacitySpring: spring(0, opacitySpringConfig) }; }; getBody(key, props) { var {isFirstPage, transformSpring, opacitySpring} = props; var style = { position: 'absolute', top: 0, left: 0, width: '100%', WebkitTransform: `translateX(${transformSpring}%)`, transform: `translateX(${transformSpring}%)`, opacity: opacitySpring }; return (isFirstPage ? ( ) : ( ) }} /> } /> )); } updateHeight = (height) => { this.setState({ height: { ...this.state.height, [`page${this.state.isFirstPage ? '1' : '2'}`]: height } }); }; getFooter(key, props) { var {isFirstPage, opacitySpring} = props; var style = { position: 'absolute', top: 0, left: 0, width: '100%', opacity: opacitySpring }; return (isFirstPage ? ( ) : ( )); } getHeader(key, props) { var {isFirstPage, transformSpring} = props; var style = { position: 'absolute', top: 0, left: 0, width: '100%' }; var scrollStyle = { WebkitTransform: `translateY(${transformSpring}%)`, transform: `translateY(${transformSpring}%)` }; var sideScrollStyle = { position: 'relative', zIndex: 2, WebkitTransform: `translateX(${-Math.abs(transformSpring)}%)`, transform: `translateX(${-Math.abs(transformSpring)}%)` }; return (isFirstPage ? (
{(msg) =>
{msg}
}
) : (
{(msg) =>
{msg}
}
)); } getLinks(key, props) { var {isFirstPage, opacitySpring} = props; var style = { position: 'absolute', top: 0, left: 0, width: '100%', opacity: opacitySpring }; return (isFirstPage ? (
) : (
{'test 123'}
)); } onSwitchViews = (event) => { event.preventDefault(); this.setState({ isFirstPage: !this.state.isFirstPage }); }; } export default connect((state) => ({ path: state.routing.location.pathname }))(AuthPage);