Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
DonyaElbanna committed Dec 30, 2022
1 parent ea14dbe commit 68f98e8
Show file tree
Hide file tree
Showing 18 changed files with 1,326 additions and 100 deletions.
988 changes: 988 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@mui/material": "^5.11.2",
"@mui/styled-engine-sc": "^5.11.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"styled-components": "^5.3.6",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
Binary file removed public/favicon.ico
Binary file not shown.
Binary file added public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 13 additions & 38 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,43 +1,18 @@
<!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" />
<!--
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" />
<!--
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>React App</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.
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.png" />
<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="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>Rick & Morty Wiki</title>
</head>

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
<body>
<div id="root"></div>
</body>

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</html>
Binary file removed public/logo192.png
Binary file not shown.
Binary file removed public/logo512.png
Binary file not shown.
17 changes: 0 additions & 17 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
Expand Down
60 changes: 35 additions & 25 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,38 +1,48 @@
.App {
margin: 0 1%;
width: 97%;
}

h1 {
text-align: center;
color: whitesmoke;
}

.App-logo {
height: 40vmin;
pointer-events: none;
/* .MuiPaper-root.MuiPaper-elevation.MuiPaper-rounded.MuiPaper-elevation1.MuiCard-root.css-1xez8po-MuiPaper-root-MuiCard-root {
margin: auto;
} */

/* Search */

.search {
text-align: center;
margin-bottom: 2%;
color: rgb(255, 255, 255);
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
/* Filter */

.filter {
color: whitesmoke;
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
/* Card */

span.MuiBadge-badge {
font-size: 17px;
border-radius: 0px;
}

.App-link {
color: #61dafb;
.MuiTypography-h5 {
text-align: center;
}

/* Pagination */

.pagination {
margin: 4% 0 2% 0;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
svg.MuiSvgIcon-root {
color: #8fd746;
}
122 changes: 106 additions & 16 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,113 @@
import logo from './logo.svg';
import './App.css';
import "./App.css";
// import CardItem from "./components/CardItem";
import Filter from "./components/Filter";
import { useEffect, useState } from "react";
import Grid from "@mui/material/Unstable_Grid2";
import CardItem from "./components/CardItem";
import Search from "./components/Search";
import PaginationBar from "./components/PaginationBar";
import { ThemeProvider, createTheme } from "@mui/material/styles";
import CssBaseline from "@mui/material/CssBaseline";

const theme = createTheme({
palette: {
// primary: {
// main: "#8fd746",
// contrastText: "#ffffff",
// },
// secondary: {
// main: "#EEE",
// },
background: {
default: "#222222",
contrastText: "#EEE",
},
// accent: {
// main: "#8fd746",
// },
},
typography: {
// fontFamily: ["Roboto"],
fontSize: 18,
},
});

// import { styled } from "@mui/material/styles";
// import Box from "@mui/material/Box";
// import Paper from "@mui/material/Paper";
// import { withTheme } from "@mui/material";
// import Card from "@mui/material/Card";
// import CardContent from "@mui/material/CardContent";
// import CardMedia from "@mui/material/CardMedia";
// import Typography from "@mui/material/Typography";
// import { CardActionArea } from "@mui/material";
// import { lightGreen } from "@mui/material/colors";
// import Button from "@mui/material/Button";
// import Pagination from "@mui/material/Pagination";
// import Badge from "@mui/material/Badge";
// import Stack from "@mui/material/Stack";
// import CssBaseline from "@mui/material/CssBaseline";
// import Input from "@mui/material/Input";

// import { ThemeProvider, createTheme } from "@mui/material/styles";

function App() {
const [fetchedData, setFetchedData] = useState([]);
const { info, results } = fetchedData;
const [searchInput, setSearchInput] = useState("");
const [page, setPage] = useState(1);
// const [clicked, setClicked] = useState(false);

// const showDetails = () => {
// setClicked(true);
// };

let api = `https://rickandmortyapi.com/api/character/?page=${page}&name=${searchInput}`;

useEffect(() => {
(async () => {
const data = await fetch(api).then((response) => response.json());
setFetchedData(data);
})();
}, [api]);
// console.log(info);
// const theme = createTheme({
// palette: {
// primary: {
// main: "#ffff00",
// contrastText: "#EEE",
// },
// secondary: {
// main: "#EEE",
// },
// background: {
// default: "#222222",
// contrastText: "#EEE",
// },
// accent: {
// main: "#8fd746",
// },
// },
// typography: {
// fontFamily: ["Poppins"],
// fontSize: 18,
// },
// });

return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
<ThemeProvider theme={theme}>
<CssBaseline />
<h1>Characters</h1>
<Search setSearchInput={setSearchInput} />
<Grid container spacing={1}>
<Grid xs={12} sm={4} md={3}>
<Filter />
</Grid>
<CardItem results={results} />
</Grid>
<PaginationBar info={info ? info : ""} setPage={setPage} />
</ThemeProvider>
</div>
);
}
Expand Down
Empty file added src/components/CardDetails.js
Empty file.
71 changes: 71 additions & 0 deletions src/components/CardItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React from "react";
import Card from "@mui/material/Card";
import Grid from "@mui/material/Unstable_Grid2";
import CardContent from "@mui/material/CardContent";
import CardMedia from "@mui/material/CardMedia";
import Typography from "@mui/material/Typography";
import Badge from "@mui/material/Badge";
const CardItem = ({ results }) => {
return (
<Grid
xs={12}
sm={8}
md={9}
container
rowSpacing={1}
columnSpacing={{ sm: 1, md: 2 }}
>
{results ? (
results.map((result) => {
let { id, name, image, origin, gender, location, species, status } =
result;
return (
<Grid xs={12} sm={6} md={4} lg={3}>
<Card sx={{ maxWidth: 300 }} key={id}>
<div style={{ position: "relative" }}>
<Badge
color={
status === "Dead"
? "error"
: status === "Alive"
? "primary"
: "warning"
}
badgeContent={status}
style={{
position: "absolute",
top: "10px",
right: status === "unknown" ? "40px" : "25px",
}}
/>
<CardMedia
component="img"
image={image}
alt={name + " image"}
/>
</div>

<CardContent>
<Typography gutterBottom variant="h5" component="div">
{result.name}
</Typography>
<Typography variant="body1" color="text.info">
Gender: {gender} <br></br>
Species: {species} <br></br>
Origin: {origin.name} <br></br>
Location: {location.name}
</Typography>
</CardContent>
</Card>
{/* </Badge> */}
</Grid>
);
})
) : (
<div>No Caharacters Found</div>
)}
</Grid>
);
};

export default CardItem;
7 changes: 7 additions & 0 deletions src/components/Filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from "react";

const Filter = () => {
return <div className="filter">Filter</div>;
};

export default Filter;
Empty file added src/components/Navbar.js
Empty file.
Loading

0 comments on commit 68f98e8

Please sign in to comment.