Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Katarina's Happy Thoughts #87

wants to merge 5 commits into from

Conversation

KatSjolin
Copy link

Copy link

@Tejpex Tejpex left a 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 :)

Comment on lines +7 to +13
return (
<div>
<Header />
<ThoughtsForm />
<ThoughtsList />
</div>
)
Copy link

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);
Copy link

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;
Copy link

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;
Copy link

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 }),
})

Copy link

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&#39;s making you happy right now?</h2>
{error && <p style={{ color: "red" }}>{error}</p>}
Copy link

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}
Copy link

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))
Copy link

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>
Copy link

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!

Comment on lines +15 to +29
.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);
}
Copy link

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?

Copy link
Contributor

@AntonellaMorittu AntonellaMorittu left a 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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants