diff --git a/README.md b/README.md index 9ea4e26b3..66c555f2d 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,33 @@ -# Happy Thoughts +Project Happy Thoughts - https://project-happy-thoughts-hannah-ek.netlify.app -Replace this readme with your own information about your project. +🏁 Goals: -Start by briefly describing the assignment in a sentence or two. Keep it short and to the point. +I was tasked with building a Twitter like app using an API to collect 'Happy Thoughts' in React and I have successfully completed what I set out to do. -## The problem +The app has three main functionalities - adding thoughts, listing thoughts, and toggling a 'like' status. I decided to keep the design quite simple as I did not wan't it to be overly complex. -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? +Overall, I found this project to be a great opportunity to flex my React muscles and bring together different parts of React and working with fetching and posting to an API. I am very pleased with the outcome and I'm looking forward to using the skills and knowledge I gained from this project in future endeavors. -## View it live +Must-have requirements: -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. +✅ Follow a given design as close as possible. + +✅ List the most recent thoughts at the top and older thoughts at the bottom (sorted). + +✅ Show the content of the message and how many likes the thoughts have received. + +✅ Have a form to post new thoughts. + +✅ Implement a heart button to send likes on a thought. + +🚧 The problem: + +I started by going through the design and sketching the different components out, deciding on how to structure my app. Then I started building also decided on adding a loading component for when the page re-renders. + +If I had more time, I would add more functionality. + +💻 Tech stack: + +JavaScript React CSS HTML Figma + +View it live https://project-happy-thoughts-hannah-ek.netlify.app diff --git a/code/package-lock.json b/code/package-lock.json index f7e97e1e9..fab8e56d2 100644 --- a/code/package-lock.json +++ b/code/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "dependencies": { "babel-eslint": "^10.1.0", + "date-fns": "^2.29.3", "eslint": "^8.21.0", "eslint-config-airbnb": "^19.0.4", "eslint-plugin-import": "^2.26.0", @@ -6205,6 +6206,18 @@ "node": ">=10" } }, + "node_modules/date-fns": { + "version": "2.29.3", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz", + "integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==", + "engines": { + "node": ">=0.11" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/date-fns" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -21996,6 +22009,11 @@ "whatwg-url": "^8.0.0" } }, + "date-fns": { + "version": "2.29.3", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz", + "integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==" + }, "debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", diff --git a/code/package.json b/code/package.json index 68869f589..4cbbdb2d2 100644 --- a/code/package.json +++ b/code/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "babel-eslint": "^10.1.0", + "date-fns": "^2.29.3", "eslint": "^8.21.0", "eslint-config-airbnb": "^19.0.4", "eslint-plugin-import": "^2.26.0", diff --git a/code/public/index.html b/code/public/index.html index e6730aa66..16b949fd5 100644 --- a/code/public/index.html +++ b/code/public/index.html @@ -4,6 +4,9 @@ + + + - Technigo React App + Project Happy Thoughts diff --git a/code/src/App.js b/code/src/App.js index f2007d229..b44a2edf7 100644 --- a/code/src/App.js +++ b/code/src/App.js @@ -1,9 +1,16 @@ import React from 'react'; +import { ThoughtFeed } from 'components/ThoughtFeed'; +import { NewThought } from 'components/NewThought'; export const App = () => { return ( -
- Find me in src/app.js! -
- ); -} + <> +
+ +
+
+ +
+ + ) +} \ No newline at end of file diff --git a/code/src/components/NewThought.js b/code/src/components/NewThought.js new file mode 100644 index 000000000..c09514cb2 --- /dev/null +++ b/code/src/components/NewThought.js @@ -0,0 +1,51 @@ +import React, { useState } from 'react'; + +export const NewThought = () => { + const [newThought, setNewThought] = useState(''); + + const HandleFormSubmit = (event) => { + event.preventDefault(); + if (newThought.length < 5) { + return alert('Get on that keyboard, more than 5 characters, please!') + } else if (newThought.length > 140) { + return alert('Are you some sort of hacker?! No more than 140 characters, please!') + } else { + const Submit = { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ message: newThought }) + }; + fetch('https://happy-thoughts-ux7hkzgmwa-uc.a.run.app/thoughts', Submit) + .then((response) => response.json()) + .then(() => { + setNewThought(''); + setTimeout(() => window.location.reload(), 3000) + }) + } + }; + + return ( +
+
+