Skip to content

Commit

Permalink
Merge pull request #1 from adrianhajdin/ui-changes
Browse files Browse the repository at this point in the history
UI changes
  • Loading branch information
adrianhajdin committed Aug 7, 2022
2 parents 18d26f3 + 5ac8745 commit db9f374
Show file tree
Hide file tree
Showing 21 changed files with 946 additions and 837 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
REACT_APP_RAPID_API_KEY=iFUdxubHsQmshe51vbzzowIsXzBrp1zQDPGjsnlyuFeYlDeBLs
REACT_APP_RAPID_API_KEY=KJwZZIJSFimshuivMSVGaiYzkRomp15f2vKjsnK4bKzuUzVLzA
956 changes: 650 additions & 306 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 4 additions & 28 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,15 @@
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>YT</title>
<title>JSM Media</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
15 changes: 2 additions & 13 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
import { Box } from '@mui/material';

import {
ChannelDetail,
VideoDetail,
SearchFeed,
Navbar,
Feed,
} from './components';
import { ChannelDetail, VideoDetail, SearchFeed, Navbar, Feed } from './components';

const App = () => (
<Router>
<Box
sx={{
p: 1,
bgcolor: '#000',
}}
>
<Box sx={{ backgroundColor: '#000' }}>
<Navbar />
<Switch>
<Route exact path='/' component={Feed} />
Expand Down
52 changes: 0 additions & 52 deletions src/components/Categories.jsx

This file was deleted.

59 changes: 26 additions & 33 deletions src/components/ChannelCard.jsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,42 @@
import React from 'react';
import { Card, CardContent, CardMedia, Typography } from '@mui/material';
import { Box, CardContent, CardMedia, Typography } from '@mui/material';
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
import { Link } from 'react-router-dom';

const ChannelCard = ({ channelDetail, mt }) => (
<Card
const ChannelCard = ({ channelDetail, marginTop }) => (
<Box
sx={{
boxShadow: 'none',
borderRadius: '20px',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'column',
width: { xs: '350px', md: '320px' },
width: { xs: '356px', md: '320px' },
height: '326px',
margin: 'auto',
mt,
background: '#000',
marginTop,
}}
>
<CardMedia
component='img'
height='160'
image={channelDetail?.snippet?.thumbnails?.high.url}
alt='channel-img'
sx={{
borderRadius: '50%',
width: '160px',
border: '1px solid #e3e3e3',
}}
/>
<CardContent sx={{ textAlign: 'center', color: '#fff' }}>
<Typography sx={{ fontSize: '18px', fontWeight: 700 }}>
{channelDetail?.snippet?.title}{' '}
<CheckCircleIcon sx={{ fontSize: '14px', color: 'gray', ml: '5px' }} />
</Typography>
{channelDetail?.statistics?.subscriberCount && (
<Typography sx={{ fontSize: '15px', fontWeight: 500, color: 'gray' }}>
{channelDetail?.statistics?.subscriberCount &&
parseInt(channelDetail?.statistics?.subscriberCount).toLocaleString(
'en-US'
)}{' '}
Subscribers
<Link to={`/channel/${channelDetail?.id?.channelId}`}>
<CardContent sx={{ display: 'flex', flexDirection: 'column', justifyContent: 'center', textAlign: 'center', color: '#fff' }}>
<CardMedia
image={channelDetail?.snippet?.thumbnails?.high?.url}
alt={channelDetail?.snippet?.title}
sx={{ borderRadius: '50%', height: '180px', width: '180px', mb: 2, border: '1px solid #e3e3e3' }}
/>
<Typography variant="h6">
{channelDetail?.snippet?.title}{' '}
<CheckCircleIcon sx={{ fontSize: '14px', color: 'gray', ml: '5px' }} />
</Typography>
)}
</CardContent>
</Card>
{console.log(channelDetail)}
{channelDetail?.statistics?.subscriberCount && (
<Typography sx={{ fontSize: '15px', fontWeight: 500, color: 'gray' }}>
{parseInt(channelDetail?.statistics?.subscriberCount).toLocaleString('en-US')} Subscribers
</Typography>
)}
</CardContent>
</Link>
</Box>
);

export default ChannelCard;
45 changes: 22 additions & 23 deletions src/components/ChannelDetail.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useState, useEffect } from 'react';
import { useParams } from 'react-router-dom';
import { Box } from '@mui/material';
import React, { useState, useEffect } from "react";
import { useParams } from "react-router-dom";
import { Box } from "@mui/material";

import { Videos, ChannelCard, Loader } from './';
import { axiosGetReq } from '../utils';
import { Videos, ChannelCard } from "./";
import { fetchFromAPI } from "../utils/fetchFromAPI";

const ChannelDetail = () => {
const [channelDetail, setChannelDetail] = useState();
Expand All @@ -13,34 +13,33 @@ const ChannelDetail = () => {

useEffect(() => {
const fetchResults = async () => {
const data = await axiosGetReq(`channels?part=snippet&id=${id}`);
const data = await fetchFromAPI(`channels?part=snippet&id=${id}`);

setChannelDetail(data?.items[0]);

const videosData = await axiosGetReq(`search?channelId=${id}&part=snippet%2Cid&order=date`);
const videosData = await fetchFromAPI(`search?channelId=${id}&part=snippet%2Cid&order=date`);

setVideos(videosData?.items);
};

fetchResults();
}, []);

if (!videos) <Loader />;
}, [id]);

return (
<>
<Box minHeight="95vh">
<Box>
<img
src={channelDetail?.brandingSettings?.image?.bannerExternalUrl}
alt='channel-art'
style={{
height: '300px',
width: '100%',
borderRadius: '8px',
}}
/>
<ChannelCard channelDetail={channelDetail} mt='-93px' />
<div style={{
height:'300px',
background: 'linear-gradient(90deg, rgba(0,238,247,1) 0%, rgba(206,3,184,1) 100%, rgba(0,212,255,1) 100%)',
zIndex: 10,
}} />
<ChannelCard channelDetail={channelDetail} marginTop="-93px" />
</Box>
<Box p={2} display="flex">
<Box sx={{ mr: { sm: '100px' } }}/>
<Videos videos={videos} />
</Box>
<Videos videos={videos} />
</>
</Box>
);
};

