Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map almost closed view #545

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/pages/MapPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
import { CSSTransition } from 'react-transition-group';
import EateryCard from '../components/EateryCard';
import './MapPage.css';
import { IReadOnlyExtendedLocation } from '../types/locationTypes';
import {
IReadOnlyExtendedLocation,
LocationState,
} from '../types/locationTypes';

const token = process.env.VITE_MAPKITJS_TOKEN;

Expand Down Expand Up @@ -66,16 +69,23 @@ function MapPage({
>
{locations.map((location, locationIndex) => {
if (!location.coordinates) return undefined;
let markerColor = '#ff5b40';
if (location.closedLongTerm) {
markerColor = '#ff5b40';
} else if (
location.locationState === LocationState.CLOSES_SOON
) {
markerColor = '#ffd700';
} else if (location.isOpen) {
markerColor = '#69bb36';
}
Comment on lines +72 to +81
Copy link
Contributor

@cirex-web cirex-web Feb 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I think we can probably directly call

const colors: Record<LocationState, string> = {
	[LocationState.OPEN]: '#19b875',
	[LocationState.CLOSED]: '#dd3c18',
	[LocationState.CLOSED_LONG_TERM]: '#dd3c18',
	[LocationState.OPENS_SOON]: '#f6cc5d',
	[LocationState.CLOSES_SOON]: '#f3f65d',
};

defined in EateryCard.tsx for the values instead. Is there any reason why the colors need to be different between the two pages?

At this point, maybe we should honestly create a new file /util/colors.ts and write a getColorFromStatus function that uses this colors map.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or, or, better yet, make some css classes like .icon--closes-soon, .icon--opens-soon, .icon--closed and delegate the color assignment responsibility to CSS instead


return (
<Marker
key={location.conceptId}
latitude={location.coordinates.lat}
longitude={location.coordinates.lng}
color={
!location.closedLongTerm && location.isOpen
? '#69bb36'
: '#ff5b40'
}
color={markerColor}
glyphText={abbreviate(location.name)}
onSelect={() => {
setSelectedLocationIndex(locationIndex);
Expand Down