-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'change answer classification' feature
- Loading branch information
1 parent
125b9c6
commit 80ffdba
Showing
18 changed files
with
410 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,8 @@ | |
gap: 8px | ||
&__body | ||
margin: 8px 0 | ||
&__categorizable | ||
&-list | ||
list-style: none | ||
margin: 0 | ||
padding: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Component } from "react"; | ||
import Btn from "../Btn"; | ||
import "./style.sass"; | ||
|
||
export default class SentimentItem extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
color: "", | ||
}; | ||
} | ||
change = (color) => { | ||
this.setState( | ||
{ | ||
color: this.state.color === color ? "" : color, | ||
}, | ||
() => { | ||
if (this.props.onChange) { | ||
this.props.onChange(color); | ||
} | ||
} | ||
); | ||
}; | ||
render() { | ||
const color = this.state.color | ||
? ` c-sentiment-item--${this.state.color}` | ||
: ""; | ||
return ( | ||
<li className={`c-sentiment-item${color}`}> | ||
{this.props.format ? ( | ||
this.props.format(this.props.item) | ||
) : ( | ||
<> | ||
{this.props.item.answer} | ||
{!this.props["hide-sentiment"] && ( | ||
<ul> | ||
<li>Sentiment Score: {this.props.item.sentiment.score}</li> | ||
</ul> | ||
)} | ||
<div className="c-sentiment-item__control"> | ||
{this.props.categories.map((k) => ( | ||
<Btn small color={k} key={k} onClick={() => this.change(k)}> | ||
Change to {k} | ||
</Btn> | ||
))} | ||
</div> | ||
</> | ||
)} | ||
</li> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.c-sentiment-item | ||
padding: 8px 12px | ||
border: 1px solid #F3F3F4 | ||
background-color: #F3F3F4 | ||
border-radius: 8px | ||
margin: 4px 0 | ||
&__control | ||
padding-top: 8px | ||
text-align: right | ||
&--positive | ||
background-color: #bee2aa | ||
&--negative | ||
background-color: #e2aaaa | ||
&--neutral | ||
background-color: #afd4ff | ||
&--unclassified | ||
background-color: #ffe7ce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Component } from "react"; | ||
import key from "../../plugins/key"; | ||
import SentimentItem from "../SentimentItem"; | ||
|
||
export default class SentimentList extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
set: this.props.list, | ||
}; | ||
} | ||
|
||
render() { | ||
return ( | ||
<ul className="c-answer-pane__categorizable-list"> | ||
{this.state.set.map((i) => { | ||
const categories = this.props.categories.filter( | ||
(j) => j !== this.props.category | ||
); | ||
|
||
return ( | ||
<SentimentItem | ||
item={i} | ||
categories={categories} | ||
key={key(`fdbk-${i.line}`)} | ||
onChange={(to) => this.props.change(i, to, this.props.category)} | ||
hide-sentiment={this.props["hide-sentiment"]} | ||
/> | ||
); | ||
})} | ||
</ul> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Component } from "react"; | ||
import key from "../../plugins/key"; | ||
|
||
import "./style.sass"; | ||
|
||
export default class SuitableContent extends Component { | ||
render() { | ||
return this.props.areas.map((item) => { | ||
const Content = item.content; | ||
const _key = item.key.split(":")[0].trim(); | ||
|
||
return this.props.visible === _key ? ( | ||
<div key={key(`suitable-${_key}`)}> | ||
<Content /> | ||
</div> | ||
) : null; | ||
}); | ||
} | ||
} |
Oops, something went wrong.