Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
isVy08 committed Oct 24, 2021
1 parent 8dec285 commit 7dff9fb
Show file tree
Hide file tree
Showing 5 changed files with 1,286 additions and 538 deletions.
141 changes: 141 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"homepage": "https://isVy08.github.io/mwe-demo",
"name": "my-app",
"version": "0.1.0",
"private": true,
Expand All @@ -10,13 +11,17 @@
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"bootstrap": "^4.1.1",
"gh-pages": "^3.2.3",
"react": "^17.0.2",
"react-collapse": "^5.1.0",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"save-dev": "0.0.1-security",
"web-vitals": "^1.1.2"
},
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
Expand Down
30 changes: 1 addition & 29 deletions src/components/input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,13 @@ import DropdownItem from './DropdownItem'
class Input extends React.Component {
state = {
id: this.props.id,
upvalue: this.props.upvalue,
downvalue: this.props.downvalue,
contents: this.props.content
};

handleIncrementUp = () => {
this.setState({upvalue : this.state.upvalue + 1})
}

handleIncrementDown = () => {
this.setState({downvalue : this.state.downvalue + 1})
}

render () {
return (
<div>
{this.props.children}

<button onClick={this.handleIncrementUp} class="btn btn-link">👍</button>
<span className={this.getBadgeClasses(true)}>{this.formatCount(this.state.upvalue)}</span>
<button onClick={this.handleIncrementDown} class="btn btn-link">👎</button>
<span className={this.getBadgeClasses(false)}>{this.formatCount(this.state.downvalue)}</span>

{this.props.children}

<div class="card-title">
{this.state.contents.map(content =>
Expand All @@ -44,19 +28,7 @@ class Input extends React.Component {
</div>
);
}

getBadgeClasses (up) {
let classes = "badge m-2 badge-";
if (up === true) {classes += this.state.upvalue === 0 ? "light" : "warning"
} else {
classes += this.state.downvalue === 0 ? "light" : "primary"
} ;
return classes;
}

formatCount (value) {
return value === 0 ? 0 : value;
}
}

export default Input;
2 changes: 1 addition & 1 deletion src/components/inputs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Inputs extends React.Component {
return (
<div>
{ this.state.inputs.map(input => (<Input
key={input.id} upvalue={input.upvalue} downvalue={input.downvalue} content={input.content}>
key={input.id} content={input.content}>
<div class="card-header" style={{fontWeight:"bolder"}}>{input.sentence}</div>
</Input>
))}
Expand Down
Loading

0 comments on commit 7dff9fb

Please sign in to comment.