-
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
5777441
commit bae1b9d
Showing
12 changed files
with
833 additions
and
544 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true | ||
} |
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,25 @@ | ||
import { Route, Routes } from 'react-router-dom'; | ||
import { Header } from './components/Header'; | ||
import Layout from './pages/Layout'; | ||
|
||
import { Categories } from './pages/Categories'; | ||
import { Home } from './pages/Home'; | ||
|
||
const navItems = [ | ||
{ name: 'Home', path: '/', component: <Home /> }, | ||
{ name: 'Categories', path: '/categories', component: <Categories /> }, | ||
]; | ||
|
||
export const App = () => { | ||
return ( | ||
<Layout header={<Header navItems={navItems} />}> | ||
<Routes> | ||
{navItems.map(({ path, component }) => ( | ||
<> | ||
<Route path={path} element={component} /> | ||
</> | ||
))} | ||
</Routes> | ||
</Layout> | ||
); | ||
}; |
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,34 @@ | ||
import { Toolbar, Button, AppBar } from '@mui/material'; | ||
import { Box } from '@mui/system'; | ||
import React from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
type TProps = { | ||
navItems: { | ||
name: string; | ||
path: string; | ||
component: JSX.Element; | ||
}[]; | ||
}; | ||
|
||
export const Header = ({ navItems }: TProps) => { | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<AppBar component="nav"> | ||
<Toolbar> | ||
<Box sx={{ display: { xs: 'none', sm: 'block' } }}> | ||
{navItems.map(({ name, path }) => ( | ||
<Button | ||
key={name} | ||
sx={{ color: '#fff' }} | ||
onClick={() => navigate(path)} | ||
> | ||
{name} | ||
</Button> | ||
))} | ||
</Box> | ||
</Toolbar> | ||
</AppBar> | ||
); | ||
}; |
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,14 +1,18 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import "./index.css"; | ||
import FrontPage from "./pages/FrontPage"; | ||
import reportWebVitals from "./reportWebVitals"; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import './index.css'; | ||
|
||
import reportWebVitals from './reportWebVitals'; | ||
import { App } from './App'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
|
||
ReactDOM.render( | ||
<React.StrictMode> | ||
<FrontPage /> | ||
<BrowserRouter> | ||
<App /> | ||
</BrowserRouter> | ||
</React.StrictMode>, | ||
document.getElementById("root") | ||
document.getElementById('root') | ||
); | ||
|
||
reportWebVitals(); |
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,10 @@ | ||
import { Grid } from '@mui/material'; | ||
import CategoriesList from '../components/CategoriesList'; | ||
|
||
export const Categories = () => { | ||
return ( | ||
<Grid item xs={12} width={'100%'} justifyContent={'center'} my={4}> | ||
<CategoriesList /> | ||
</Grid> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
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,70 @@ | ||
import React from 'react'; | ||
import { makeStyles } from '@mui/styles'; | ||
import { Box, Grid, Typography, useTheme } from '@mui/material'; | ||
import CategoriesList from '../components/CategoriesList'; | ||
import RandomJoke from '../components/RandomJoke'; | ||
import SearchJoke from '../components/SearchJokes'; | ||
import { Header } from '../components/Header'; | ||
|
||
const useStyles = makeStyles(() => ({ | ||
image: { | ||
height: '30vh', | ||
width: 'auto', | ||
'&:hover': { | ||
animation: '$shake 0.5s', | ||
animatedItemExiting: 'infinite', | ||
}, | ||
'60%': { transform: 'translate(-3px, 1px) rotate(0deg)' }, | ||
'70%': { transform: 'translate(3px, 1px) rotate(-1deg)' }, | ||
'80%': { transform: 'translate(-1px, -1px) rotate(1deg)' }, | ||
'90% ': { transform: 'translate(1px, 2px) rotate(0deg)' }, | ||
'100%': { transform: 'translate(1px, -2px) rotate(-1deg)' }, | ||
}, | ||
'@keyframes shake': { | ||
'0%': { transform: 'translate(1px, 1px) rotate(0deg)' }, | ||
' 10%': { transform: 'translate(-1px, -2px) rotate(-1deg)' }, | ||
' 20%': { transform: 'translate(-3px, 0px) rotate(1deg)' }, | ||
'30%': { transform: 'translate(3px, 2px) rotate(0deg)' }, | ||
'40%': { transform: 'translate(1px, -1px) rotate(1deg)' }, | ||
'50%': { transform: 'translate(-1px, 2px) rotate(-1deg)' }, | ||
}, | ||
})); | ||
|
||
export const Home = () => { | ||
const classes = useStyles(); | ||
const theme = useTheme(); | ||
|
||
return ( | ||
<Box width={'100%'}> | ||
<Grid container width="100%" my={6}> | ||
<Grid item xs={12} display="flex" justifyContent="center"> | ||
<img | ||
className={classes.image} | ||
src="https://api.chucknorris.io/img/chucknorris_logo_coloured_small@2x.png" | ||
alt="Chuck Noris is watching you" | ||
/> | ||
</Grid> | ||
<Grid item xs={12} display="flex" justifyContent="center"> | ||
<Typography | ||
component="a" | ||
target="_blank" | ||
variant="h4" | ||
href="http://chucknorris.io" | ||
> | ||
Chuck Norris Quotes | ||
</Typography> | ||
</Grid> | ||
</Grid> | ||
|
||
<Grid container width="100%" my={2}> | ||
<Grid item xs={12} my={theme.spacing(2)}> | ||
<RandomJoke /> | ||
</Grid> | ||
|
||
<Grid item xs={12}> | ||
<SearchJoke /> | ||
</Grid> | ||
</Grid> | ||
</Box> | ||
); | ||
}; |
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,20 @@ | ||
import { Box } from '@mui/system'; | ||
import React from 'react'; | ||
|
||
type TProps = { | ||
header: React.ReactNode; | ||
children: React.ReactNode; | ||
}; | ||
|
||
const Layout = ({ header, children }: TProps) => { | ||
return ( | ||
<> | ||
{header} | ||
<Box mt={8} sx={{ display: 'flex' }}> | ||
{children} | ||
</Box> | ||
</> | ||
); | ||
}; | ||
|
||
export default Layout; |
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,13 @@ | ||
import { useState } from "react"; | ||
|
||
export function useFetchData<T>(){ | ||
|
||
const [data, setData] = useState<T | undefined>() | ||
|
||
const getData = (url:string)=> fetch(url).then(async (response) => { | ||
const result = await response.json(); | ||
setData(result); | ||
}); | ||
|
||
return {data, getData} | ||
} |
Oops, something went wrong.