Skip to content

Commit

Permalink
Added router
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-co committed Oct 2, 2023
1 parent 18e9dfc commit d2ab96f
Show file tree
Hide file tree
Showing 10 changed files with 336 additions and 4 deletions.
48 changes: 48 additions & 0 deletions React/test-feed/package-lock.json

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

2 changes: 2 additions & 0 deletions React/test-feed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.11.0",
"react-router-dom": "^6.16.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
Expand Down
14 changes: 13 additions & 1 deletion React/test-feed/src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import React from 'react'
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'
import { Home } from './pages/Home'
import { Nav } from './components/Nav'
import {About} from './pages/About'

export const App = () => {
return (
<div>App</div>
<div>
<Router>
<Nav />
<Routes>
<Route exact path='/' element={<Home />} />
<Route exact path='/about' element={<About />} />
</Routes>
</Router>
</div>
)
}
11 changes: 11 additions & 0 deletions React/test-feed/src/components/Nav.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'
import { Link } from 'react-router-dom'

export const Nav = () => {
return (
<div>
<Link to='/'>Home</Link>
<Link to='/about'>About</Link>
</div>
)
}
17 changes: 17 additions & 0 deletions React/test-feed/src/data/feed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const Feed = [
{
id: 1,
rating: 10,
text: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. consequuntur vel vitae commodi alias voluptatem est voluptatum ipsa quae.',
},
{
id: 2,
rating: 9,
text: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. consequuntur vel vitae commodi alias voluptatem est voluptatum ipsa quae.',
},
{
id: 3,
rating: 8,
text: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. consequuntur vel vitae commodi alias voluptatem est voluptatum ipsa quae.',
},
]
236 changes: 236 additions & 0 deletions React/test-feed/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

* {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
font-family: 'Poppins', sans-serif;
background-color: #202142;
color: #fff;
line-height: 1.6;
}

ul {
list-style: none;
}

.container {
max-width: 768px;
margin: auto;
padding: 0 20px;
}

header {
height: 70px;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30px;
}

.card {
background-color: #fff;
color: #333;
border-radius: 15px;
padding: 40px 50px;
margin: 20px 0;
position: relative;
}

.card.reverse {
background-color: rgba(0, 0, 0, 0.4);
color: #fff;
}

.card h2 {
font-size: 22px;
font-weight: 600;
text-align: center;
}

.rating {
display: flex;
align-items: center;
justify-content: space-around;
margin: 30px 0 40px;
}

.rating li,
.num-display {
position: relative;
background: #f4f4f4;
width: 50px;
height: 50px;
padding: 10px;
text-align: center;
border-radius: 50%;
font-size: 19px;
border: 1px #eee solid;
transition: 0.3s;
}

.rating li label {
position: absolute;
top: 50%;
left: 50%;
width: 50px;
height: 50px;
padding: 10px;
border-radius: 50%;
transform: translate(-50%, -50%);
cursor: pointer;
}

.rating li:hover,
.num-display {
background: #ff6a95;
color: #fff;
}

[type='radio'] {
opacity: 0;
}

[type='radio']:checked ~ label {
background: #ff6a95;
color: #fff;
}

.input-group {
display: flex;
flex-direction: row;
border: 1px solid #ccc;
padding: 8px 10px;
border-radius: 8px;
}

input {
flex-grow: 2;
border: none;
font-size: 16px;
}

input:focus {
outline: none;
}

.feedback-stats {
color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
}

.num-display {
position: absolute;
top: -10px;
left: -10px;
}

.close,
.edit {
position: absolute;
top: 10px;
right: 20px;
cursor: pointer;
background: none;
border: none;
}

.edit {
right: 40px;
}

.btn {
color: #fff;
border: 0;
border-radius: 8px;
color: #fff;
width: 100px;
height: 40px;
cursor: pointer;
}

.btn-primary {
background-color: #202142;
}

.btn-secondary {
background: #ff6a95;
}

.btn:hover {
transform: scale(0.98);
opacity: 0.9;
}

.btn:disabled {
background-color: #cccccc;
color: #333;
cursor: auto;
}

.btn:disabled:hover {
transform: scale(1);
opacity: 1;
}

.message {
padding-top: 10px;
text-align: center;
color: rebeccapurple;
}

/* FIX: Remove position: absolute to keep about icon at the bottom of the
* document */
.about-link {
display: flex;
justify-content: flex-end;
}

/* FIX: Remove position: absolute to keep about icon at the bottom of the
* document */
.about-link a {
color: #fff;
cursor: pointer;
}

.about-link a:hover {
color: #ff6a95;
}

.about h1 {
margin-bottom: 20px;
}

.about p {
margin: 10px 0;
}

@media (max-width: 600px) {
.rating li {
margin: 10px 3px;
}

.rating {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
margin: 30px 0 40px;
}

.input-group input {
width: 80%;
}
}

/* nav link eg */
.active {
background-color: #333;
color: red;
}
1 change: 1 addition & 0 deletions React/test-feed/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import ReactDOM from "react-dom/client";
import { App } from './App'
import './index.css'

const root = ReactDOM.createRoot(document.getElementById('root'))
root.render(
Expand Down
Empty file removed React/test-feed/src/main.css
Empty file.
4 changes: 1 addition & 3 deletions React/test-feed/src/pages/About.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from 'react'

function About() {
export const About = () => {
return (
<div>About</div>
)
}

export default About
Loading

0 comments on commit d2ab96f

Please sign in to comment.