From 744728fcd7d8c0574845d9fb079c17a3b1668f58 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 16 Jun 2024 12:53:51 +0200 Subject: [PATCH] add create post form compo and logic; add post list auto refresh on post created; #149 --- .../socialcode/api/data/posts.json | 2 +- .../app/src/components/core/Form.css | 2 +- .../app/src/components/core/Heading.jsx | 2 +- .../app/src/components/core/Image.css | 7 ++- .../app/src/components/core/Title.css | 9 +++ .../app/src/components/core/Title.jsx | 5 +- .../app/src/components/library/View.css | 19 +++--- .../socialcode/app/src/views/Home.jsx | 39 +++++------- .../socialcode/app/src/views/Login.jsx | 4 +- .../src/views/components/CreatePostForm.css | 10 +++ .../src/views/components/CreatePostForm.jsx | 63 +++++++++++++++++++ .../app/src/views/components/Footer.css | 1 + .../app/src/views/components/Post.css | 40 ++++++++---- .../app/src/views/components/Post.jsx | 9 ++- .../app/src/views/components/PostList.jsx | 11 +--- 15 files changed, 162 insertions(+), 61 deletions(-) create mode 100644 staff/mateo-gomez/socialcode/app/src/components/core/Title.css create mode 100644 staff/mateo-gomez/socialcode/app/src/views/components/CreatePostForm.css create mode 100644 staff/mateo-gomez/socialcode/app/src/views/components/CreatePostForm.jsx diff --git a/staff/mateo-gomez/socialcode/api/data/posts.json b/staff/mateo-gomez/socialcode/api/data/posts.json index 0637a088a..1d8989210 100644 --- a/staff/mateo-gomez/socialcode/api/data/posts.json +++ b/staff/mateo-gomez/socialcode/api/data/posts.json @@ -1 +1 @@ -[] \ No newline at end of file +[{"author":"doncic","title":"doncic","image":"https://media.giphy.com/media/l0ExdMHUDKteztyfe/giphy.gif?cid=790b7611b1gu00qk8rbgliucmzz3s3zkyr97bfj5gunwfq0u&ep=v1_gifs_search&rid=giphy.gif&ct=g","description":"klk","date":"2024-06-13T10:56:31.500Z","id":"31351023829888214-1718276191500"},{"author":"doncic","title":"hola","image":"https://media.giphy.com/media/lJNoBCvQYp7nq/giphy.gif?cid=790b7611evab4y6j4wimm5zlr11t8447uuplrw52hurba6va&ep=v1_gifs_search&rid=giphy.gif&ct=g","description":"k tal","date":"2024-06-14T07:34:46.627Z","id":"7169851230536599-1718350486628"},{"author":"doncic","title":"1","image":"https://media.giphy.com/media/lJNoBCvQYp7nq/giphy.gif?cid=790b7611evab4y6j4wimm5zlr11t8447uuplrw52hurba6va&ep=v1_gifs_search&rid=giphy.gif&ct=g","description":"2","date":"2024-06-14T07:54:09.256Z","id":"987646978818935-1718351649256"},{"author":"doncic","title":"3","image":"https://media.giphy.com/media/dT7LBdAZP1Rh6/giphy.gif?cid=790b7611evab4y6j4wimm5zlr11t8447uuplrw52hurba6va&ep=v1_gifs_search&rid=giphy.gif&ct=g","description":"1","date":"2024-06-14T07:54:45.305Z","id":"3817116222012884-1718351685305"}] \ No newline at end of file diff --git a/staff/mateo-gomez/socialcode/app/src/components/core/Form.css b/staff/mateo-gomez/socialcode/app/src/components/core/Form.css index c99491e6f..2f73de328 100644 --- a/staff/mateo-gomez/socialcode/app/src/components/core/Form.css +++ b/staff/mateo-gomez/socialcode/app/src/components/core/Form.css @@ -4,6 +4,6 @@ background-color: rgb(228, 179, 34); border-radius: 30%; align-items: center; - width: 20rem; + width: 30rem; } \ No newline at end of file diff --git a/staff/mateo-gomez/socialcode/app/src/components/core/Heading.jsx b/staff/mateo-gomez/socialcode/app/src/components/core/Heading.jsx index 017504e5a..f99a4043a 100644 --- a/staff/mateo-gomez/socialcode/app/src/components/core/Heading.jsx +++ b/staff/mateo-gomez/socialcode/app/src/components/core/Heading.jsx @@ -1,7 +1,7 @@ function Heading({ level, className, children }) { const Tag = `h${level}` - return {children} + return {children} } diff --git a/staff/mateo-gomez/socialcode/app/src/components/core/Image.css b/staff/mateo-gomez/socialcode/app/src/components/core/Image.css index d1abcb0ea..00ae2b96c 100644 --- a/staff/mateo-gomez/socialcode/app/src/components/core/Image.css +++ b/staff/mateo-gomez/socialcode/app/src/components/core/Image.css @@ -1,3 +1,8 @@ .Image { - width: 100%; + width: 80%; + display: flex; + justify-content: center; + border-radius: 5%; + display: block; + margin: 2rem auto; } \ No newline at end of file diff --git a/staff/mateo-gomez/socialcode/app/src/components/core/Title.css b/staff/mateo-gomez/socialcode/app/src/components/core/Title.css new file mode 100644 index 000000000..02fd10cc6 --- /dev/null +++ b/staff/mateo-gomez/socialcode/app/src/components/core/Title.css @@ -0,0 +1,9 @@ +.MainTitle { + font-family: 'Pacifico', sans-serif; + font-size: 60px; + display: flex; + justify-content: center; + margin-top: -100px; + -webkit-text-stroke: 0.01rem rgb(111, 59, 7); + text-shadow: 10px 7px 6px rgba(54, 29, 3, 0.64); +} \ No newline at end of file diff --git a/staff/mateo-gomez/socialcode/app/src/components/core/Title.jsx b/staff/mateo-gomez/socialcode/app/src/components/core/Title.jsx index 188369f33..22f9f1f9d 100644 --- a/staff/mateo-gomez/socialcode/app/src/components/core/Title.jsx +++ b/staff/mateo-gomez/socialcode/app/src/components/core/Title.jsx @@ -1,8 +1,9 @@ import Heading from './Heading' +import './Title.css' -function Title({ children }) { - return {children} +function Title({ className, children }) { + return {children} } export default Title \ No newline at end of file diff --git a/staff/mateo-gomez/socialcode/app/src/components/library/View.css b/staff/mateo-gomez/socialcode/app/src/components/library/View.css index 724332225..59698cd15 100644 --- a/staff/mateo-gomez/socialcode/app/src/components/library/View.css +++ b/staff/mateo-gomez/socialcode/app/src/components/library/View.css @@ -1,7 +1,8 @@ @import url('https://fonts.googleapis.com/css2?family=Micro+5+Charted&family=Pacifico&display=swap'); .View { - height: 100vh; + height: auto; + min-height: 100vh; display: flex; flex-direction: column; align-items: center; @@ -10,12 +11,12 @@ } -.MainTitle { - font-family: 'Pacifico', sans-serif; - font-size: 60px; - display: flex; - justify-content: center; - margin-top: -100px; - -webkit-text-stroke: 0.01rem rgb(111, 59, 7); - text-shadow: 10px 7px 6px rgba(54, 29, 3, 0.64); + + +.View .FormWithFeedback { + margin-top: 15rem; +} + +.View .login { + color: blue; } \ No newline at end of file diff --git a/staff/mateo-gomez/socialcode/app/src/views/Home.jsx b/staff/mateo-gomez/socialcode/app/src/views/Home.jsx index 5e32b831f..9413ab575 100644 --- a/staff/mateo-gomez/socialcode/app/src/views/Home.jsx +++ b/staff/mateo-gomez/socialcode/app/src/views/Home.jsx @@ -1,5 +1,4 @@ import { useState, useEffect } from 'react' -import Title from '../components/core/Title' import View from '../components/library/View' import Header from './components/Header' import Button from '../components/core/Button' @@ -7,12 +6,14 @@ import logic from '../logic' import Heading from '../components/core/Heading' import PostList from './components/PostList' import Footer from './components/Footer' +import CreatePostForm from './components/CreatePostForm' function Home({ onUserLoggedOut }) { console.log('Home -> render') const [name, setName] = useState('') const [view, setView] = useState('') + const [postListRefreshStamp, setPostListRefreshStamp] = useState(0) const handleLogout = () => { logic.logoutUser() @@ -31,6 +32,8 @@ function Home({ onUserLoggedOut }) { return } + console.log('Home -> setName') + setName(name) }) @@ -43,34 +46,26 @@ function Home({ onUserLoggedOut }) { const handleCreatePostClick = () => setView('create-post') - const handleCancelCreatePost = () => setView('') + const handleCancelCreatePostClick = () => setView('') + + const handlePostCreated = () => { + setPostListRefreshStamp(Date.now()) + + setView('') + } + + return
{name}
+ - - - {view === 'create-post' &&
-
- - -
- -
- - -
-
- - -
- - - -
} + + + {view === 'create-post' && }