diff --git a/components/kaburi.jsx b/components/kaburi.jsx index a395238..dc7b0cf 100644 --- a/components/kaburi.jsx +++ b/components/kaburi.jsx @@ -1,20 +1,16 @@ -import { Component } from "react"; +export default ({ activity }) => { + const kaburiActivity = activity.filter(a => a.ch === "kaburi"); + const count = kaburiActivity.length; + const time = kaburiActivity + .map(a => a.endTime - a.startTime) + .reduce((a, c) => a + c, 0); -export default class extends Component { - render() { - const activity = this.props.activity.filter(a => a.ch === "kaburi"); - const count = activity.length; - const time = activity - .map(a => a.endTime - a.startTime) - .reduce((a, c) => a + c, 0); - - return ( -
-
かぶり回数
-
{count}
-
かぶり時間 (ms)
-
{time}
-
- ); - } -} + return ( +
+
かぶり回数
+
{count}
+
かぶり時間 (ms)
+
{time}
+
+ ); +}; diff --git a/components/percentage.jsx b/components/percentage.jsx index d249a5a..038e957 100644 --- a/components/percentage.jsx +++ b/components/percentage.jsx @@ -1,29 +1,25 @@ -import { Component } from "react"; +export default ({ activity }) => { + const leftActivity = activity + .filter(a => a.ch === "l") + .map(a => a.endTime - a.startTime) + .reduce((a, c) => a + c, 0); + const rightActivity = activity + .filter(a => a.ch === "r") + .map(a => a.endTime - a.startTime) + .reduce((a, c) => a + c, 0); -export default class extends Component { - render() { - const leftActivity = this.props.activity - .filter(a => a.ch === "l") - .map(a => a.endTime - a.startTime) - .reduce((a, c) => a + c, 0); - const rightActivity = this.props.activity - .filter(a => a.ch === "r") - .map(a => a.endTime - a.startTime) - .reduce((a, c) => a + c, 0); - - return ( -
-
会話時間 (ms)
-
{leftActivity + rightActivity}
-
会話の割合
-
- 左{" "} - - {leftActivity / (leftActivity + rightActivity)} - {" "} - 右 -
-
- ); - } -} + return ( +
+
会話時間 (ms)
+
{leftActivity + rightActivity}
+
会話の割合
+
+ 左{" "} + + {leftActivity / (leftActivity + rightActivity)} + {" "} + 右 +
+
+ ); +};