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 { types } from '@douyinfe/semi-animation-styled'; import StyledAnimation from '../lib/StyledAnimation'; /** semi-ui demos */ import SemiCollapseAnimation from './semi-collapse-animation-styled'; const stories = storiesOf('semi-animation-react/StyledAnimation', module); stories.addDecorator(withKnobs); const { bouncingEntrances, bouncingExits, fadingEntrances, fadingExits, rotatingEntrances, rotatingExits, slidingEntrances, slidingExits, zoomingEntrances, zoomingExits, } = types; const rectStyle = { backgroundColor: 'rgb(241, 101, 101)', padding: '20px', // width: '200px', // height: '100px', margin: '20px', marginLeft: '50px', borderRadius: '4px', fontSize: '20px', color: 'white', display: 'flex', alignItems: 'center', justifyContent: 'center', }; const bgContainerStyle = { border: '1px solid gray', backgroundColor: 'tan', borderRadius: 4, marginBottom: 10 }; const itemStyle = { backgroundColor: 'rgb(241, 101, 101)', color: 'white', borderRadius: '4px', padding: '10px', textAlign: 'center', }; const durations = ['200ms', '500ms', '750ms', '1s', '1.5s']; const containerStyle = { display: 'flex', width: '960px', flexWrap: 'wrap' }; const printArgs = (...args) => console.log(...args); class AnimItem extends Component { state = { type: undefined, duration: '500ms', speed: 'faster', }; constructor(props = {}) { super(props); } componentDidMount() { this.setState({ type: this.props.enterType, }); } _reset = () => { let currentType = this.state.type; this.setState( { type: undefined, }, () => { this.setState({ type: currentType, }); } ); }; setSpeed = e => { this.setState({ speed: e.target.value, }); this._reset(); }; setDuration = e => { this.setState({ duration: e.target.value, }); this._reset(); }; enter = () => { this.setState( { type: undefined, }, () => this.setState({ type: this.props.enterType, }) ); }; leave = () => { this.setState( { type: undefined, }, () => this.setState({ type: this.props.leaveType, }) ); }; render() { let { type, speed, duration } = this.state; let { children } = this.props; if (type) { return (