Skip to content

Commit e79930a

Browse files
committed
Initial commit
1 parent fd17cad commit e79930a

File tree

7 files changed

+103
-13
lines changed

7 files changed

+103
-13
lines changed

src/App.js

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
1-
import React from 'react';
1+
import React, { useState } from 'react';
22
import logo from './logo.svg';
33
import './App.css';
4+
import UserInput from './UserInput/UserInput';
5+
import UserOutput from './UserOutput/UserOutput';
6+
7+
import ValidationComponent from './ValidationComponent/ValidationComponent';
8+
import CharComponent from './CharComponent/CharComponent';
49

510
function App() {
11+
const [text, setText] = useState("Hola");
12+
13+
const updateText = ev => setText(ev.target.value);
14+
15+
const deleteLetter = ix => {
16+
const textChars = text.split('');
17+
textChars.splice(ix, 1);
18+
setText(textChars.join(''));
19+
}
20+
621
return (
722
<div className="App">
823
<header className="App-header">
9-
<img src={logo} className="App-logo" alt="logo" />
10-
<p>
11-
Edit <code>src/App.js</code> and save to reload.
12-
</p>
13-
<a
14-
className="App-link"
15-
href="https://reactjs.org"
16-
target="_blank"
17-
rel="noopener noreferrer"
18-
>
19-
Learn React
20-
</a>
24+
<input onChange={updateText} value={text}></input>
25+
<p>The word is {text}!</p>
26+
<ValidationComponent length={text.length}></ValidationComponent>
27+
{text.split('').map((c, ix) => (
28+
<CharComponent
29+
key={ix}
30+
letter={c}
31+
click={() => deleteLetter(ix)}>
32+
</CharComponent>)
33+
)
34+
}
35+
{/* <UserInput username={username} changeUsernameHandler={setUsername}></UserInput>
36+
<UserOutput username={username}></UserOutput>
37+
<UserOutput></UserOutput>
38+
<UserOutput></UserOutput> */}
2139
</header>
2240
</div>
2341
);

src/CharComponent/CharComponent.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
3+
const charComponent = props => {
4+
const style = {
5+
display: "inline-block",
6+
padding: "16px",
7+
textAlign: "center",
8+
margin: "16px",
9+
border: "1px solid black"
10+
};
11+
12+
return <div style={style} onClick={props.click}>{props.letter}</div>
13+
}
14+
15+
export default charComponent;

src/UserInput/UserInput.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.UserInput {
2+
border-radius: 5px;
3+
}

src/UserInput/UserInput.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
3+
import "./UserInput.css";
4+
5+
const userInput = props => {
6+
7+
const changeUsernameHandler = event => props.changeUsernameHandler(event.target.value);
8+
9+
const style = {
10+
width: "100%",
11+
padding: "12px 20px",
12+
margin: "8px 0",
13+
boxSizing: "border-box"
14+
}
15+
16+
return <input
17+
className="UserInput"
18+
type="text"
19+
style={style}
20+
value={props.username}
21+
onChange={changeUsernameHandler}
22+
></input>;
23+
}
24+
25+
export default userInput;

src/UserOutput/UserOutput.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.UserOutput {
2+
3+
}
4+
5+
.UserOutput > p {
6+
font-size: 12px;
7+
}

src/UserOutput/UserOutput.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
3+
import './UserOutput.css';
4+
5+
const userOutput = props => {
6+
return (
7+
<div className="UserOutput">
8+
<p>My first paragraph {props.username}!</p>
9+
<p>My second paragrap</p>
10+
</div>
11+
);
12+
}
13+
14+
export default userOutput;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
3+
const validationComponent = props => {
4+
let advice = props.length < 5? "Text too short" : "Text long enough";
5+
return <p>{advice}</p>;
6+
}
7+
8+
export default validationComponent;

0 commit comments

Comments
 (0)