This file contains hidden or 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
import Game from "../model/Game"; | |
export async function getGames({ page, size }) { | |
const start = page * size - size; | |
const end = start + size; | |
const data = await gamesData; | |
return { | |
games: data.slice(start, end), | |
total: data.length | |
}; |
This file contains hidden or 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
import React, { Component } from "react"; | |
import { getGames } from "./api/api"; | |
import Pagination from "./components/Pagination"; | |
class App extends Component { | |
size = 12; | |
state = { | |
games: [], | |
totoal: null |
This file contains hidden or 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
import React from "react"; | |
import classNames from "classnames"; | |
function PaginationItem({ onClick, data, selected }) { | |
const cssClass = classNames("pagination__item", { | |
"pagination__item--active": data === selected | |
}); | |
return ( | |
<li className={cssClass} onClick={() => onClick(data)}> | |
{data} |
This file contains hidden or 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
import React, { Component } from "react"; | |
import PropTypes from "prop-types"; | |
import PaginationItem from "../components/PaginationItem"; | |
class Pagination extends Component { | |
state = { | |
selected: 1 | |
}; | |
onPaginate = selected => { |
This file contains hidden or 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
import { colorCode } from "./constants"; | |
class Game { | |
constructor({ | |
id, | |
name, | |
slug, | |
mana_cost, | |
rarity_id, | |
color_id, |
This file contains hidden or 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
export const colorCode = { | |
bigStone: "#182E3F", | |
siverTree: "#6CB6A0", | |
redDaMask: "#DC5F46", | |
ronChi: "#E9B24F" | |
}; |
This file contains hidden or 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
{ | |
"extends": ["react-app", "plugin:prettier/recommended"] | |
} |