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

Project happy thoughts #449

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Conversation

SofiaGerdmar
Copy link

No description provided.

Copy link

@JohLeo JohLeo left a comment

Choose a reason for hiding this comment

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

Well done!! Your project is so pretty and I loove the colours! One tiny improvement would be to split the logic for fetching and submitting thoughts into their own functions outside of the App component. That would make the code more modular and easier to test.
The App component can then call these functions as needed. The(very nice) loading spinner can be placed in its own componen as well, which can be reused throughout the application!
But that is just a preference! Be proud you have done a great job, again!! 🤩☀️

code/src/App.js Outdated
Comment on lines 12 to 19
const fetchThoughts = () => {
setLoading(true)
fetch('https://happy-thoughts-ux7hkzgmwa-uc.a.run.app/thoughts')
.then((response) => response.json())
.then((data) => setThoughtsList(data))
.catch((error) => console.log(error))
.finally(() => { setLoading(false) })
}
Copy link

Choose a reason for hiding this comment

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

To keep the App component cleaner (not really necessary I think in this size of projects but a good practise for the future when we work in bigger projects) this could've been places in one of your components. Since this is fetching the thoughts from the API it would be neat to place it in your ListThoughts.js maybe!

Comment on lines +21 to +24
useEffect(() => {
fetchThoughts()
}, [])

Copy link

Choose a reason for hiding this comment

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

This hook is to call the fetchThoughts function when the component is mounted so this should/could/would also be moved if so we were to change the structure for a "cleaner" App.js

const handleFormSubmit = (event) => {
event.preventDefault()
setLoading(true)

Copy link

Choose a reason for hiding this comment

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

Since the "handleFormSubmit" handles the submission of a new thought it could be moved into your component "submitThoughts.js" instead if we want to continue on "cleaning" the app.js a bit.

Comment on lines +13 to +34
return (
<section className="listSection">
{thoughtsList.map((thought) => {
return (
<div className="listBox">
<p className="thought" key={thought._id}>{thought.message}</p>
<div className="list">
<button
className={thought.hearts === 0 ? 'heartBtn' : 'likedBtn'}
type="submit"
onClick={() => handleLikeChange(thought._id)}>
💛
</button>
<p>x {thought.hearts}</p>
<div>
<p className="time">{getTimeAgo(thought.createdAt)}</p>
</div>
</div>
</div>
)
})}
</section>
Copy link

Choose a reason for hiding this comment

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

Very nice and tidy indentation, pretty code!

if (textLength < 5) {
setErrorAlert('Your message needs to be at least 5 characters long. 😊')
} else if (textLength > 140) {
setErrorAlert('Whoa Nelly! Save the essay for your portfolio. 😄')
Copy link

Choose a reason for hiding this comment

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

I wish I tried writing a message that was to long, fuunny! 😂

Comment on lines +77 to +79
.errorAlert {
font-size: 12px;
margin-bottom: 10px;
Copy link

Choose a reason for hiding this comment

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

Oh so the alert pops up in the thoughstlist instead of beeing an actual alert! Is that on purpose?

Comment on lines 122 to 126
.thought {
margin-left: 10px;
font-family: 'Courier New', Courier, monospace;
font-weight: 500;
}
Copy link

Choose a reason for hiding this comment

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

How and where in you code are you making the text of this card to not overflow if it where an textsnippet that was to long? In the inspect there is a "overflow-wrap: anywhere;" but i cannot find it and how you did it. Is it magic? Curios to know!

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.

2 participants