|
|
@@ -1,11 +1,11 @@
|
|
|
-import React from "react";
|
|
|
-import { Motion, spring } from "react-motion";
|
|
|
+import React from 'react';
|
|
|
+import { Motion, spring } from 'react-motion';
|
|
|
|
|
|
-import "./style.css";
|
|
|
+import './style.css';
|
|
|
|
|
|
export default class Toggle extends React.Component {
|
|
|
state = {
|
|
|
- open: false
|
|
|
+ open: false,
|
|
|
};
|
|
|
|
|
|
handleClick = () => {
|
|
|
@@ -15,14 +15,14 @@ export default class Toggle extends React.Component {
|
|
|
render() {
|
|
|
return (
|
|
|
<div>
|
|
|
- <h2>
|
|
|
- Try the toggole which controls the status and animation. The block
|
|
|
+ <p>
|
|
|
+ Try the toggle which controls the status and animation. The block
|
|
|
itself is also clickable.
|
|
|
- </h2>
|
|
|
+ </p>
|
|
|
<button onClick={this.handleClick}>
|
|
|
Toggle
|
|
|
</button>
|
|
|
- <h2>Status: {this.state.open ? "open" : "closed"}</h2>
|
|
|
+ <h3>Status: {this.state.open ? 'open' : 'closed'}</h3>
|
|
|
<Motion style={{ x: spring(this.state.open ? 200 : 0) }}>
|
|
|
{({ x }) =>
|
|
|
<div className="toggle-bg">
|
|
|
@@ -30,7 +30,7 @@ export default class Toggle extends React.Component {
|
|
|
className="toggle-block"
|
|
|
onClick={this.handleClick}
|
|
|
style={{
|
|
|
- transform: `translate3d(${x}px, 0, 0)`
|
|
|
+ transform: `translate3d(${x}px, 0, 0)`,
|
|
|
}}
|
|
|
/>
|
|
|
</div>}
|