From 3dc286f2dd8d93a17754fb4fe770d686ac0fa6ef Mon Sep 17 00:00:00 2001 From: Petr Vecera Date: Fri, 3 Mar 2023 21:54:49 +0100 Subject: [PATCH] Move faction icon to components (#59) * Move faction icon to components * Remove img from PayPal donations * Cleanup * Fix README * Add more notes * Fix prettier * Fix the space * Clean up the footer --- .github/workflows/preview.yml | 4 +++- README.md | 8 ++++++++ components/Footer/Footer.tsx | 14 +++++++++++--- components/Header/Header.tsx | 1 - components/SearchPlayerEntry.tsx | 2 -- {pages => components}/faction-icon.tsx | 0 components/paypal-donations.tsx | 1 - components/player-card/player-recent-matches.tsx | 2 +- components/player-card/player-standings-table.tsx | 2 +- components/search-button/search-button.tsx | 6 +++--- jest.config.js | 1 + next.config.js | 1 + package.json | 11 +++++------ pages/_app.tsx | 4 ++-- pages/index.tsx | 7 ++++++- pages/leaderboards.tsx | 2 +- src/firebase/web-firebase.ts | 1 - 17 files changed, 43 insertions(+), 24 deletions(-) rename {pages => components}/faction-icon.tsx (100%) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 9f613702..ae7cc299 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -43,12 +43,14 @@ jobs: run: yarn --prefer-offline --frozen-lockfile install - name: Disable Vercel telemetry run: yarn next telemetry disable + - name: Run the build + run: yarn build - name: Deploy to Edgio hosting env: DEPLOY_TOKEN: ${{ secrets.EDGIO_DEPLOY_TOKEN}} # Deploy command automatically runs the build run: | - npx edgio deploy --site=coh3-stats --team=coh-stats --environment=$EDGIO_ENV --token $DEPLOY_TOKEN --branch=$BRANCH_NAME + npx edgio deploy --skip-build --site=coh3-stats --team=coh-stats --environment=$EDGIO_ENV --token $DEPLOY_TOKEN --branch=$BRANCH_NAME - uses: jwalton/gh-find-current-pr@v1 id: finder - name: Publish Preview Link diff --git a/README.md b/README.md index 8d70ff0a..6da63d94 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,14 @@ You can start editing the page by modifying `pages/index.tsx`. The page auto-upd Before making an MR please create an issue describing what you want to change / how you want to change it. So we can have some discussion, also it avoids multiple people working on the same thing. +Feel free to create fork and make MR. Before PR you can test your code with `yarn build` to make sure it can be build. + +Development conventions: + +- Name the files with `-` instead of camelCase. Eg `color-scheme-toggle.tsx` +- Try not to add anymore eslint warnings if possible (Don't worry if you don't know how to solve it though) +- Prettier and eslint should cover the rest + ## Development aproach ### High level architecture diff --git a/components/Footer/Footer.tsx b/components/Footer/Footer.tsx index 048f460f..389f403e 100644 --- a/components/Footer/Footer.tsx +++ b/components/Footer/Footer.tsx @@ -1,8 +1,9 @@ -import { Container, createStyles, Group, Text } from "@mantine/core"; +import { Container, createStyles, Group, Space, Text, Anchor } from "@mantine/core"; import React from "react"; import { Discord } from "../icon/discord"; import { Donate } from "../icon/donate"; import { Github } from "../icon/github"; +import Link from "next/link"; const useStyles = createStyles((theme) => ({ footer: { @@ -39,9 +40,16 @@ export const Footer: React.FC = () => {
- The Company of Heroes is registered trademark of SEGA Holdings. Co + The Company of Heroes is registered trademark of SEGA Holdings. Co
- The COH Images and other assets are owned by Relic Entertainment and/or SEGA + The COH Images and other assets are owned by + Relic Entertainment and/or SEGA + + Visit{" "} + + coh2stats.com{" "} + {" "} + for Company of Heroes 2 stats and analytics
diff --git a/components/Header/Header.tsx b/components/Header/Header.tsx index 04d7381b..339cbca7 100644 --- a/components/Header/Header.tsx +++ b/components/Header/Header.tsx @@ -13,7 +13,6 @@ import { SimpleGrid, createStyles, Stack, - Indicator, ActionIcon, Tooltip, Anchor, diff --git a/components/SearchPlayerEntry.tsx b/components/SearchPlayerEntry.tsx index a575b649..1e13fce6 100644 --- a/components/SearchPlayerEntry.tsx +++ b/components/SearchPlayerEntry.tsx @@ -5,11 +5,9 @@ import { Center, Image, Text, - Badge, Avatar, Indicator, } from "@mantine/core"; -import Link from "next/link"; const useStyles = createStyles((theme) => ({ action: { diff --git a/pages/faction-icon.tsx b/components/faction-icon.tsx similarity index 100% rename from pages/faction-icon.tsx rename to components/faction-icon.tsx diff --git a/components/paypal-donations.tsx b/components/paypal-donations.tsx index 9572b55c..c67d25c4 100644 --- a/components/paypal-donations.tsx +++ b/components/paypal-donations.tsx @@ -9,7 +9,6 @@ export const PayPalDonation = () => { title="PayPal" alt="Donate with PayPal button" /> - ); }; diff --git a/components/player-card/player-recent-matches.tsx b/components/player-card/player-recent-matches.tsx index b799d127..1668812a 100644 --- a/components/player-card/player-recent-matches.tsx +++ b/components/player-card/player-recent-matches.tsx @@ -7,7 +7,7 @@ import { maps, matchTypesAsObject, raceIDs } from "../../src/coh3/coh3-data"; import { raceID } from "../../src/coh3/coh3-types"; import { getMatchDuration, getMatchPlayersByFaction } from "../../src/coh3/helpers"; import ErrorCard from "../error-card"; -import FactionIcon from "../../pages/faction-icon"; +import FactionIcon from "../faction-icon"; import { formatMatchTime } from "../../src/utils"; import { IconInfoCircle } from "@tabler/icons"; import sortBy from "lodash/sortBy"; diff --git a/components/player-card/player-standings-table.tsx b/components/player-card/player-standings-table.tsx index a9ec6ce7..cd371fd8 100644 --- a/components/player-card/player-standings-table.tsx +++ b/components/player-card/player-standings-table.tsx @@ -1,6 +1,6 @@ import { leaderBoardType, raceType, RawLeaderboardStat } from "../../src/coh3/coh3-types"; import { DataTable } from "mantine-datatable"; -import FactionIcon from "../../pages/faction-icon"; +import FactionIcon from "../faction-icon"; import { localizedNames } from "../../src/coh3/coh3-data"; import { Space, Group, Text, Title, Anchor } from "@mantine/core"; diff --git a/components/search-button/search-button.tsx b/components/search-button/search-button.tsx index c50646a1..9521e6d7 100644 --- a/components/search-button/search-button.tsx +++ b/components/search-button/search-button.tsx @@ -1,4 +1,4 @@ -import { Button, createStyles, Group, Text } from "@mantine/core"; +import { Button, Group, Text } from "@mantine/core"; import { IconSearch } from "@tabler/icons"; import React from "react"; import { openSpotlight } from "@mantine/spotlight"; @@ -8,10 +8,10 @@ interface SearchButtonProps { onClick?: React.MouseEventHandler; } -const useStyles = createStyles((theme) => ({})); +// const useStyles = createStyles((theme) => ({})); export const SearchButton: React.FC = ({ mobile, onClick }) => { - const { classes } = useStyles(); + // const { classes } = useStyles(); const handleClick = (event: React.MouseEvent) => { openSpotlight(); diff --git a/jest.config.js b/jest.config.js index baff22c4..50bde5b6 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires const nextJest = require("next/jest"); const createJestConfig = nextJest({ diff --git a/next.config.js b/next.config.js index 7eb27bb8..282980d8 100644 --- a/next.config.js +++ b/next.config.js @@ -1,5 +1,6 @@ // This file was automatically added by edgio init. // You should commit this file to source control. +// eslint-disable-next-line @typescript-eslint/no-var-requires const { withEdgio, withServiceWorker } = require("@edgio/next/config"); /** @type {import('next').NextConfig} */ diff --git a/package.json b/package.json index 3ceed2ff..91ea7054 100644 --- a/package.json +++ b/package.json @@ -11,16 +11,14 @@ "npm": "please-use-yarn" }, "scripts": { - "start": "yarn edgio:dev", - "edgio:dev": "edgio dev", - "edgio:build": "edgio build", - "edgio:deploy": "edgio deploy", + "start": "edgio dev", "dev": "edgio dev", "build": "edgio build", "next:dev": "next dev", "next:build": "next build", - "lint": "next lint", "test": "jest", + "lint": "next lint", + "lint:eslint": "eslint **/*.{ts,tsx,js}", "lint:prettier": "prettier --check .", "fix": "prettier --loglevel warn --write .", "fix:prettier": "prettier --loglevel warn --write .", @@ -29,7 +27,8 @@ }, "lint-staged": { "*.{js,ts,jsx,tsx}": [ - "prettier --loglevel warn --write" + "prettier --loglevel warn --write", + "eslint --config .eslintrc.js" ] }, "dependencies": { diff --git a/pages/_app.tsx b/pages/_app.tsx index 1010bef4..16f9c1d4 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -58,7 +58,7 @@ export default function App(props: AppProps & { colorScheme: ColorScheme }) { console.log("SEARCH", query); let data = null; - let error = null; + // let error = null; try { const res = await fetch( @@ -91,7 +91,7 @@ export default function App(props: AppProps & { colorScheme: ColorScheme }) { } catch (e: any) { console.error(`Failed getting data for player id ${query}`); console.error(e); - error = e.message; + // error = e.message; } }; // when debounced query entry changes fetch player results diff --git a/pages/index.tsx b/pages/index.tsx index fc20337d..fc990396 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -7,7 +7,12 @@ import { Discord } from "../components/icon/discord"; const Home: NextPage = () => { return ( - + {"coh3-background"} Company of Heroes 3 is out🎉 diff --git a/pages/leaderboards.tsx b/pages/leaderboards.tsx index 8fe7ce2a..0f2c1664 100644 --- a/pages/leaderboards.tsx +++ b/pages/leaderboards.tsx @@ -13,7 +13,7 @@ import CountryFlag from "../components/country-flag"; import Head from "next/head"; import { localizedGameTypes, localizedNames } from "../src/coh3/coh3-data"; import { raceType, leaderBoardType } from "../src/coh3/coh3-types"; -import FactionIcon from "./faction-icon"; +import FactionIcon from "../components/faction-icon"; /** * Timeago is causing issues with SSR, move to clinet side diff --git a/src/firebase/web-firebase.ts b/src/firebase/web-firebase.ts index 982c16cc..e9a6f13e 100644 --- a/src/firebase/web-firebase.ts +++ b/src/firebase/web-firebase.ts @@ -22,7 +22,6 @@ const init = (): void => { if (app.name && typeof window !== "undefined") { analytics = getAnalytics(app); // This is OK we just need to "getPerf" to initialize it - // eslint-disable-next-line @typescript-eslint/no-unused-vars performance = getPerformance(app); setUserProperties(analytics, { custom_platform: "web_app" }); }