Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nitin => Article Page in Progress #4

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Nitin => Article Page in Progress
  • Loading branch information
nitinkadam70 committed May 4, 2022
commit 8b8055baf85158f21efffa42cedbbd4846e099a9
50 changes: 30 additions & 20 deletions my-app/public/index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<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"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--

<head>
<meta charset="utf-8" />
<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" />
<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="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
<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.
@@ -24,12 +22,23 @@
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>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
/>
<!-- Icons to support Material Design -->
<link
rel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons"
/>
</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.

@@ -39,5 +48,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</body>

</html>
159 changes: 158 additions & 1 deletion my-app/src/Components/Styled.js
Original file line number Diff line number Diff line change
@@ -90,7 +90,6 @@ padding-top: 10px;
padding-bottom: 10px;
text-align: -webkit-center;
color: #ffffff;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
@@ -125,3 +124,161 @@ export const Para = styled.p`
font-size: 10px;
line-height: 0.2;
`;

//Article page
export const ArticleHeader = styled.div`
background-color: rgb(240, 240, 240);
padding: 20px 200px 30px 200px;
text-align: justify;
border-spacing: 2px;
`;

export const Apara = styled.p``;
export const Ahedd = styled.h1`
font-size: 28px;
font-weight: normal;
margin-bottom: 10px;
color: #444444;
text-align:left`;

export const Container = styled.div`

margin-bottom: 40px;
min-height: 300px;
width: 72%;
margin:auto;
border: 1px solid #dddddd;
padding: 0px;
border-radius: 10px;
background-color: #ffffff;
box-shadow: 0px 0px 6px #e0e0e0;
text-align: left;
display: table;
border-collapse: separate;
box-sizing: border-box;
text-indent: initial;
display:flex;
`;

export const ATitle = styled.h1`
text-align: justify;
border-collapse: separate;
text-indent: initial;
border-spacing: 2px;
font-size: 22px;
font-weight: normal;
color: rgb(68, 68, 68);
`;
export const APara = styled.p`
color: #444444;
text-align: justify;
margin-bottom: 25px;
border-collapse: separate;
text-indent: initial;
border-spacing: 2px;
font-size: 14px;
`;
export const Date= styled.p`
color: rgb(153, 153, 153);
font-size: 14px;
text-align: justify;
`;

export const AButton = styled.button`
background-color: #d41f1f;
display: block;
height: 35px;
width: 160px;
line-height: 25px;
font-size: 18px;
color: #ffffff;
font-weight: bold;
text-decoration: none;
text-align: center;
vertical-align: middle;
border-radius: 6px;
background-color: #d41f1f;
cursor: pointer;
border:#d41f1f;
`;

export const AImg = styled.img`
position: relative;
width: 500px;
height: 300px;
overflow: hidden;
background-color: #ffffff;
border-radius: 10px 10px 0px 0px;

}
`;

export const BImg = styled.div`
border: 1px solid #dddddd;
padding: 0px;
border-radius: 10px;
background-color: #ffffff;
box-shadow: 0px 0px 6px #e0e0e0;
width: 500px;
min-height: 250px;

`;


//pagination

export const Pagination = styled.div`
width:68%;
padding:0% 16%;
display:flex;
align-items: center;
justify-content:space-between;
margin-Top:50px;
`;

export const PButton = styled.button`
width: 100px;
height: 40px;
line-height: 19px;
background-color:#e8e8e8;
color: #444444;
font-size: 16px;
font-weight: normal;
padding: 8px 15px 8px 15px;
text-align: center;
xborder-bottom: 1px solid #999999;
xbox-shadow: 0px 1px 2px #aaaaaa;
border-radius: 6px;
border:#e8e8e8;
`;

export const PageNum = styled.p`
margin-left: -42%;
color:blue;
display:flex;
gap:18px;
`;

export const Num = styled.p`
display:block;
cursor: pointer;
transition: transform .10s;
&:active{
background-color: #f8f8f8;
border: 1px solid #e8e8e8;
color: #666666;
font-weight: bold;
font-size: 14px;
line-height: 25px;
width: 18px;
height: 22px;
padding: 5px;
margin-right: 5px;
text-align: center;
display: inline;
transform: scale(1);


}
`;

74 changes: 71 additions & 3 deletions my-app/src/Pages/Articles.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,77 @@
import React from 'react'
import React, { useState,useEffect} from 'react';
import { ArticleHeader, Ahedd, Apara, Pagination, PButton,PageNum, Num } from '../Components/Styled'
import MapData from './MapData';


const Articles = () => {

const [data, setData] = React.useState([]);

const [pageNumber, setPageNumber] = useState(1);

useEffect(() => {
const getData = async () => {

try {
let res = await fetch(`http://localhost:3000/articles?_page=${pageNumber}&_limit=5`)
let data = await res.json();
setData(data)
}
catch (error) {
console.log(error);
}
}
getData();
},[pageNumber])

return (
<h1>Articles</h1>
<>
<ArticleHeader>
<Ahedd>Yummy News, Articles & Videos</Ahedd>
<Apara>Want to keep updated on the latest news of delicious meat-free meals and adorable animals? Check out this section for interesting daily happenings and articles that will melt your tummy (and heart too).
</Apara>
<Apara> You can also follow our Facebook Page or Twitter for more news and updates.</Apara>
</ArticleHeader>

<Pagination>
<p>Page : </p>
<PageNum>
<Num onClick={()=>setPageNumber(1)}>1</Num>
<Num onClick={()=>setPageNumber(2)}>2</Num>
<Num onClick={()=>setPageNumber(3)}>3</Num>
<Num onClick={()=>setPageNumber(4)}>4</Num>
<Num onClick={()=>setPageNumber(5)}>5</Num>
<Num onClick={()=>setPageNumber(6)}>6</Num>
<Num onClick={()=>setPageNumber(7)}>7</Num>
<Num onClick={()=>setPageNumber(8)}>8</Num>
<p>.....</p>
<Num onClick={()=>setPageNumber(10)}>10</Num>
</PageNum>
<div style={{display:"flex", gap:"10px"}}>
<PButton onClick={()=>setPageNumber(pageNumber-1)}>« Prev</PButton>
<PButton onClick={()=>setPageNumber(pageNumber+1)}>Next »</PButton>
</div>
</Pagination>



{
data.map((data) => (
<MapData key={data.id} {...data} />
))
}






</>
)
}

export default Articles
export default Articles




27 changes: 27 additions & 0 deletions my-app/src/Pages/MapData.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react'
import { AButton, AImg, Apara, ATitle, BImg, Container, Date } from '../Components/Styled'

const MapData = ({ id, title, imgURL, para, by, date }) => {
return (
<div>
<Container>
<BImg>
<AImg src={imgURL} alt={id} />
</BImg>
<div style={{ padding: "20px" }}>
<ATitle>{title}</ATitle>
<Apara>{by}</Apara>
<Apara>{para}</Apara>
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
<AButton>View Video</AButton>
<Date>{date}</Date>
</div>
</div>
</Container>
<br />
<br />
</div>
)
}

export default MapData
Loading