-
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.
Merge pull request #16 from Berlevog/08-leaderboard-page
Добавил первый вариант лидерборда и разметку
- Loading branch information
Showing
29 changed files
with
1,389 additions
and
17 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"presets": ["@babel/preset-env", "@babel/preset-react"] | ||
"presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"] | ||
} |
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,4 @@ | ||
import Enzyme from "enzyme"; | ||
import Adapter from "@wojtekmaj/enzyme-adapter-react-17"; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); |
Large diffs are not rendered by default.
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
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,9 @@ | ||
import * as React from "react"; | ||
import * as ReactDOM from "react-dom"; | ||
import Footer from "./Footer"; | ||
|
||
it("renders without crashing", () => { | ||
const div = document.createElement("div"); | ||
ReactDOM.render(<Footer />, div); | ||
ReactDOM.unmountComponentAtNode(div); | ||
}); |
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,22 @@ | ||
import React from "react"; | ||
import Typography from "@material-ui/core/Typography"; | ||
import Link from "@material-ui/core/Link"; | ||
|
||
const Footer = () => { | ||
return ( | ||
<Typography variant="body2" color="textSecondary" align="center"> | ||
{"Berlevog © "} | ||
<Link | ||
color="primary" | ||
href="https://github.com/Berlevog/yandex.middlefrontend.mario" | ||
target="_blank" | ||
underline="always" | ||
> | ||
repo | ||
</Link>{" "} | ||
{new Date().getFullYear()} | ||
{"."} | ||
</Typography> | ||
); | ||
}; | ||
export default Footer; |
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 @@ | ||
export { default as Footer } from "./Footer"; |
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,18 @@ | ||
import * as React from "react"; | ||
import * as ReactDOM from "react-dom"; | ||
import { mount } from "enzyme"; | ||
import Header from "./Header"; | ||
|
||
describe("render header", () => { | ||
it("renders without crashing", () => { | ||
const div = document.createElement("div"); | ||
|
||
ReactDOM.render(<Header open={true} />, div); | ||
ReactDOM.unmountComponentAtNode(div); | ||
}); | ||
|
||
it("props 'open' passed successfully", () => { | ||
const header = mount(<Header open={false} />); | ||
expect(header.prop("open")).toEqual(false); | ||
}); | ||
}); |
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,79 @@ | ||
import React, { FC } from "react"; | ||
import AppBar from "@material-ui/core/AppBar"; | ||
import Toolbar from "@material-ui/core/Toolbar"; | ||
import Typography from "@material-ui/core/Typography"; | ||
import IconButton from "@material-ui/core/IconButton"; | ||
import MenuIcon from "@material-ui/icons/Menu"; | ||
import clsx from "clsx"; | ||
import { makeStyles } from "@material-ui/core/styles"; | ||
import { DRAWER_WIDTH } from "../../config/constants"; | ||
import { ThemeToggler } from "../ThemeToggler"; | ||
|
||
type Props = React.ButtonHTMLAttributes<HTMLButtonElement> & { | ||
open: boolean; | ||
}; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
toolbar: { | ||
paddingRight: 24, | ||
}, | ||
appBar: { | ||
zIndex: theme.zIndex.drawer + 1, | ||
transition: theme.transitions.create(["width", "margin"], { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.leavingScreen, | ||
}), | ||
}, | ||
appBarShift: { | ||
marginLeft: DRAWER_WIDTH, | ||
width: `calc(100% - ${DRAWER_WIDTH}px)`, | ||
transition: theme.transitions.create(["width", "margin"], { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.enteringScreen, | ||
}), | ||
}, | ||
menuButton: { | ||
marginRight: 36, | ||
}, | ||
menuButtonHidden: { | ||
display: "none", | ||
}, | ||
title: { | ||
flexGrow: 1, | ||
}, | ||
})); | ||
|
||
const Header: FC<Props> = ({ open, onClick }) => { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<AppBar | ||
position="absolute" | ||
className={clsx(classes.appBar, open && classes.appBarShift)} | ||
> | ||
<Toolbar className={classes.toolbar}> | ||
<IconButton | ||
edge="start" | ||
color="inherit" | ||
aria-label="open drawer" | ||
onClick={onClick} | ||
className={clsx(classes.menuButton, open && classes.menuButtonHidden)} | ||
> | ||
<MenuIcon /> | ||
</IconButton> | ||
<Typography | ||
component="h1" | ||
variant="h6" | ||
color="inherit" | ||
noWrap | ||
className={classes.title} | ||
> | ||
Super Mario Pro | ||
</Typography> | ||
<ThemeToggler /> | ||
</Toolbar> | ||
</AppBar> | ||
); | ||
}; | ||
|
||
export default Header; |
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 @@ | ||
export { default as Header } from "./Header"; |
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,18 @@ | ||
import * as React from "react"; | ||
import * as ReactDOM from "react-dom"; | ||
import { mount } from "enzyme"; | ||
import Menu from "./Menu"; | ||
|
||
describe("render header", () => { | ||
it("renders without crashing", () => { | ||
const div = document.createElement("div"); | ||
|
||
ReactDOM.render(<Menu open={true} />, div); | ||
ReactDOM.unmountComponentAtNode(div); | ||
}); | ||
|
||
it("props 'open' passed successfully", () => { | ||
const menu = mount(<Menu open={false} />); | ||
expect(menu.prop("open")).toEqual(false); | ||
}); | ||
}); |
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, { FC } from "react"; | ||
import clsx from "clsx"; | ||
import { makeStyles } from "@material-ui/core/styles"; | ||
import Drawer from "@material-ui/core/Drawer"; | ||
import List from "@material-ui/core/List"; | ||
import IconButton from "@material-ui/core/IconButton"; | ||
import ChevronLeftIcon from "@material-ui/icons/ChevronLeft"; | ||
import Divider from "@material-ui/core/Divider"; | ||
import { mainListItems, secondaryListItems } from "./listItems"; | ||
import { DRAWER_WIDTH } from "../../config/constants"; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
toolbarIcon: { | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "flex-end", | ||
padding: "0 8px", | ||
...theme.mixins.toolbar, | ||
}, | ||
drawerPaper: { | ||
position: "relative", | ||
whiteSpace: "nowrap", | ||
width: DRAWER_WIDTH, | ||
transition: theme.transitions.create("width", { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.enteringScreen, | ||
}), | ||
}, | ||
drawerPaperClose: { | ||
overflowX: "hidden", | ||
transition: theme.transitions.create("width", { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.leavingScreen, | ||
}), | ||
width: theme.spacing(7), | ||
[theme.breakpoints.up("sm")]: { | ||
width: theme.spacing(9), | ||
}, | ||
}, | ||
})); | ||
|
||
type Props = React.ButtonHTMLAttributes<HTMLButtonElement> & { | ||
open: boolean; | ||
}; | ||
|
||
const Menu: FC<Props> = ({ open, onClick }) => { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<Drawer | ||
variant="permanent" | ||
classes={{ | ||
paper: clsx(classes.drawerPaper, !open && classes.drawerPaperClose), | ||
}} | ||
open={open} | ||
> | ||
<div className={classes.toolbarIcon}> | ||
<IconButton onClick={onClick}> | ||
<ChevronLeftIcon /> | ||
</IconButton> | ||
</div> | ||
<Divider /> | ||
<List>{mainListItems}</List> | ||
<Divider /> | ||
<List>{secondaryListItems}</List> | ||
</Drawer> | ||
); | ||
}; | ||
|
||
export default Menu; |
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 @@ | ||
export { default as Menu } from "./Menu"; |
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,42 @@ | ||
import React from "react"; | ||
import ListItem from "@material-ui/core/ListItem"; | ||
import ListItemIcon from "@material-ui/core/ListItemIcon"; | ||
import ListItemText from "@material-ui/core/ListItemText"; | ||
import ShowChartIcon from "@material-ui/icons/ShowChart"; | ||
import ExitToAppIcon from "@material-ui/icons/ExitToApp"; | ||
import SportsEsportsIcon from "@material-ui/icons/SportsEsports"; | ||
import ForumIcon from "@material-ui/icons/Forum"; | ||
|
||
export const mainListItems = ( | ||
<div> | ||
<ListItem button> | ||
<ListItemIcon> | ||
<SportsEsportsIcon /> | ||
</ListItemIcon> | ||
<ListItemText primary="Game" /> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemIcon> | ||
<ShowChartIcon /> | ||
</ListItemIcon> | ||
<ListItemText primary="Leaderboard" /> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemIcon> | ||
<ForumIcon /> | ||
</ListItemIcon> | ||
<ListItemText primary="Forum" /> | ||
</ListItem> | ||
</div> | ||
); | ||
|
||
export const secondaryListItems = ( | ||
<div> | ||
<ListItem button> | ||
<ListItemIcon> | ||
<ExitToAppIcon /> | ||
</ListItemIcon> | ||
<ListItemText primary="Logout" /> | ||
</ListItem> | ||
</div> | ||
); |
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,9 @@ | ||
import * as React from "react"; | ||
import * as ReactDOM from "react-dom"; | ||
import ThemeToggler from "./ThemeToggler"; | ||
|
||
it("renders without crashing", () => { | ||
const div = document.createElement("div"); | ||
ReactDOM.render(<ThemeToggler />, div); | ||
ReactDOM.unmountComponentAtNode(div); | ||
}); |
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,16 @@ | ||
import React, { FC } from "react"; | ||
import WbSunnyOutlinedIcon from "@material-ui/icons/WbSunnyOutlined"; | ||
import Brightness2Icon from "@material-ui/icons/Brightness2"; | ||
import Switch from "@material-ui/core/Switch"; | ||
|
||
const ThemeToggler = () => { | ||
return ( | ||
<> | ||
<WbSunnyOutlinedIcon /> | ||
<Switch color="default" /> | ||
<Brightness2Icon /> | ||
</> | ||
); | ||
}; | ||
|
||
export default ThemeToggler; |
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 @@ | ||
export { default as ThemeToggler } from "./ThemeToggler"; |
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,2 @@ | ||
export const DRAWER_WIDTH = 240; | ||
export const NO_CONTENT = "No content"; |
Oops, something went wrong.