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

Happy thoughts - Zoe #104

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

Happy thoughts - Zoe #104

wants to merge 19 commits into from

Conversation

zoe-lindqvist
Copy link

Copy link
Contributor

@HIPPIEKICK HIPPIEKICK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well-structured project - good job! Left some comments for you to have a look at and maybe think about for upcoming projects.

api/api.js Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that you abstracted these functions 👍

Comment on lines +8 to +12
<!-- Favicon with heart emoji -->
<link
rel="icon"
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext y='.9em' font-size='90'%3E%E2%9D%A4%EF%B8%8F%3C/text%3E%3C/svg%3E"
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!

@@ -0,0 +1,40 @@
/* eslint-disable react/prop-types */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do this in an eslint config file as well

- 'formatDistanceToNow' from 'date-fns' formats the time,
like "2 minutes ago".
*/}
{formatDistanceToNow(new Date(thought.createdAt), {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const handleSubmit = (event) => {
// Prevent the form's default behavior of reloading the page when submitted
event.preventDefault();
if (message.length < 5 || message.length > 140) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

return (
<form onSubmit={handleSubmit}>
<h1 htmlFor="thought">What’s making you happy right now?</h1>
<input
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input element is generally used for shorter text input, so maybe you'd wanna use a textare instead?

Comment on lines +106 to +120
.heart-button {
background: none;
border: none;
background-color: #ebebeb;
color: #ff4500;
font-size: 1.3em;
cursor: pointer;
transition: transform 0.3s ease, box-shadow 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
padding: 10px;
border-radius: 50%;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably add a fixed width and height to this button to make it round ⚪

Copy link

@HeleneWestrin HeleneWestrin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This project is really well put together! Great job, Zoe 🙌 It was really fun and inspiring to look through your code and see your approach.

The structure is clean and modular, with each component doing its own job, which makes the whole codebase easy to follow and probably to maintain as well. Your naming conventions are clear, and the comments throughout the code add a nice layer of understanding without overwhelming things.

Really nice touch with the optimistic UI update! I left a couple of comments for potential improvements.

Look forward to seeing your next project ✨


return (
<form onSubmit={handleSubmit}>
<h1 htmlFor="thought">What’s making you happy right now?</h1>
Copy link

@HeleneWestrin HeleneWestrin Nov 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "for" (or htmlFor in jsx) is only applicable to <label> and <output>. One suggestion could be to either add a proper label, or if you want the H1 to be the label then maybe add a visually hidden label for screen readers.

// Prevent the form's default behavior of reloading the page when submitted
event.preventDefault();
if (message.length < 5 || message.length > 140) {
alert("Message must be between 5 and 140 characters."); // Show an alert if it's not valid

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work with the validation! One improvement could be to replace the alert with a more modern approach, like an inline error text, which would give a more seamless UX.

}
};

loadThoughts(); // Call the function to fetch thoughts when the component loads

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One enhancement could be to add a loading state when first fetching the posts from the API. On a slow network it might take a while for the posts to load, making the page look broken for users.

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