Skip to content

Commit c70381b

Browse files
feat: add ParkingIcon and SwimmingPoolIcon components; update ModelPicker to include new icons and display additional model information
1 parent a932a86 commit c70381b

5 files changed

Lines changed: 88 additions & 16 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { IconProps } from "@/types";
2+
import React from "react";
3+
4+
export const ParkingIcon: React.FC<IconProps> = (props) => (
5+
<svg
6+
xmlns="http://www.w3.org/2000/svg"
7+
width="12"
8+
height="12"
9+
fill="none"
10+
{...props}
11+
viewBox="0 0 12 12"
12+
>
13+
<path
14+
stroke="#fff"
15+
strokeWidth="1.3"
16+
strokeLinecap="round"
17+
strokeLinejoin="round"
18+
d="M4 2.5v7M4 2.5h2.6a2 2 0 0 1 0 4H4"
19+
/>
20+
</svg>
21+
);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { IconProps } from "@/types";
2+
import React from "react";
3+
4+
export const SwimmingPoolIcon: React.FC<IconProps> = (props) => (
5+
<svg
6+
xmlns="http://www.w3.org/2000/svg"
7+
width="12"
8+
height="12"
9+
fill="none"
10+
{...props}
11+
viewBox="0 0 12 12"
12+
>
13+
<path
14+
stroke="#fff"
15+
strokeWidth="1"
16+
strokeLinecap="round"
17+
strokeLinejoin="round"
18+
d="M1.4 5.1c.9 0 .9-.8 1.75-.8s.9.8 1.75.8.9-.8 1.75-.8.9.8 1.75.8.9-.8 1.6-.8M1.4 8.1c.9 0 .9-.8 1.75-.8s.9.8 1.75.8.9-.8 1.75-.8.9.8 1.75.8.9-.8 1.6-.8"
19+
/>
20+
</svg>
21+
);

