-
Notifications
You must be signed in to change notification settings - Fork 124
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
Katarina's Happy Thoughts #87
base: main
Are you sure you want to change the base?
Conversation
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.
Good job with the app! I would like to see the thought-list update immediately when I send a post, but otherwise there is only smaller comments on the code :)
return ( | ||
<div> | ||
<Header /> | ||
<ThoughtsForm /> | ||
<ThoughtsList /> | ||
</div> | ||
) |
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.
Nice and clean app structure! 😃
} | ||
|
||
.submit-button:hover { | ||
transform: scale(1.02); |
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.
Good way of making it bigger on hover.
} | ||
|
||
.thought { | ||
min-width: 600px; |
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.
Should this be max-width, to make sure the content doesn't spill out of the wrapper?
} | ||
|
||
.thought { | ||
min-width: 700px; |
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.
Same here...
headers: { "Content-Type": "application/json" }, | ||
body: JSON.stringify({ message: newThought }), | ||
}) | ||
|
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.
Maybe there could be a way of adding the new new post into the list showing right away, instead of the user having to update the site to see the post?
Something like this:
const json = await response.json()
setThoughts((previousThoughts) => [json, ...previousThoughts])
return ( | ||
<div className="new-thought-wrapper"> | ||
<h2>What's making you happy right now?</h2> | ||
{error && <p style={{ color: "red" }}>{error}</p>} |
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.
Nice error-handling.
rows="5" | ||
cols="30" | ||
minLength={5} | ||
maxLength={140} |
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.
Good way to ensure that the user is not exceeding the limit!
} | ||
if (like.includes(thoughtId)) { | ||
|
||
setLike(like.filter((id) => id !== thoughtId)) |
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.
Is there an easier way of handling the color change?
❤️ | ||
</button> | ||
<p className="like-number">x {thought.hearts}</p> | ||
<div className="time">{formatDistance(new Date(thought.createdAt), Date.now(), { addSuffix: true, })}</div> |
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.
Nice formatting of the date!
.submit-button { | ||
background-color: #ffadad; | ||
padding: 10px; | ||
border-radius: 20px; | ||
width: 50%; | ||
min-width: 220px; | ||
border: 1px solid transparent; | ||
font-weight: bold; | ||
cursor: pointer; | ||
transform: 0.5s; | ||
} | ||
|
||
.submit-button:hover { | ||
transform: scale(1.02); | ||
} |
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.
Why double code for submit-button?
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.
Hi Katarina, one step away from passing this project! When posting a message, you want the post to be immediately listed without refreshing the page. You could, on the post method, call your fetchData()
function, you could pass it as a prop to your ThoughtsForm
component, and then move thefetchData()
inside the parent component, in your case App.jsx
file where you're using your components. Hope this makes sense, take a look at a very similar example shown during class here to understand the flow 👍
Netlify link
https://katarina-happy-thoughts.netlify.app/