Skip to content

Commit b622caa

Browse files
committed
baseline
add hideMe button and action assign key to boxes remove animation
1 parent 81649ca commit b622caa

File tree

8 files changed

+119
-120
lines changed

8 files changed

+119
-120
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
24+
25+
.idea

README.md

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1 @@
1-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2-
3-
## Available Scripts
4-
5-
In the project directory, you can run:
6-
7-
### `npm start`
8-
9-
Runs the app in the development mode.<br>
10-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11-
12-
The page will reload if you make edits.<br>
13-
You will also see any lint errors in the console.
14-
15-
### `npm test`
16-
17-
Launches the test runner in the interactive watch mode.<br>
18-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19-
20-
### `npm run build`
21-
22-
Builds the app for production to the `build` folder.<br>
23-
It correctly bundles React in production mode and optimizes the build for the best performance.
24-
25-
The build is minified and the filenames include the hashes.<br>
26-
Your app is ready to be deployed!
27-
28-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29-
30-
### `npm run eject`
31-
32-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33-
34-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35-
36-
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37-
38-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39-
40-
## Learn More
41-
42-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43-
44-
To learn React, check out the [React documentation](https://reactjs.org/).
45-
46-
### Code Splitting
47-
48-
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49-
50-
### Analyzing the Bundle Size
51-
52-
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53-
54-
### Making a Progressive Web App
55-
56-
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57-
58-
### Advanced Configuration
59-
60-
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61-
62-
### Deployment
63-
64-
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65-
66-
### `npm run build` fails to minify
67-
68-
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
1+
# Animating Visibility with CSS: An Example of React Hooks

package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"dependencies": {
66
"react": "^16.8.6",
77
"react-dom": "^16.8.6",
8-
"react-scripts": "3.0.1"
8+
"react-scripts": "3.0.1",
9+
"superb": "^4.0.0"
910
},
1011
"scripts": {
1112
"start": "react-scripts start",

public/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
1111
-->
1212
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
13+
<link
14+
rel="stylesheet"
15+
href="https://use.fontawesome.com/releases/v5.8.2/css/all.css"
16+
integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay"
17+
crossorigin="anonymous"
18+
/>
1319
<!--
1420
Notice the use of %PUBLIC_URL% in the tags above.
1521
It will be replaced with the URL of the `public` folder during the build.

src/App.css

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,51 @@
1-
.App {
2-
text-align: center;
1+
2+
.frame{
3+
margin: auto;
4+
width: 600px;
5+
display: flex;
6+
flex-direction: row;
7+
flex-wrap: wrap;
38
}
49

5-
.App-logo {
6-
animation: App-logo-spin infinite 20s linear;
7-
height: 40vmin;
8-
pointer-events: none;
10+
.box{
11+
position: relative;
12+
margin: 16px;
13+
height: 150px;
14+
width: 150px;
15+
border-radius: 16px;
16+
border: 1px solid;
917
}
1018

11-
.App-header {
12-
background-color: #282c34;
13-
min-height: 100vh;
14-
display: flex;
15-
flex-direction: column;
16-
align-items: center;
17-
justify-content: center;
18-
font-size: calc(10px + 2vmin);
19-
color: white;
19+
.center{
20+
position: absolute;
21+
left: 50%;
22+
top: 50%;
23+
transform: translate(-50%, -50%);
2024
}
2125

22-
.App-link {
23-
color: #61dafb;
26+
.bottom-corner{
27+
position: absolute;
28+
left: 75%;
29+
top: 75%;
2430
}
2531

26-
@keyframes App-logo-spin {
27-
from {
28-
transform: rotate(0deg);
29-
}
30-
to {
31-
transform: rotate(360deg);
32-
}
32+
33+
34+
.button {
35+
width: 30px;
36+
height: 30px;
37+
background-color: transparent;
38+
39+
border-radius:8px;
40+
border:2px solid #fff;
41+
cursor:pointer;
42+
color:#fff;
43+
text-decoration:none;
44+
}
45+
.button:hover {
46+
background-color:#f6f6f6;
47+
color:#424242;
48+
}
49+
.button:active {
50+
background-color:#424242;
3351
}

src/App.js

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,51 @@
1-
import React from 'react';
2-
import logo from './logo.svg';
3-
import './App.css';
1+
import React, { useState } from "react";
2+
import superb from "superb";
3+
import "./App.css";
4+
5+
const colors = [
6+
"#6690FF",
7+
"#6CD566",
8+
"#50E5FF",
9+
"#FFDC75",
10+
"#FF7C83",
11+
"#FF702D",
12+
"#FFAA42",
13+
"#7F7B82",
14+
"#4D7EA8"
15+
];
16+
17+
function Box({ word }) {
18+
const color = colors[Math.floor(Math.random() * 9)];
19+
const [visible, setVisible] = useState(true);
20+
21+
function hideMe(){
22+
setVisible(false);
23+
}
24+
25+
let style = { borderColor: color, backgroundColor: color };
26+
if (!visible) style.display = "none";
27+
28+
return (
29+
<div className="box" style={style}>
30+
<div className="center">{word}</div>
31+
<button className="button bottom-corner" onClick={hideMe}>
32+
<i className="center far fa-eye fa-lg" />
33+
</button>
34+
</div>
35+
);
36+
}
437

538
function App() {
39+
const words = [];
40+
for (let i = 0; i < 12; i++) {
41+
words[i] = superb.random();
42+
}
43+
644
return (
7-
<div className="App">
8-
<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>
21-
</header>
45+
<div className="frame">
46+
{words.map(word => (
47+
<Box key={word} word={word} />
48+
))}
2249
</div>
2350
);
2451
}

src/App.test.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)