frontend/src/features/try-fair/api/stac.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export type BaseModelStacItem = {
3535
"fair:hyperparameters_spec": HyperParamSpec[];
3636
"fair:source_imagery"?: string;
3737
"fair:preview_location"?: { type: "Point"; coordinates: [number, number] };
38+
"fair:preview_place"?: string;
39+
"fair:preview_country"?: string;
40+
"fair:coverage"?: string;
3841
"fair:base_model_title"?: string;
3942
keywords: string[];
4043
providers: Array<{ name: string; description?: string; url?: string }>;

frontend/src/features/try-fair/components/model-picker-modal.tsx

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import DropDown from "@/components/ui/dropdown/dropdown";
44
import { useDropdownMenu } from "@/hooks/use-dropdown-menu";
55
import { ChevronDownIcon } from "@/components/ui/icons";
66
import { BuildingIcon } from "@/components/ui/icons/buildings-icon";
7+
import { TreesIcon } from "@/components/ui/icons/trees-icon";
8+
import { SwimmingPoolIcon } from "@/components/ui/icons/swimming-pool-icon";
9+
import { ParkingIcon } from "@/components/ui/icons/parking-icon";
10+
import { IconProps } from "@/types";
711

812
type ModelPickerProps = {
913
selectedModel: BaseModelStacItem | null;
@@ -15,13 +19,20 @@ type ModelPickerProps = {
1519
openMobileDialog?: () => void;
1620
};
1721

22+
const FEATURE_ICONS: Record<string, React.FC<IconProps>> = {
23+
building: BuildingIcon,
24+
tree: TreesIcon,
25+
swimming_pool: SwimmingPoolIcon,
26+
parking: ParkingIcon,
27+
};
28+
1829
const FeatureBadge = ({ label }: { label: string | undefined }) => {
19-
const featureLabel =
20-
label ?? "".replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
30+
const Icon = FEATURE_ICONS[label ?? ""] ?? BuildingIcon;
31+
const featureLabel = (label ?? "").replace(/[-_]/g, " ");
2132

2233
return (
2334
<span className="inline-flex gap-2 items-center px-2 py-0.5 capitalize rounded bg-grey text-white text-xs font-medium">
24-
<BuildingIcon />
35+
<Icon />
2536
{featureLabel}
2637
</span>
2738
);
@@ -38,6 +49,12 @@ export const ModelPicker: React.FC<ModelPickerProps> = ({
3849
}) => {
3950
const { onDropdownHide, dropdownRef } = useDropdownMenu();
4051
const [isOpen, setIsOpen] = useState(false);
52+
const selectedLocation = [
53+
selectedModel?.properties["fair:preview_place"],
54+
selectedModel?.properties["fair:preview_country"],
55+
]
56+
.filter(Boolean)
57+
.join(", ");
4158

4259
const handleSelect = (model: BaseModelStacItem) => {
4360
onSelect(model);
@@ -62,6 +79,11 @@ export const ModelPicker: React.FC<ModelPickerProps> = ({
6279
<p className="font-medium text-dark text-xs leading-tight">
6380
{selectedModel.properties.title}
6481
</p>
82+
{selectedLocation && (
83+
<p className="text-grey text-[10px] leading-tight truncate">
84+
{selectedLocation}
85+
</p>
86+
)}
6587
</>
6688
) : (
6789
<p className="text-grey text-xs">Select a model</p>
@@ -130,6 +152,7 @@ export const ModelPickerContent = ({
130152
{models.map((model) => {
131153
const isSelected = selectedModel?.id === model.id;
132154
const baseModelTitle = model?.properties?.["fair:base_model_title"];
155+
const coverage = model?.properties?.["fair:coverage"];
133156
return (
134157
<button
135158
key={model.id}
@@ -159,6 +182,9 @@ export const ModelPickerContent = ({
159182
Model: {baseModelTitle}
160183
</p>
161184
)}
185+
{coverage && (
186+
<p className="text-grey text-xs mb-0.5 capitalize">{coverage}</p>
187+
)}
162188
<p className="text-grey text-xs mb-2">
163189
By: {model?.properties?.providers[0]?.name ?? ""}
164190
</p>

frontend/src/styles/index.css

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -450,32 +450,33 @@ hotosm-auth {
450450
}
451451

452452
.try-fair-confidence-slider::-webkit-slider-runnable-track {
453-
height: 6px;
454-
border-radius: 9999px;
455-
background: linear-gradient(90deg, #0088ff 0%, #ff383c 100%);
453+
height: 16px;
454+
background: linear-gradient(90deg, #0088ff 0%, #22c55e 100%);
455+
-webkit-clip-path: polygon(0 0, 100% 42%, 100% 58%, 0 100%);
456+
clip-path: polygon(0 0, 100% 42%, 100% 58%, 0 100%);
456457
}
457458

458459
.try-fair-confidence-slider::-webkit-slider-thumb {
459460
-webkit-appearance: none;
460461
appearance: none;
461-
width: 18px;
462-
height: 18px;
463-
margin-top: -6px;
464-
border-radius: 50%;
462+
width: 10px;
463+
height: 22px;
464+
margin-top: -3px;
465+
border-radius: 9999px;
465466
background: #687075;
466467
cursor: pointer;
467468
}
468469

469470
.try-fair-confidence-slider::-moz-range-track {
470-
height: 6px;
471-
border-radius: 9999px;
472-
background: linear-gradient(90deg, #0088ff 0%, #ff383c 100%);
471+
height: 16px;
472+
background: linear-gradient(90deg, #0088ff 0%, #22c55e 100%);
473+
clip-path: polygon(0 0, 100% 42%, 100% 58%, 0 100%);
473474
}
474475

475476
.try-fair-confidence-slider::-moz-range-thumb {
476-
width: 18px;
477-
height: 18px;
478-
border-radius: 50%;
477+
width: 10px;
478+
height: 22px;
479+
border-radius: 9999px;
479480
background: #687075;
480481
cursor: pointer;
481482
border: none;

0 commit comments

Comments
 (0)