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 heading and image core components; update title and view compos; …
…add user name retrieval and rendering in home; add post list compo in home with posts retrieval and redering; b00tc4mp#149
- Loading branch information
unknown
authored and
unknown
committed
Jun 12, 2024
1 parent
4dc5cb3
commit 5fbddd5
Showing
10 changed files
with
130 additions
and
9 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function Heading({ level, className, children }) { | ||
const Tag = `h${level}` | ||
|
||
return <Tag className={` ${className ? className : ''}`}>{children}</Tag> | ||
|
||
} | ||
|
||
export default Heading |
7 changes: 7 additions & 0 deletions
7
staff/mateo-gomez/socialcode/app/src/components/core/Image.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,7 @@ | ||
import './Image.css' | ||
|
||
function Image({ src, className }) { | ||
return <img className={`Image ${className ? className : ''}`} src={src} /> | ||
} | ||
|
||
export default Image |
5 changes: 4 additions & 1 deletion
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,5 +1,8 @@ | ||
import Heading from './Heading' | ||
|
||
|
||
function Title({ children }) { | ||
return <h1>{children}</h1> | ||
return <Heading 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
4 changes: 2 additions & 2 deletions
4
staff/mateo-gomez/socialcode/app/src/components/library/View.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,7 +1,7 @@ | ||
import './View.css' | ||
|
||
function View({ tag: Tag = 'div', children }) { | ||
return <Tag className="View">{children}</Tag> | ||
function View({ tag: Tag = 'div', className, children }) { | ||
return <Tag className={`View ${className ? className : ''}`}>{children}</Tag> | ||
} | ||
|
||
export default View |
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
8 changes: 8 additions & 0 deletions
8
staff/mateo-gomez/socialcode/app/src/views/components/Post.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,8 @@ | ||
.Post { | ||
width: 50rem; | ||
height: auto; | ||
background-color: aliceblue; | ||
border: 1px solid orange; | ||
margin: 2rem; | ||
border-radius: 4%; | ||
} |
8 changes: 8 additions & 0 deletions
8
staff/mateo-gomez/socialcode/app/src/views/components/PostList.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,8 @@ | ||
.PostList { | ||
position: center; | ||
bottom: 0; | ||
width: 100%; | ||
left: 0; | ||
box-sizing: border-box; | ||
background-color: rgba(255, 191, 0, 0.792); | ||
} |
61 changes: 61 additions & 0 deletions
61
staff/mateo-gomez/socialcode/app/src/views/components/PostList.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,61 @@ | ||
import './PostList.css' | ||
import './Post.css' | ||
|
||
import Image from "../../components/core/Image" | ||
import Heading from '../../components/core/Heading' | ||
import View from "../../components/library/View" | ||
|
||
import logic from '../../logic' | ||
import { useEffect, useState } from 'react' | ||
|
||
function PostList() { | ||
console.log('PostList -> render') | ||
|
||
const [posts, setPosts] = useState([]) | ||
|
||
useEffect(() => { | ||
console.log('PostList -> useEffect') | ||
|
||
try { | ||
logic.getAllPosts((error, posts) => { | ||
if (error) { | ||
console.error(error) | ||
|
||
alert(error.message) | ||
|
||
return | ||
} | ||
|
||
setPosts(posts) | ||
}) | ||
|
||
} catch (error) { | ||
console.error(error) | ||
|
||
alert(error.message) | ||
} | ||
}, []) | ||
|
||
return <View tag="section" className='PostList'> | ||
|
||
{posts.map(post => <article className="Post"> | ||
<p className="AuthorTitle">{post.author}</p> | ||
<Heading level='2' className="PostTitle">{post.title}</Heading> | ||
<Image className="PostImage" src={post.image} /> | ||
<Heading level='4' className="DescriptionTitle"> | ||
Description: | ||
</Heading> | ||
<p className="PostDescription"> | ||
{post.description}</p> | ||
<time>{post.date}</time> | ||
<button className="Button">Delete</button> | ||
</article> | ||
|
||
)} | ||
|
||
|
||
</View> | ||
|
||
} | ||
|
||
export default PostList |