forked from b00tc4mp/isdi-parttime-202403
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add create post form compo and logic; add post list auto refresh on p…
…ost created; b00tc4mp#149
- Loading branch information
unknown
authored and
unknown
committed
Jun 16, 2024
1 parent
b0e1cdc
commit 744728f
Showing
15 changed files
with
162 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[] | ||
[{"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"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,6 @@ | |
background-color: rgb(228, 179, 34); | ||
border-radius: 30%; | ||
align-items: center; | ||
width: 20rem; | ||
width: 30rem; | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
staff/mateo-gomez/socialcode/app/src/components/core/Heading.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
staff/mateo-gomez/socialcode/app/src/components/core/Image.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
.Image { | ||
width: 100%; | ||
width: 80%; | ||
display: flex; | ||
justify-content: center; | ||
border-radius: 5%; | ||
display: block; | ||
margin: 2rem auto; | ||
} |
9 changes: 9 additions & 0 deletions
9
staff/mateo-gomez/socialcode/app/src/components/core/Title.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
5 changes: 3 additions & 2 deletions
5
staff/mateo-gomez/socialcode/app/src/components/core/Title.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import Heading from './Heading' | ||
import './Title.css' | ||
|
||
|
||
function Title({ children }) { | ||
return <Heading level='1'>{children}</Heading> | ||
function Title({ className, children }) { | ||
return <Heading className={`MainTitle ${className ? className : ''}`} level='1'>{children}</Heading> | ||
} | ||
|
||
export default Title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
staff/mateo-gomez/socialcode/app/src/views/components/CreatePostForm.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.CreatePostForm { | ||
position: fixed; | ||
justify-content: center; | ||
align-items: center; | ||
bottom: 10rem; | ||
width: 30rem; | ||
box-sizing: border-box; | ||
background-color: rgba(255, 191, 0, 0.792); | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
staff/mateo-gomez/socialcode/app/src/views/components/CreatePostForm.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import logic from '../../logic' | ||
import './CreatePostForm.css' | ||
|
||
function CreatePostForm({ onCancelCreatePostClick, onPostCreated }) { | ||
console.log('CreatePostForm -> render') | ||
|
||
const handleCancelCreatePostClick = () => onCancelCreatePostClick() | ||
|
||
const handleCreatePostSubmit = event => { | ||
event.preventDefault() | ||
|
||
const form = event.target | ||
|
||
const title = form.title.value | ||
const image = form.image.value | ||
const description = form.description.value | ||
|
||
try { | ||
logic.createPost(title, image, description, error => { | ||
if (error) { | ||
console.error(error) | ||
|
||
alert(error.message) | ||
|
||
return | ||
} | ||
|
||
onPostCreated() | ||
|
||
}) | ||
|
||
} catch (error) { | ||
console.error(error) | ||
|
||
alert(error.message) | ||
} | ||
|
||
} | ||
|
||
return <form className="Form FormWithFeedback CreatePostForm" onSubmit={handleCreatePostSubmit}> | ||
<div className="Field FormInput"> | ||
<label htmlFor="title">Title</label> | ||
<input className="Input" id="title" type="text" placeholder="title" /> | ||
</div> | ||
|
||
<div className="Field FormInput"> | ||
<label htmlFor="image">Image</label> | ||
<input className="Input" id="image" type="text" placeholder="image" /> | ||
</div> | ||
<div className="Field description-input"> | ||
<label htmlFor="description">Description</label> | ||
<input className="Input" id="description" type="text" placeholder="description" /> | ||
</div> | ||
|
||
<button className="Button" type="button" onClick={handleCancelCreatePostClick}>Cancel</button> | ||
<button className="Button SubmitButton" type="submit">Create</button> | ||
|
||
<p className='Feedback'>image is not valid</p> | ||
</form> | ||
} | ||
|
||
|
||
export default CreatePostForm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
justify-content: center; | ||
padding: 1 rem 0; | ||
box-sizing: content-box; | ||
height: 3.5rem; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.