-
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.
- Loading branch information
1 parent
f1b6b0a
commit 953ec7f
Showing
10 changed files
with
348 additions
and
70 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 |
---|---|---|
|
@@ -29,6 +29,7 @@ yarn-error.log* | |
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env | ||
|
||
# vercel | ||
.vercel | ||
.vercel |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { useEffect, useState } from 'react'; | ||
import Image from 'next/image'; | ||
import Router from 'next/router' | ||
|
||
import Carousel from "react-elastic-carousel"; | ||
|
||
import { CarouselFeedStyle } from "./styles"; | ||
import api from '@/service/api'; | ||
import React from 'react'; | ||
import { toast } from 'react-toastify'; | ||
|
||
import { Avatar, Card, CardActions, CardContent, CardHeader, CardMedia, Checkbox, IconButton, Typography } from '@material-ui/core'; | ||
import MoreVertOutlined from '@material-ui/icons/MoreVertOutlined'; | ||
import FavoriteBorderIcon from '@material-ui/icons/FavoriteBorder'; | ||
import ModeCommentOutlinedIcon from '@material-ui/icons/ModeCommentOutlined'; | ||
import ShareOutlinedIcon from '@material-ui/icons/ShareOutlined'; | ||
import TurnedInNotOutlinedIcon from '@material-ui/icons/TurnedInNotOutlined'; | ||
import FavoriteOutlinedIcon from '@material-ui/icons/FavoriteOutlined'; | ||
|
||
import { CardFeedCarousel } from '@/styles/MaterialGuide' | ||
|
||
|
||
export default function CarouselFeed({ feedCarousel }: any) { | ||
const [userData, setUserData] = useState<any[]>([]); | ||
|
||
useEffect(() => { | ||
function handleSetData() { | ||
setUserData(feedCarousel); | ||
console.log(userData); | ||
} | ||
handleSetData(); | ||
}, [feedCarousel]) | ||
|
||
const handleRedirectUserPerfil = (username: string) => () => { | ||
Router.push(`/users/${username}`) | ||
} | ||
|
||
return ( | ||
<CarouselFeedStyle> | ||
<Carousel | ||
showArrows={false} | ||
isRTL | ||
verticalMode | ||
itemPadding={[0, 5]} | ||
breakPoints={ | ||
[ | ||
{ width: 1, itemsToShow: 6 }, | ||
{ width: 550, itemsToShow: 8 }, | ||
{ width: 768, itemsToShow: 10 }, | ||
{ width: 1200, itemsToShow: 12 }, | ||
] | ||
} | ||
> | ||
{userData?.map((feed: any, index: number) => ( | ||
<CardFeedCarousel key={index}> | ||
<CardHeader | ||
avatar={ | ||
<Avatar> | ||
<Image src={feed?.profile_image?.medium} alt={`Profile picture of ${feed?.username}`} width={56} height={56} /> | ||
</Avatar> | ||
} | ||
title={ | ||
<Typography variant="body2" onClick={handleRedirectUserPerfil(feed.username)}>{feed?.username}</Typography> | ||
} | ||
action={ | ||
<IconButton aria-label="settings"> | ||
<MoreVertOutlined /> | ||
</IconButton> | ||
} | ||
/> | ||
<CardMedia | ||
component="img" | ||
height="510" | ||
image={feed?.photos[0]?.urls?.full} | ||
alt={`Profile picture of ${feed?.username}`} | ||
/> | ||
<CardActions> | ||
<section className="first-buttons"> | ||
<Checkbox | ||
icon={<ShareOutlinedIcon />} | ||
checkedIcon={<ShareOutlinedIcon />} | ||
/> | ||
<Checkbox | ||
icon={<ModeCommentOutlinedIcon />} | ||
checkedIcon={<ModeCommentOutlinedIcon />} | ||
/> | ||
<Checkbox | ||
icon={<FavoriteBorderIcon />} | ||
checkedIcon={<FavoriteOutlinedIcon />} | ||
/> | ||
</section> | ||
<Checkbox | ||
icon={<TurnedInNotOutlinedIcon />} | ||
checkedIcon={<TurnedInNotOutlinedIcon />} | ||
/> | ||
</CardActions> | ||
<CardContent> | ||
<Typography variant="body2" component="p"> | ||
{feed?.username} | ||
</Typography> | ||
</CardContent> | ||
</CardFeedCarousel> | ||
))} | ||
</Carousel> | ||
</CarouselFeedStyle > | ||
); | ||
} |
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,39 @@ | ||
import styled from "styled-components"; | ||
|
||
export const CarouselFeedStyle = styled.div` | ||
width: 100%; | ||
height: 100%; | ||
a { | ||
text-decoration: none; | ||
cursor: pointer; | ||
} | ||
.rec-slider-container { | ||
padding: 0; | ||
margin: 0; | ||
} | ||
.rec { | ||
padding: 0; | ||
margin: 0; | ||
} | ||
.rec-dot { | ||
box-shadow: none; | ||
border: none; | ||
background: none; | ||
box-shadow: none; | ||
} | ||
.rec-item-wrapper { | ||
padding: 0; | ||
width: 80px; | ||
} | ||
.MuiTypography-h2 { | ||
color: #262626; | ||
font-size: 12px; | ||
line-height: 16px; | ||
overflow: hidden; | ||
text-align: center; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
`; |
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,16 +1,41 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { HomeStyled } from '@/styles/pages/home'; | ||
|
||
import CarouselPerfil from '@/components/CarouselPerfil'; | ||
import CarouselFeed from '@/components/Feed'; | ||
|
||
import Header from '@/components/Header'; | ||
import api from '@/service/api'; | ||
import { toast } from 'react-toastify'; | ||
|
||
export default function Home() { | ||
const [userData, setUserData] = useState<any[]>([]); | ||
|
||
useEffect(() => { | ||
function fetchApiUnsplash() { | ||
api.get('search/users?', { | ||
params: { | ||
query: 'usa', | ||
client_id: process.env.NEXT_PUBLIC_UNSPLASH_API_KEY | ||
} | ||
}).then((response: any) => setUserData(response.data.results) | ||
).catch(error => toast.warning(error.message)); | ||
} | ||
fetchApiUnsplash(); | ||
}, []) | ||
|
||
return ( | ||
<HomeStyled> | ||
<Header /> | ||
|
||
<div className="home-carousel-content"> | ||
<CarouselPerfil /> | ||
<div className="home-content-mobile"> | ||
<CarouselPerfil userCarousel={userData} /> | ||
</div> | ||
|
||
<div className="home-content-mobile"> | ||
<CarouselFeed feedCarousel={userData} /> | ||
</div> | ||
|
||
</HomeStyled> | ||
) | ||
} |
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.