From 137f9885a78f6d1f74d4207e028ff81314f7b054 Mon Sep 17 00:00:00 2001 From: Dan Reeves Date: Mon, 9 Oct 2023 01:56:55 +0100 Subject: [PATCH] weapons page style tweaks --- app/components/Form.tsx | 2 +- app/components/TagList.tsx | 12 ++-- app/components/ui/badge.tsx | 36 ++++++++++ app/routes/_pages.codex.skins.tsx | 4 +- app/routes/_pages.codex.weapons.tsx | 104 ++++++++++++++++++---------- app/utils/titleCase.ts | 3 + 6 files changed, 115 insertions(+), 46 deletions(-) create mode 100644 app/components/ui/badge.tsx create mode 100644 app/utils/titleCase.ts diff --git a/app/components/Form.tsx b/app/components/Form.tsx index 9ad74f9..d6235a9 100644 --- a/app/components/Form.tsx +++ b/app/components/Form.tsx @@ -111,7 +111,7 @@ export function Form({ onChange={(e) => { submit(e.currentTarget) }} - className={cn(`flex items-center justify-items-stretch gap-4`, className)} + className={cn(`flex items-center gap-4`, className)} > {children} diff --git a/app/components/TagList.tsx b/app/components/TagList.tsx index dd3c25e..e22144a 100644 --- a/app/components/TagList.tsx +++ b/app/components/TagList.tsx @@ -1,13 +1,13 @@ +import { Badge } from "~/components/ui/badge" +import { titleCase } from "~/utils/titleCase" + export function TagList({ tags }: { tags: string[] }) { return (
{tags.map((tag) => ( -
- {tag} -
+ + {titleCase(tag)} + ))}
) diff --git a/app/components/ui/badge.tsx b/app/components/ui/badge.tsx new file mode 100644 index 0000000..8665d4f --- /dev/null +++ b/app/components/ui/badge.tsx @@ -0,0 +1,36 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "app/lib/utils" + +const badgeVariants = cva( + "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", + { + variants: { + variant: { + default: + "border-transparent bg-primary text-primary-foreground hover:bg-primary/80", + secondary: + "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", + destructive: + "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", + outline: "text-foreground", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +export interface BadgeProps + extends React.HTMLAttributes, + VariantProps {} + +function Badge({ className, variant, ...props }: BadgeProps) { + return ( +
+ ) +} + +export { Badge, badgeVariants } diff --git a/app/routes/_pages.codex.skins.tsx b/app/routes/_pages.codex.skins.tsx index f92a874..72eeabd 100644 --- a/app/routes/_pages.codex.skins.tsx +++ b/app/routes/_pages.codex.skins.tsx @@ -29,8 +29,8 @@ export default function Skins() { return ( <> -
-
+ +
diff --git a/app/routes/_pages.codex.weapons.tsx b/app/routes/_pages.codex.weapons.tsx index 301262e..e333d5a 100644 --- a/app/routes/_pages.codex.weapons.tsx +++ b/app/routes/_pages.codex.weapons.tsx @@ -4,9 +4,14 @@ import { Link, useLoaderData, useOutlet } from "@remix-run/react" import { TagList } from "~/components/TagList" import { getItems } from "~/data/items.server" import { WeaponSchema } from "~/data/schemas.server" -import { Form, FormGroup, TextInput, Checkbox } from "~/components/Form" +import { Form } from "~/components/Form" import { getSearchParam } from "~/utils/getSearchParam" import { Img } from "~/components/Img" +import { Label } from "~/components/ui/label" +import { Input } from "~/components/ui/input" +import { Checkbox } from "~/components/ui/checkbox" +import { titleCase } from "~/utils/titleCase" +import { Button } from "~/components/ui/button" export const loader = async ({ request }: LoaderArgs) => { const url = new URL(request.url) @@ -31,51 +36,76 @@ export default function Weapons() { return ( <> - - - - - + +
+ + +
- - - - - - +
+ +
+ {["melee", "ranged"].map((kind) => ( +
+ + +
+ ))} +
+
- +
+ +
+ {["veteran", "zealot", "psyker", "ogryn"].map((kind) => ( +
+ + +
+ ))} +
+
-
    + +
      {weapons.map((weapon) => { return ( -
    • -
      - -
      - -
      - {weapon.display_name} -
      - - {/* TODO: Different schema for weapons and curios so this is not optional */} - - +
    • +
    • ) })}
    + {weapons.length < 1 ? (
    diff --git a/app/utils/titleCase.ts b/app/utils/titleCase.ts new file mode 100644 index 0000000..2d1002b --- /dev/null +++ b/app/utils/titleCase.ts @@ -0,0 +1,3 @@ +export function titleCase(str: string): string { + return str.charAt(0).toUpperCase() + str.slice(1) +}