From 1f3e1045c3f1b562d0c0ac09359574389f7d6fc5 Mon Sep 17 00:00:00 2001 From: Mathias Schopmans Date: Mon, 19 Feb 2024 11:15:19 +0100 Subject: [PATCH] feat: add basic overview page --- src/components/Badge/Badge.module.css | 21 +++++++ src/components/Badge/Badge.tsx | 6 ++ src/components/Filter/Filter.module.css | 8 +++ src/components/Filter/Filter.tsx | 25 +++++++++ src/components/Filter/QueryFilter.module.css | 25 +++++++++ src/components/Filter/QueryFilter.tsx | 29 ++++++++++ src/components/Filter/RingFilter.module.css | 8 +++ src/components/Filter/RingFilter.tsx | 43 ++++++++++++++ src/components/ItemList/ItemList.tsx | 3 +- src/components/QuadrantList/QuadrantList.tsx | 7 +-- src/pages/_app.tsx | 2 +- src/pages/index.tsx | 1 - src/pages/overview.tsx | 59 ++++++++++++++++++++ src/styles/globals.css | 20 +++++++ 14 files changed, 249 insertions(+), 8 deletions(-) create mode 100644 src/components/Filter/Filter.module.css create mode 100644 src/components/Filter/Filter.tsx create mode 100644 src/components/Filter/QueryFilter.module.css create mode 100644 src/components/Filter/QueryFilter.tsx create mode 100644 src/components/Filter/RingFilter.module.css create mode 100644 src/components/Filter/RingFilter.tsx create mode 100644 src/pages/overview.tsx diff --git a/src/components/Badge/Badge.module.css b/src/components/Badge/Badge.module.css index 330aa87..3242ff2 100644 --- a/src/components/Badge/Badge.module.css +++ b/src/components/Badge/Badge.module.css @@ -27,3 +27,24 @@ color: var(--foreground); background-color: var(--badge); } + +.selectable { + cursor: pointer; + + &:not(.selected) { + color: var(--foreground); + border: 1px solid var(--foreground); + background: transparent; + } + + &:not(.colored) { + color: var(--foreground); + border: 1px solid var(--foreground); + background: transparent; + + &.selected { + color: var(--background); + background: #fff; + } + } +} diff --git a/src/components/Badge/Badge.tsx b/src/components/Badge/Badge.tsx index fe83d4b..2cb07ee 100644 --- a/src/components/Badge/Badge.tsx +++ b/src/components/Badge/Badge.tsx @@ -15,6 +15,8 @@ import { cn } from "@/lib/utils"; interface BadgeProps extends ComponentPropsWithoutRef<"span"> { children?: ReactNode; color?: string; + selectable?: boolean; + selected?: boolean; size?: "small" | "medium" | "large"; } @@ -22,6 +24,8 @@ export function Badge({ children, color, size = "medium", + selectable, + selected, ...props }: BadgeProps) { const style = useMemo( @@ -40,6 +44,8 @@ export function Badge({ styles.badge, styles[`size-${size}`], color && styles.colored, + selectable && styles.selectable, + selected && styles.selected, )} > {children} diff --git a/src/components/Filter/Filter.module.css b/src/components/Filter/Filter.module.css new file mode 100644 index 0000000..b95a1b4 --- /dev/null +++ b/src/components/Filter/Filter.module.css @@ -0,0 +1,8 @@ +.filter { + display: flex; + justify-content: space-between; + align-items: center; + flex-wrap: wrap; + margin-bottom: 20px; + gap: 20px; +} diff --git a/src/components/Filter/Filter.tsx b/src/components/Filter/Filter.tsx new file mode 100644 index 0000000..25550c1 --- /dev/null +++ b/src/components/Filter/Filter.tsx @@ -0,0 +1,25 @@ +import styles from "./Filter.module.css"; + +import { QueryFilter } from "@/components/Filter/QueryFilter"; +import { RingFilter } from "@/components/Filter/RingFilter"; + +interface FilterProps { + query?: string; + onQueryChange: (query: string) => void; + ring?: string; + onRingChange: (ring: string) => void; +} + +export function Filter({ + query, + onQueryChange, + ring, + onRingChange, +}: FilterProps) { + return ( +
+ + +
+ ); +} diff --git a/src/components/Filter/QueryFilter.module.css b/src/components/Filter/QueryFilter.module.css new file mode 100644 index 0000000..91ed846 --- /dev/null +++ b/src/components/Filter/QueryFilter.module.css @@ -0,0 +1,25 @@ +.filter { + flex: 1 1 100%; + position: relative; +} + +.input { + padding-right: 50px; +} + +.button { + position: absolute; + top: 50%; + right: 16px; + width: 20px; + height: 20px; + margin: -10px 0 0; + background: transparent; + border: none; +} + +@media (min-width: 768px) { + .filter { + flex: 1 1 auto; + } +} diff --git a/src/components/Filter/QueryFilter.tsx b/src/components/Filter/QueryFilter.tsx new file mode 100644 index 0000000..4fe9cf1 --- /dev/null +++ b/src/components/Filter/QueryFilter.tsx @@ -0,0 +1,29 @@ +import { ChangeEvent } from "react"; + +import Search from "../Icons/Search"; +import styles from "./QueryFilter.module.css"; + +interface QueryFilterProps { + value?: string; + onChange: (value: string) => void; +} + +export function QueryFilter({ value, onChange }: QueryFilterProps) { + const _onChange = (e: ChangeEvent) => { + onChange(e.target.value); + }; + + return ( +
+ + +
+ ); +} diff --git a/src/components/Filter/RingFilter.module.css b/src/components/Filter/RingFilter.module.css new file mode 100644 index 0000000..004c2f6 --- /dev/null +++ b/src/components/Filter/RingFilter.module.css @@ -0,0 +1,8 @@ +.filter { + list-style: none; + margin: 0; + padding: 0; + display: flex; + flex-wrap: wrap; + gap: 20px; +} diff --git a/src/components/Filter/RingFilter.tsx b/src/components/Filter/RingFilter.tsx new file mode 100644 index 0000000..b7b41ed --- /dev/null +++ b/src/components/Filter/RingFilter.tsx @@ -0,0 +1,43 @@ +import styles from "./RingFilter.module.css"; + +import { Badge, RingBadge } from "@/components/Badge/Badge"; +import { getRings } from "@/lib/data"; +import { cn } from "@/lib/utils"; + +interface RingFilterProps { + value?: string; + onChange: (value: string) => void; + className?: string; +} + +export function RingFilter({ value, onChange, className }: RingFilterProps) { + const rings = getRings(); + + return ( + + ); +} diff --git a/src/components/ItemList/ItemList.tsx b/src/components/ItemList/ItemList.tsx index e70a678..7740070 100644 --- a/src/components/ItemList/ItemList.tsx +++ b/src/components/ItemList/ItemList.tsx @@ -9,7 +9,7 @@ import { cn } from "@/lib/utils"; export interface ItemListProps { items: Item[]; activeId?: string; - size?: "small" | "default"; + size?: "small" | "default" | "large"; className?: string; } @@ -23,6 +23,7 @@ export function ItemList({