Skip to content

Commit ee9c71a

Browse files
authored
Merge pull request #668 from azavea/feature/asu/user-profile-subheader
Add user profile subheader components + button group
2 parents a14227e + b5d90ef commit ee9c71a

17 files changed

Lines changed: 601 additions & 101 deletions

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1313
- Bootstrap new frontend and remove old frontend [#666](https://github.com/azavea/echo-locator/pull/666)
1414
- Add Tailwind CSS theme [#667](https://github.com/azavea/echo-locator/pull/667)
1515
- Add a styled Button component [#667](https://github.com/azavea/echo-locator/pull/667)
16+
- Add a styled Button Group component [#668](https://github.com/azavea/echo-locator/pull/668)
17+
- Add user profile subheader components [#668](https://github.com/azavea/echo-locator/pull/668)
1618

1719
### Changed
1820

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 3 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

src/frontend/src/components/Button/Button.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {
2+
ButtonGroup,
3+
GroupedButton,
4+
} from "components/base/ButtonGroup/ButtonGroup";
5+
6+
import StarSolidIcon from "assets/icons/star-solid.svg?react";
7+
import ArrowFullRightIcon from "assets/icons/arrow-full-right.svg?react";
8+
9+
interface Props {
10+
size?: "small" | "medium" | "large";
11+
}
12+
const CompareFavoritesButton = ({ size = "medium" }: Props) => {
13+
return (
14+
<ButtonGroup>
15+
<GroupedButton
16+
aria-label="Remove from favorites"
17+
size={size}
18+
leftIcon={
19+
<StarSolidIcon className="w-[18px] fill fill-orange-800" />
20+
}
21+
/>
22+
<GroupedButton
23+
size={size}
24+
label="Compare favorites"
25+
rightIcon={
26+
<ArrowFullRightIcon className="w-[13px] fill fill-orange-900/60" />
27+
}
28+
/>
29+
</ButtonGroup>
30+
);
31+
};
32+
33+
export default CompareFavoritesButton;
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import type { Key } from "react-aria-components";
2+
3+
import Button from "components/base/Button/Button";
4+
import {
5+
ToggleButton,
6+
ToggleButtonGroup,
7+
} from "components/base/ToggleButton/ToggleButton";
8+
9+
import FamilyIcon from "assets/icons/family.svg?react";
10+
import TransitIcon from "assets/icons/transit.svg?react";
11+
import CarIcon from "assets/icons/car.svg?react";
12+
import ArrowFullRightIcon from "assets/icons/arrow-full-right.svg?react";
13+
import { useEffect, useState } from "react";
14+
15+
export const Places = {
16+
Work: "Work",
17+
School: "School",
18+
Daycare: "Daycare",
19+
FriendsFamily: "Friends/Family",
20+
Doctor: "Doctor",
21+
Other: "Other",
22+
};
23+
24+
type PlaceKeys = (typeof Places)[keyof typeof Places];
25+
26+
type Mode = "transit" | "car";
27+
type Size = "small" | "medium" | "large";
28+
29+
interface Props {
30+
size?: Size;
31+
mode: Mode;
32+
place: PlaceKeys;
33+
}
34+
35+
interface MobileProps extends Props {
36+
display: "map" | "list";
37+
}
38+
39+
const getModeIcon = (mode: Mode, size: Size) =>
40+
mode === "transit" ? (
41+
<TransitIcon className={getIconStyle(size)} />
42+
) : (
43+
<CarIcon className={getIconStyle(size)} />
44+
);
45+
46+
const getIconStyle = (size: Size) =>
47+
size === "small"
48+
? "font-normal text-gray-500 w-[13px]"
49+
: "font-normal text-gray-500 w-[17px]";
50+
51+
export const UserProfileSubheaderMobile = ({
52+
mode,
53+
place,
54+
size = "medium",
55+
display = "map",
56+
}: MobileProps) => {
57+
const [displayOption, setDisplayOption] = useState(new Set<Key>([display]));
58+
59+
useEffect(() => {
60+
setDisplayOption(new Set<Key>([display]));
61+
}, [display]);
62+
63+
const onChangeDisplayOption = (keys: Set<Key>) => {
64+
if (keys.size === 0) {
65+
setDisplayOption(displayOption);
66+
return;
67+
}
68+
setDisplayOption(keys);
69+
};
70+
71+
return (
72+
<div className="flex flex-column items-center gap-3">
73+
<Button
74+
variant="outline"
75+
size={size}
76+
label="You"
77+
leftIcon={<FamilyIcon className={getIconStyle(size)} />}
78+
/>
79+
<Button
80+
variant="outline"
81+
size={size}
82+
label={place}
83+
leftIcon={
84+
<div className="flex items-center gap-3">
85+
{getModeIcon(mode, size)}
86+
<ArrowFullRightIcon className="font-normal fill-gray-400 w-[10px] -ml-1" />
87+
</div>
88+
}
89+
/>
90+
<ToggleButtonGroup
91+
selectionMode="single"
92+
selectedKeys={displayOption}
93+
onSelectionChange={onChangeDisplayOption}
94+
>
95+
<ToggleButton id="map" size={size}>
96+
Map
97+
</ToggleButton>
98+
<ToggleButton id="list" size={size}>
99+
List
100+
</ToggleButton>
101+
</ToggleButtonGroup>
102+
</div>
103+
);
104+
};
105+
106+
export const UserProfileSubheader = ({
107+
mode,
108+
place,
109+
size = "medium",
110+
}: Props) => {
111+
return (
112+
<div className="flex flex-col gap-3 w-[360px]">
113+
<Button
114+
variant="outline"
115+
size={size}
116+
label="Your Profile"
117+
leftIcon={<FamilyIcon className={getIconStyle(size)} />}
118+
info="2br・public transit"
119+
/>
120+
<Button
121+
variant="outline"
122+
size={size}
123+
label={place}
124+
leftIcon={getModeIcon(mode, size)}
125+
info="122 Address St, Cambridge"
126+
/>
127+
</div>
128+
);
129+
};

0 commit comments

Comments
 (0)