Expand Down
78 changes: 19 additions & 59 deletions src/components/Feed.jsx
Original file line number Diff line number Diff line change
@@ -1,75 +1,35 @@
import React, { useEffect, useState } from 'react';
import { Box, Stack, Typography } from '@mui/material';
import React, { useEffect, useState } from "react";
import { Box, Stack, Typography } from "@mui/material";

import { Videos, Categories } from './';
import { axiosGetReq } from '../utils';
import { fetchFromAPI } from "../utils/fetchFromAPI";
import { Videos, Sidebar } from "./";

const Feed = () => {
const [selectedCategory, setSelectedCategory] = useState('all');
const [selectedCategory, setSelectedCategory] = useState("New");
const [videos, setVideos] = useState(null);

useEffect(() => {
setVideos(null);
const fetchVideos = async () => {
const data = await axiosGetReq(
`search?part=snippet&q=${selectedCategory}`
);
setVideos(data.items);
};

fetchVideos();
}, [selectedCategory]);
fetchFromAPI(`search?part=snippet&q=${selectedCategory}`)
.then((data) => setVideos(data.items))
}, [selectedCategory]);

return (
<Stack sx={{ flexDirection: { sx: 'column', md: 'row' } }}>
<Box sx={{ position: 'relative' }}>
<Categories
selectedCategory={selectedCategory}
setSelectedCategory={setSelectedCategory}
/>
<p
className='copyright'
style={{
position: 'absolute',
bottom: '15px',
color: '#fff',
fontSize: '15px',
left: '30px',
opacity: '0.8',
}}
>
Copyright © 2022 YT, Inc.
</p>
<Stack sx={{ flexDirection: { sx: "column", md: "row" } }}>
<Box sx={{ height: { sx: "auto", md: "92vh" }, borderRight: "1px solid #3d3d3d", px: { sx: 0, md: 2 } }}>
<Sidebar selectedCategory={selectedCategory} setSelectedCategory={setSelectedCategory} />

<Typography className="copyright" variant="body2" sx={{ mt: 1.5, color: "#fff", }}>
Copyright © 2022 JSM Media
</Typography>
</Box>

<Box
sx={{
overflow: 'auto',
height: '90vh',
flex: 2,
}}
>
<Typography
fontSize={25}
fontWeight={900}
textAlign='center'
pt={1}
pb={2}
sx={{ textTransform: 'capitalize', color: 'white' }}
>
{selectedCategory || 'Recommended'} Videos
<Box p={2} sx={{ overflowY: "auto", height: "90vh", flex: 2 }}>
<Typography variant="h4" fontWeight="bold" mb={2} sx={{ color: "white" }}>
{selectedCategory} <span style={{ color: "#FC1503" }}>videos</span>
</Typography>
{/* <Stack direction='row' gap='20px' sx={{ width: '80%', margin: 'auto' }}>
<Link to='/video/jfKfPfyJRdk' style={{width:'100%'}}>
<img
style={{ height: '400px', width: '100%' }}
src={
'https://media.npr.org/assets/img/2022/07/14/lofi-girl-picture_custom-27a34c6d0ca36f828940156e7bd3c964140cff9c.jpg'
}
alt='recommended video'
/>
</Link>
</Stack> */}

<Videos videos={videos} />
</Box>
</Stack>
Expand Down
10 changes: 6 additions & 4 deletions src/components/Loader.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import { CircularProgress, Stack } from '@mui/material';
import { Box, CircularProgress, Stack } from '@mui/material';

const Loader = () => (
<Stack direction='row' justifyContent='center' alignItems='center' height='80vh' >
<CircularProgress />
</Stack>
<Box minHeight="95vh">
<Stack direction='row' justifyContent='center' alignItems='center' height='80vh' >
<CircularProgress />
</Stack>
</Box>
);

export default Loader;
Loading

0 comments on commit db9f374

Please sign in to comment.