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

add portfolio filter info alert on overview map #744

Merged
merged 29 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f97e3b9
add react-select package
austensen Apr 5, 2023
5665f10
add react-relect (wip)
austensen Apr 6, 2023
623bb31
add back placeholder styles
austensen Apr 6, 2023
819cef2
separated selected values working
austensen Apr 6, 2023
62a5ae5
add more/less selections
austensen Apr 7, 2023
d6f2549
custom close icon for selected values
austensen Apr 7, 2023
01c44c4
replace old multiselect, new functional, styled for desktop
austensen Apr 7, 2023
e5ad5f2
fix multiselect error placement and input border
austensen Apr 7, 2023
d864725
fix info-alert styles
austensen Apr 7, 2023
f6ce0fa
multiselect mobile styles, start refactoring filter styles
austensen Apr 8, 2023
3608053
separate out MinMaxSelect component
austensen Apr 8, 2023
e160550
separate out MinMaxSelect styles
austensen Apr 8, 2023
909a533
fix up alert styles for no-close, align apply buttons
austensen Apr 8, 2023
c59cf10
finish styles refactor, fix multiselect apply move
austensen Apr 8, 2023
05cee1a
fix primary button letter spacing (from #738)
austensen Apr 8, 2023
ff20821
Merge 'filters' into multiselect-screen-reader
austensen Apr 8, 2023
b4a563f
reduce font weight for table body (except firefox)
austensen Apr 9, 2023
04c10c2
remove old styles mistakenly adding in 'filters' merge
austensen Apr 9, 2023
0176fdb
fix min-max label font styles & "to" -> "and"
austensen Apr 9, 2023
752f464
delete old multiselect styles file
austensen Apr 9, 2023
5afdd2c
"Zip Code" (fix capitalization)
austensen Apr 9, 2023
f2db0b4
add portfolio filter info alert on overview map, update big portfolio…
austensen Apr 9, 2023
57bf5ca
adjust down firefox font-weight in minmax- & multi-select components
austensen Apr 9, 2023
623503d
fix multiselect filename
austensen Apr 9, 2023
cfc797f
adjust desktop filter dropdowns for scrollbars on windows
austensen Apr 10, 2023
6715daa
add aria labels for multiselect buttons & description on input
austensen Apr 10, 2023
fa6a0dd
Merge in 'multiselect-rewrite' changes
austensen Apr 10, 2023
0497012
keep portfolio alerts closed for session
austensen Apr 10, 2023
10b2563
Merge branch 'filters' into overview-filter-alert
austensen Apr 11, 2023
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
3 changes: 2 additions & 1 deletion client/src/components/Amplitude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export type AmplitudeEvent =
| "portfolioViewDetail"
| "addressChangeMap"
| "addressChangePortfolio"
| "portfolioColumnSort";
| "portfolioColumnSort"
| "alertToFilterPortfolio";

export type EventProperties = {
[x: string]: unknown;
Expand Down
106 changes: 0 additions & 106 deletions client/src/components/MapBanner.tsx

This file was deleted.

123 changes: 123 additions & 0 deletions client/src/components/PortfolioAlerts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import React, { useEffect, useState } from "react";
import { Trans } from "@lingui/macro";
import classNames from "classnames";
import { Link, useLocation } from "react-router-dom";
import networkDiagram from "../assets/img/network-diagram.png";
import { AddressPageRoutes } from "../routes";
import { Alert, AlertProps } from "./Alert";
import { logAmplitudeEvent } from "./Amplitude";
import Modal from "./Modal";
import { isLegacyPath } from "./WowzaToggle";

export const BIG_PORTFOLIO_THRESHOLD = 300;
export const FILTER_PORTFOLIO_THRESHOLD = 15;

type PortfolioAlertProps = Omit<AlertProps, "children"> & {
portfolioSize: number;
};

type FilterPortfolioAlertProps = PortfolioAlertProps & {
addressPageRoutes: AddressPageRoutes;
};

export const BigPortfolioAlert = ({ portfolioSize, className, ...props }: PortfolioAlertProps) => {
Copy link
Member

Choose a reason for hiding this comment

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

alerts would be an excellent candidate for making into a reusable class component in storybook later! esp since these exact patterns also exist in LOC rebrand

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah for sure! That was the next one I was hoping to add, it should be mostly ready to copy over from here and just the styles need to be updated.

const [isLearnMoreModalVisible, setModalVisibility] = useState(false);
const { pathname } = useLocation();

// Preload modal image when BigPortfolioBanner mounts:
useEffect(() => {
new Image().src = networkDiagram;
}, []);

return !isLegacyPath(pathname) && portfolioSize > BIG_PORTFOLIO_THRESHOLD ? (
<Alert
className={classNames("big-portfolio-alert", className)}
variant="secondary"
type="info"
{...props}
>
<>
<Trans>Why am I seeing such a big portfolio?</Trans>{" "}
<button
className="button is-text"
onClick={() => {
logAmplitudeEvent("learnWhyPortfolioSoBig");
window.gtag("event", "learn-why-portfolio-so-big");
setModalVisibility(true);
}}
>
<Trans>Learn more.</Trans>
</button>
<Modal showModal={isLearnMoreModalVisible} onClose={() => setModalVisibility(false)}>
<h5 className="first-header">
<Trans>Why am I seeing such a big portfolio?</Trans>
</h5>
<p>
<Trans>
When two parties share the same business address, we group them as part of the same
portfolio.
</Trans>
</p>
<p className="is-marginless">
<Trans>
Some large corporations, however, are a bit more complicated and may share personnel
and financial stake with other related companies, which all will show up on Who Owns
What as one large portfolio.
</Trans>
</p>
<br />
<img className="img-responsive" src={networkDiagram} alt="" />
<br />
<p>
<Trans>
We’ve improved Who Owns What to dig deeper into the data and offer you a more complete
picture of buildings associated with your landlord.{" "}
<a
href="https://medium.com/justfixorg/untangling-nycs-web-of-real-estate-who-owns-what-s-latest-release-b22aac917617"
target="_blank"
rel="noopener noreferrer"
>
Read more in our methodology article
</a>
</Trans>
</p>
</Modal>
</>
</Alert>
) : (
<></>
);
};

export const FilterPortfolioAlert = ({
portfolioSize,
className,
addressPageRoutes,
...props
}: FilterPortfolioAlertProps) => {
const { pathname } = useLocation();

return !isLegacyPath(pathname) && portfolioSize >= FILTER_PORTFOLIO_THRESHOLD ? (
<Alert
className={classNames("big-portfolio-alert", className)}
variant="secondary"
type="info"
{...props}
>
<Trans>
Filter through this portfolio in{" "}
<Link
to={addressPageRoutes.portfolio}
onClick={() => {
logAmplitudeEvent("alertToFilterPortfolio", { portfolioSize });
window.gtag("event", "alert-topfilter-portfolio", { portfolioSize });
}}
>
the Portfolio tab.
</Link>
</Trans>
</Alert>
) : (
<></>
);
};
18 changes: 15 additions & 3 deletions client/src/components/PropertiesMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import { AddressRecord } from "./APIDataTypes";
import { FitBounds, Props as MapboxMapProps } from "react-mapbox-gl/lib/map";
import { Events as MapboxMapEvents } from "react-mapbox-gl/lib/map-events";
import { withMachineInStateProps } from "state-machine";
import { BigPortfolioBanner } from "./MapBanner";
import { BigPortfolioAlert, FilterPortfolioAlert } from "./PortfolioAlerts";
import { AddressPageRoutes } from "routes";

type Props = withMachineInStateProps<"portfolioFound"> & {
onAddrChange: (bbl: string) => void;
isVisible: boolean;
addressPageRoutes: AddressPageRoutes;
};

type State = {
Expand Down Expand Up @@ -267,8 +269,18 @@ export default class PropertiesMap extends Component<Props, State> {
}}
/>
{useNewPortfolioMethod ? (
<div className="MapBanner__container">
<BigPortfolioBanner sizeOfPortfolio={this.state.addrsPoints.length} />
<div className="MapAlert__container">
<BigPortfolioAlert
closeType="session"
storageId="map-big-portfolio-alert"
portfolioSize={this.state.addrsPoints.length}
/>
<FilterPortfolioAlert
closeType="session"
storageId="map-filter-portfolio-alert"
portfolioSize={this.state.addrsPoints.length}
addressPageRoutes={this.props.addressPageRoutes}
/>
</div>
) : (
<></>
Expand Down
8 changes: 6 additions & 2 deletions client/src/components/PropertiesSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { I18n } from "@lingui/core/i18n";
import { I18n as I18nComponent } from "@lingui/react";
import { PortfolioGraph } from "./PortfolioGraph";
import { ComplaintsSummary } from "./ComplaintsSummary";
import { BigPortfolioBanner } from "./MapBanner";
import { BigPortfolioAlert } from "./PortfolioAlerts";
import { LazyLoadWhenVisible } from "./LazyLoadWhenVisible";

type Props = withMachineInStateProps<"portfolioFound"> & {
Expand Down Expand Up @@ -105,7 +105,11 @@ export default class PropertiesSummary extends Component<Props, {}> {
graphJSON={state.context.portfolioData.portfolioGraph}
state={state}
/>
<BigPortfolioBanner sizeOfPortfolio={agg.bldgs} />
<BigPortfolioAlert
closeType="session"
storageId="summary-big-portfolio-alert"
portfolioSize={agg.bldgs}
/>
</LazyLoadWhenVisible>
</div>
)}
Expand Down
1 change: 1 addition & 0 deletions client/src/containers/AddressPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export default class AddressPage extends Component<AddressPageProps, State> {
window.gtag("event", "address-change-map");
}}
isVisible={this.props.currentTab === 0}
addressPageRoutes={routes}
/>
<DetailView
state={state}
Expand Down
Loading