-
Notifications
You must be signed in to change notification settings - Fork 29
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
Angry happy note #40
Open
johannacatalinismith
wants to merge
33
commits into
Technigo:main
Choose a base branch
from
johannacatalinismith:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Angry happy note #40
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
0b1d778
added link to readme
johannacatalinismith 35f36d0
added map
johannacatalinismith ade2fde
added react router
johannacatalinismith 07c3c5a
made map component
johannacatalinismith 6187fe1
added css
johannacatalinismith 67845b8
added a map id and a note
johannacatalinismith 4567154
added css
johannacatalinismith da5ba2c
create route and placeholder form
johannacatalinismith 617e5c8
set up backend and connected it to the frontend
johannacatalinismith 3e0aa4e
add geolocation api and hide longitude and latitude
johannacatalinismith 6142741
changed how map controls work
johannacatalinismith 5fef7a7
made the map be on every page.
johannacatalinismith 808c280
fixed to that one note is shown at the time
johannacatalinismith efa46d6
fix bug for closing notes
johannacatalinismith c5363cd
fix closing notes
johannacatalinismith 2402692
hide notes after 2 weeks
johannacatalinismith 06f4279
set note title to text
johannacatalinismith 8012486
install material ui
johannacatalinismith 480b3bf
add style
johannacatalinismith dc6369e
prettier
johannacatalinismith adba2f2
add error message
johannacatalinismith 94feb3a
add environment variable
johannacatalinismith e685060
add readme
johannacatalinismith c6ff57b
add readme
johannacatalinismith 6967255
add netlify.toml
johannacatalinismith e826208
add home page content
johannacatalinismith 21383ab
move components into components folder
johannacatalinismith 7313c45
move app layout into its own component
johannacatalinismith fc0b3fb
moved app component to components folder too
johannacatalinismith 5b6ea40
move app component out of components folder
johannacatalinismith 2f15de7
fix import
johannacatalinismith d813e73
increase defaultZoom
johannacatalinismith f1992e7
extract Map component
johannacatalinismith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
# Final Project | ||
# Angry Happy Note | ||
|
||
Replace this readme with your own information about your project. | ||
|
||
Start by briefly describing the assignment in a sentence or two. Keep it short and to the point. | ||
Final project for Technigo web developer bootcamp 2024. Angry Happy Note is a full-stack web app where users can leave angry (or happy) notes at their current location on a public map. | ||
|
||
## The problem | ||
|
||
Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next? | ||
The app is built using Google Maps, React, Vite, and Mongo DB. It's hosted on Netlify, Render, and Mongo DB Atlas. | ||
|
||
## View it live | ||
|
||
Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about. | ||
https://happyangrynote.netlify.app/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[[redirects]] | ||
from= "/*" | ||
to = "/index.html" | ||
status = 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
@import url('https://fonts.googleapis.com/css2?family=Rock+Salt&display=swap'); | ||
|
||
|
||
.App-header { | ||
font-family: "Rock Salt", cursive; | ||
font-weight: 400; | ||
font-style: normal; | ||
background: rgba(240, 237, 25, 0.91); | ||
color: #000000; | ||
font-size: 12px; | ||
margin: 0; | ||
text-align: center; | ||
padding: 10px; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
z-index: 1; | ||
} | ||
|
||
.App-header a { | ||
color: #1334ef; | ||
text-decoration: underline; | ||
font-family: sans-serif; | ||
font-size: 15px; | ||
} | ||
|
||
.App-map { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
} | ||
|
||
.App-menu { | ||
list-style-type: none; | ||
margin: 0; | ||
padding: 0; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
column-gap: 15px; | ||
} | ||
|
||
|
||
/* https://github.com/remix-run/react-router/blob/dev/examples/view-transitions/src/index.css this is about the view transitions that ive added. */ | ||
.App-outlet { | ||
view-transition-name: outlet; | ||
} | ||
|
||
::view-transition-old(outlet) { | ||
animation: 500ms cubic-bezier(0.4, 0, 1, 1) both fade-out, | ||
500ms cubic-bezier(0.4, 0, 0.2, 1) both slide-to-left; | ||
} | ||
|
||
::view-transition-new(outlet) { | ||
animation: 500ms cubic-bezier(0, 0, 0.2, 1) 90ms both fade-in, | ||
500ms cubic-bezier(0.4, 0, 0.2, 1) both slide-from-right; | ||
} | ||
|
||
@keyframes slide-from-right { | ||
from { | ||
transform: translateX(500px); | ||
} | ||
} | ||
|
||
@keyframes slide-to-left { | ||
to { | ||
transform: translateX(-500px); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,127 @@ | ||
export const App = () => { | ||
import { useEffect, useState } from "react"; | ||
// here i imported the router ... https://github.com/remix-run/react-router/tree/dev/examples/view-transitions | ||
import { | ||
createBrowserRouter, | ||
Link, | ||
Outlet, | ||
RouterProvider, | ||
useLocation, | ||
} from "react-router-dom"; | ||
|
||
import { HomePage } from "./components/HomePage"; | ||
import { FormPage } from "./components/FormPage"; | ||
import { LocationContext } from "./LocationContext"; | ||
import { Map } from "./components/Map"; | ||
import { Note } from "./components/Note"; | ||
|
||
import "./App.css"; | ||
|
||
const sweden = { lat: 62.3875, lng: 16.325556 }; | ||
|
||
const AppLayout = () => { | ||
let { pathname } = useLocation(); | ||
const [notes, setNotes] = useState([]); | ||
const [location, setLocation] = useState(sweden); | ||
const [noteId, setNoteId] = useState(""); | ||
|
||
useEffect(() => { | ||
const url = `${import.meta.env.VITE_BACKEND_URL}/notes`; | ||
fetch(url) | ||
.then((response) => response.json()) | ||
.then((data) => setNotes(data)); | ||
// fetch more notes, every time you change page | ||
}, [pathname]); | ||
|
||
useEffect(() => { | ||
if (pathname === "/") { | ||
} else if (pathname === "/new") { | ||
navigator.geolocation.getCurrentPosition((position) => { | ||
setLocation({ | ||
lat: position.coords.latitude, | ||
lng: position.coords.longitude, | ||
}); | ||
}); | ||
} | ||
}, [pathname]); | ||
// Plug in Material ui https://mui.com/base-ui/react-input/ | ||
return ( | ||
<> | ||
<h1>Welcome to Final Project!</h1> | ||
</> | ||
<div className="App"> | ||
<header className="App-header"> | ||
<h1 className="App-title">Angry happy note</h1> | ||
<ul className="App-menu"> | ||
<li> | ||
<Link to="/" unstable_viewTransition> | ||
Note map | ||
</Link> | ||
</li> | ||
<li> | ||
<Link to="/new" unstable_viewTransition> | ||
Add note | ||
</Link> | ||
</li> | ||
</ul> | ||
</header> | ||
|
||
<Map | ||
defaultCenter={sweden} | ||
defaultZoom={5} | ||
center={pathname === "/new" && location.lat && location} | ||
zoom={pathname === "/new" && location.lat !== sweden.lat && 16} | ||
> | ||
<> | ||
{pathname === "/" && | ||
// this is so the user can open one note at a time | ||
notes.map((note) => ( | ||
<Note | ||
key={note._id} | ||
{...note} | ||
open={note._id == noteId} | ||
onClick={() => { | ||
if (note._id === noteId) { | ||
setNoteId(""); | ||
} else { | ||
setNoteId(note._id); | ||
} | ||
}} | ||
/> | ||
))} | ||
</> | ||
</Map> | ||
<div className="App-outlet"> | ||
<LocationContext.Provider value={location}> | ||
<Outlet /> | ||
</LocationContext.Provider> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
// https://github.com/remix-run/react-router/blob/dev/examples/view-transitions/src/main.tsx | ||
// https://stackblitz.com/github/remix-run/react-router/tree/main/examples/view-transitions?file=README.md this is how to make the note slide in and out | ||
const router = createBrowserRouter([ | ||
{ | ||
path: "/", | ||
element: <AppLayout />, | ||
children: [ | ||
{ | ||
index: true, | ||
element: <HomePage />, | ||
}, | ||
{ | ||
path: "/new", | ||
element: <FormPage />, | ||
}, | ||
], | ||
}, | ||
]); | ||
|
||
// https://reactrouter.com/ | ||
export const App = () => ( | ||
<RouterProvider | ||
router={router} | ||
future={{ | ||
// Wrap all state updates in React.startTransition() | ||
v7_startTransition: true, | ||
}} | ||
/> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { createContext } from "react"; | ||
|
||
export const LocationContext = createContext({ lat: 0, lng: 0 }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.FormPage { | ||
display: grid; | ||
place-items: center; | ||
width: 100%; | ||
height: 100vh; | ||
} | ||
|
||
.FormPage-paper { | ||
background: #f0ed18 !important; | ||
} | ||
|
||
.FormPage-form { | ||
display: grid; | ||
gap: 10px; | ||
padding: 20px; | ||
border-radius: 5px; | ||
} | ||
|
||
.FormPage-label { | ||
font-size: 20px; | ||
color: #ffffff; | ||
} | ||
|
||
.FormPage-textarea { | ||
width: 100%; | ||
height: 100px; | ||
padding: 10px; | ||
font-size: 16px; | ||
} | ||
|
||
.FormPage-error { | ||
color: #960000; | ||
font-family: sans-serif; | ||
} | ||
|
||
.FormPage-submit { | ||
padding: 10px; | ||
font-size: 16px; | ||
background-color: #1a8121; | ||
color: #ffffff; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code is correct but readability can be improved, take a look at this refactored code: