mirror of
https://github.com/kou029w/_.git
synced 2025-01-30 22:08:02 +00:00
refactor: Stateless Functional Componentに変更
This commit is contained in:
parent
535ab0cd42
commit
9bea9c2e25
2 changed files with 39 additions and 47 deletions
|
@ -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 (
|
||||
<dl>
|
||||
<dt>かぶり回数</dt>
|
||||
<dd>{count}</dd>
|
||||
<dt>かぶり時間 (ms)</dt>
|
||||
<dd>{time}</dd>
|
||||
</dl>
|
||||
);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<dl>
|
||||
<dt>かぶり回数</dt>
|
||||
<dd>{count}</dd>
|
||||
<dt>かぶり時間 (ms)</dt>
|
||||
<dd>{time}</dd>
|
||||
</dl>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -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 (
|
||||
<dl>
|
||||
<dt>会話時間 (ms)</dt>
|
||||
<dd>{leftActivity + rightActivity}</dd>
|
||||
<dt>会話の割合</dt>
|
||||
<dd>
|
||||
左{" "}
|
||||
<meter value={leftActivity / (leftActivity + rightActivity)}>
|
||||
{leftActivity / (leftActivity + rightActivity)}
|
||||
</meter>{" "}
|
||||
右
|
||||
</dd>
|
||||
</dl>
|
||||
);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<dl>
|
||||
<dt>会話時間 (ms)</dt>
|
||||
<dd>{leftActivity + rightActivity}</dd>
|
||||
<dt>会話の割合</dt>
|
||||
<dd>
|
||||
左{" "}
|
||||
<meter value={leftActivity / (leftActivity + rightActivity)}>
|
||||
{leftActivity / (leftActivity + rightActivity)}
|
||||
</meter>{" "}
|
||||
右
|
||||
</dd>
|
||||
</dl>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue