diff --git a/data/config.json b/data/config.json index 591c043..9bf9a68 100644 --- a/data/config.json +++ b/data/config.json @@ -67,12 +67,17 @@ "new": { "color": "#f1235a", "title": "New", - "titleShort": "N" + "titleShort": "N", + "description": "New in this version" }, "changed": { "color": "#40a7d1", "title": "Changed", - "titleShort": "C" + "titleShort": "C", + "description": "Recently changed" + }, + "default": { + "description": "Unchanged" } }, "chart": { diff --git a/src/components/Badge/Badge.tsx b/src/components/Badge/Badge.tsx index 2cb07ee..cec8057 100644 --- a/src/components/Badge/Badge.tsx +++ b/src/components/Badge/Badge.tsx @@ -57,6 +57,7 @@ interface RingBadgeProps extends Omit { ring: string; release?: string; } + export function RingBadge({ ring: ringName, release, @@ -76,14 +77,25 @@ export function RingBadge({ ); } +// Type guard to check if flag has the required attributes +function hasRequiredFlagAttributes(flag: any): flag is { + color: string; + title: string; + titleShort: string; +} { + return "color" in flag && "title" in flag && "titleShort" in flag; +} + interface FlagBadgeProps extends Omit { flag: Flag; short?: boolean; } + export function FlagBadge({ flag: flagName, short, ...props }: FlagBadgeProps) { if (flagName === Flag.Default) return null; const flag = getFlag(flagName); + if (!flag || !hasRequiredFlagAttributes(flag)) return null; return ( diff --git a/src/components/Radar/Legend.module.css b/src/components/Radar/Legend.module.css new file mode 100644 index 0000000..e6e0e0a --- /dev/null +++ b/src/components/Radar/Legend.module.css @@ -0,0 +1,35 @@ +.legend { + list-style: none; + padding: 0; + margin: 0; + font-size: 14px; + display: none; +} + +.icon { + display: inline-block; + vertical-align: middle; + width: 16px; + height: 16px; + margin: -2px 8px 0 0; +} + +@media (min-width: 768px) { + .legend { + display: block; + position: absolute; + left: 50%; + bottom: 50px; + transform: translateX(-50%); + } +} + +@media (min-width: 1200px) { + .legend { + bottom: auto; + left: auto; + right: 0; + top: 50%; + transform: translateY(-50%); + } +} diff --git a/src/components/Radar/Legend.tsx b/src/components/Radar/Legend.tsx new file mode 100644 index 0000000..8b6d961 --- /dev/null +++ b/src/components/Radar/Legend.tsx @@ -0,0 +1,37 @@ +import { ComponentPropsWithoutRef } from "react"; + +import styles from "./Legend.module.css"; + +import BlipChanged from "@/components/Icons/BlipChanged"; +import BlipDefault from "@/components/Icons/BlipDefault"; +import BlipNew from "@/components/Icons/BlipNew"; +import { getFlags } from "@/lib/data"; +import { Flag } from "@/lib/types"; + +function Icon({ + flag, + ...props +}: { flag: Flag } & ComponentPropsWithoutRef<"svg">) { + console.log("render Icon", flag); + switch (flag) { + case Flag.New: + return ; + case Flag.Changed: + return ; + case Flag.Default: + return ; + } +} + +export function Legend() { + return ( +
    + {Object.entries(getFlags()).map(([key, flag]) => ( +
  • + + {flag.description} +
  • + ))} +
+ ); +} diff --git a/src/components/Radar/Radar.module.css b/src/components/Radar/Radar.module.css index 77f4cbf..8232f1e 100644 --- a/src/components/Radar/Radar.module.css +++ b/src/components/Radar/Radar.module.css @@ -2,6 +2,7 @@ padding: 0 15px; margin-bottom: 60px; position: relative; + transition: padding 200ms ease-in-out; } .chart { @@ -67,7 +68,7 @@ } } -@media (min-width: 768px) and (max-width: 1023px) { +@media (min-width: 768px) and (max-width: 1200px) { .radar { padding: 150px 15px; } diff --git a/src/components/Radar/Radar.tsx b/src/components/Radar/Radar.tsx index 5ab4e98..091d953 100644 --- a/src/components/Radar/Radar.tsx +++ b/src/components/Radar/Radar.tsx @@ -11,6 +11,7 @@ import styles from "./Radar.module.css"; import { Chart } from "@/components/Radar/Chart"; import { Label } from "@/components/Radar/Label"; +import { Legend } from "@/components/Radar/Legend"; import { Item, Quadrant, Ring } from "@/lib/types"; import { cn } from "@/lib/utils"; @@ -96,6 +97,7 @@ export const Radar: FC = ({