From 2c330620fb36916050761e4dd80ccafec1add5c5 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Tue, 27 Sep 2022 21:53:12 +0300 Subject: [PATCH] Add button to analyzer to build card --- app/components/BuildCard.tsx | 21 ++++++++++++++++++--- app/components/icons/Info.tsx | 16 ++++++++++++++++ app/components/layout/index.tsx | 4 ++-- app/routes/index.tsx | 4 ++-- app/styles/common.css | 7 ++++++- app/utils/urls.ts | 17 +++++++++++++++-- 6 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 app/components/icons/Info.tsx diff --git a/app/components/BuildCard.tsx b/app/components/BuildCard.tsx index 1b119f8bd..dbf85c252 100644 --- a/app/components/BuildCard.tsx +++ b/app/components/BuildCard.tsx @@ -12,16 +12,21 @@ import type { BuildAbilitiesTuple } from "~/modules/in-game-lists/types"; import { databaseTimestampToDate } from "~/utils/dates"; import { discordFullName } from "~/utils/strings"; import { + analyzerPage, gearImageUrl, mainWeaponImageUrl, modeImageUrl, + navIconUrl, userBuildsPage, } from "~/utils/urls"; import { Ability } from "./Ability"; import { Button, LinkButton } from "./Button"; import { FormWithConfirm } from "./FormWithConfirm"; +import { TrashIcon } from "./icons/Trash"; +import { EditIcon } from "./icons/Edit"; import { Image } from "./Image"; import { Popover } from "./Popover"; +import { InfoIcon } from "./icons/Info"; interface BuildProps { build: Pick< @@ -62,10 +67,20 @@ export function BuildCard({ build, owner, canEdit = false }: BuildProps) { } = build; const bottomRowItems = [ + + {t("common:pages.analyzer")} + , description && ( {t("builds:buildCard.info")}} + buttonChildren={} triggerClassName="minimal tiny build__small-text" > {description} @@ -80,7 +95,7 @@ export function BuildCard({ build, owner, canEdit = false }: BuildProps) { to={`new?buildId=${id}&userId=${user!.id}`} data-cy="edit-build-button" > - {t("builds:buildCard.edit")} + ), canEdit && ( @@ -96,7 +111,7 @@ export function BuildCard({ build, owner, canEdit = false }: BuildProps) { type="submit" data-cy="delete-build-button" > - {t("common:actions.delete")} + ), diff --git a/app/components/icons/Info.tsx b/app/components/icons/Info.tsx new file mode 100644 index 000000000..1b19b0a8b --- /dev/null +++ b/app/components/icons/Info.tsx @@ -0,0 +1,16 @@ +export function InfoIcon({ className }: { className?: string }) { + return ( + + + + ); +} diff --git a/app/components/layout/index.tsx b/app/components/layout/index.tsx index b00ca0b56..b05710e8d 100644 --- a/app/components/layout/index.tsx +++ b/app/components/layout/index.tsx @@ -2,7 +2,7 @@ import { Link, useLocation } from "@remix-run/react"; import * as React from "react"; import { useTranslation } from "react-i18next"; import type { RootLoaderData } from "~/root"; -import { LOGO_PATH } from "~/utils/urls"; +import { LOGO_PATH, navIconUrl } from "~/utils/urls"; import { Image } from "../Image"; import { ColorModeToggle } from "./ColorModeToggle"; import { Footer } from "./Footer"; @@ -54,7 +54,7 @@ export const Layout = React.memo(function Layout({ {currentPagesNavItem && (
export const calendarReportWinnersPage = (eventId: number) => `/calendar/${eventId}/report-winners`; export const articlePage = (slug: string) => `/a/${slug}`; +export const analyzerPage = (args?: { + weaponId: MainWeaponId; + abilities: Ability[]; +}) => + `/analyzer${ + args + ? `?weapon=${args.weaponId}&build=${encodeURIComponent( + args.abilities.join(",") + )}` + : "" + }`; export const badgeUrl = ({ code, @@ -62,7 +74,8 @@ export const badgeUrl = ({ export const articlePreviewUrl = (slug: string) => `/img/article-previews/${slug}.png`; -export const navIconUrl = (navItem: string) => `/img/layout/${navItem}`; +export const navIconUrl = (navItem: typeof navItems[number]["name"]) => + `/img/layout/${navItem}`; export const gearImageUrl = (gearType: GearType, gearSplId: number) => `/img/gear/${gearType.toLowerCase()}/${gearSplId}`; export const weaponCategoryUrl = (