Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-task #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions components/Board.jsx

This file was deleted.

File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions scherbenok/components/Board.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import Lists from './Lists/Lists.jsx'
import NewListForm from './NewListForm/NewListForm'

export default class Board extends React.Component {
state = {
lists: []
}

onListCreate = (name) => {
this.setState({
lists: [...this.state.lists, {
name,
}]
})
}

render() {
return (
<div>
<NewListForm onListCreate={this.onListCreate} />
<Lists lists={this.state.lists} />
</div>
);
}
}
11 changes: 11 additions & 0 deletions scherbenok/components/Card/Card.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';

export default class Card extends React.Component {
render() {
return (
<div>
{this.props.content}
</div>
);
}
};
29 changes: 29 additions & 0 deletions scherbenok/components/Form/Form.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';

export default class Form extends React.Component {
state = {
inputValue: '',
}

onInputValueChange = (e) => {
this.setState({
inputValue: e.target.value
})
}

onClick = (e) => {
this.props.onClick(this.state.inputValue)
this.setState({
inputValue: ''
})
}

render() {
return (
<div>
<input type="text" onChange={this.onInputValueChange} value={this.state.inputValue}></input>
<button onClick={this.onClick}>Add</button>
</div>
);
}
};
25 changes: 25 additions & 0 deletions scherbenok/components/List/List.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react'
import Card from '../Card/Card'
import Form from '../Form/Form'

export default class List extends React.Component {
state = {
cards: []
}

createNewCard = cardName => {
this.setState({
cards: [...this.state.cards, cardName]
})
}

render() {
return (
<div>
<h4>{this.props.name}</h4>
<Form onClick={this.createNewCard} />
{ this.state.cards.map(elem => (<Card content={elem} />)) }
</div>
);
}
};
12 changes: 12 additions & 0 deletions scherbenok/components/Lists/Lists.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import List from '../List/List';

export default class Lists extends React.Component {
render() {
return (
<div>
{ this.props.lists.map(elem => (<List name={elem.name} />)) }
</div>
);
}
};
5 changes: 5 additions & 0 deletions scherbenok/components/NewListForm/NewListForm.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.new_list_form {
background: #aaa;
color: red;
width: 300px;
}
14 changes: 14 additions & 0 deletions scherbenok/components/NewListForm/NewListForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import Form from '../Form/Form'
import './NewListForm.css'

export default class NewListForm extends React.Component {
render() {
return (
<div className='new_list_form'>
<h2>New list form</h2>
<Form onClick={this.props.onListCreate} />
</div>
);
}
};
File renamed without changes.
File renamed without changes.
9 changes: 8 additions & 1 deletion package.json → scherbenok/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,31 @@
"main": "webpack.config.js",
"scripts": {
"start": "http-server",
"build": "webpack ./webpack.config.js"
"build": "webpack ./webpack.config.js",
"watch": "webpack ./webpack.config.js --colors --watch"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.11.4",
"babel-loader": "^6.2.4",
"babel-plugin-transform-class-properties": "^6.10.2",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-1": "^6.5.0",
"css-loader": "^0.23.1",
"http-server": "^0.9.0",
"style-loader": "^0.13.1",
"webpack": "^1.13.1"
},
"babel": {
"presets": [
"react",
"stage-1",
"es2015"
],
"plugins": [
"transform-class-properties"
]
},
"dependencies": {
Expand Down
10 changes: 8 additions & 2 deletions webpack.config.js → scherbenok/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ module.exports = {
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel'
}]
}
},
{
test: /\.css$/,
loader: 'style!css'
}
]
},
devtool: 'source-map'
};