import React, { useState, Component, isValidElement } from 'react'; import ReactDOM from 'react-dom'; import { storiesOf } from '@storybook/react'; import { withKnobs, text, boolean } from '@storybook/addon-knobs'; import withPropsCombinations from 'react-storybook-addon-props-combinations'; import { Animation } from '../index'; /** demos */ import SimpleAnimation from './simple'; import Morph from './morph'; import Auto from './auto'; import DashOffset from './dashoffset'; import Scroll from './scroll'; /** semi-ui components * */ import ModalAnimation from './semi-modal-animation'; /** semi-animation-react mock animate.css */ import BounceInAnimation from './animate-react/BounceIn'; const stories = storiesOf('semi-animation-react/Animation', module); stories.addDecorator(withKnobs); const itemStyle = { backgroundColor: 'rgb(241, 101, 101)', color: 'white', borderRadius: 4, padding: 10, textAlign: 'center', }; const bigSquareStyle = { backgroundColor: 'rgb(241, 101, 101)', width: 100, height: 100, margin: 20, marginLeft: 50, borderRadius: 4, fontSize: 32, color: 'white', display: 'flex', alignItems: 'center', justifyContent: 'center', }; stories.add('Animaiton', () => { class App extends Component { constructor(props) { super(props); this.state = { value: 0, }; } onFrame = props => { const value = props.value.toFixed(2); this.setState({ value }); }; onStop = props => { console.log('onStop', props); const value = props.value.toFixed(2); this.setState({ value }); }; invokehandlerFn = (funcName, ...args) => { if ( funcName && typeof funcName === 'string' && this.handler && this.handler[funcName] && typeof this.handler[funcName] === 'function' ) { console.log(this.handler); this.handler[funcName](...args); if (['reset', 'reverse'].includes(funcName)) { this.handler.start(); } } }; render() { return ( (this.handler = handler)} config={{ duration: 20000 }} from={{ value: 0 }} to={{ value: 10 }} // onFrame={this.onFrame} onStop={this.onStop} > {props => { const value = props.value.toFixed(2); const hsl = `hsl(${value * 25 + 60}, 90%, 50%)`; const x = 100 + 20 * value; const y = 100 + 20 * Math.cos(value); return ( <>
prop.value changed to: {value}
{value}
I'am a block.
{hsl}
{['reset', 'reverse', 'pause', 'resume', 'stop', 'end'].map(funcName => ( ))}
); }}
); } } return ; }); stories.add('SimpleAnimation', () => ); stories.add('Morph', () => ); stories.add('Auto', () => ); stories.add('DashOffset', () => ); stories.add('Scroll', () => ); stories.add('Semi-ModalAnimation', () => ); stories.add('BounceInAnimation', () => ( {(currentStyle = {}) =>
BounceIn
}
));