diff --git a/app/src/frontend/displayPreferences-context.tsx b/app/src/frontend/displayPreferences-context.tsx index 6caed436..bde2d89d 100644 --- a/app/src/frontend/displayPreferences-context.tsx +++ b/app/src/frontend/displayPreferences-context.tsx @@ -1,6 +1,6 @@ import React, { createContext, useCallback, useContext, useEffect, useState } from 'react'; -import { LayerEnablementState } from './config/map-config'; +import { LayerEnablementState, MapTheme } from './config/map-config'; interface DisplayPreferencesContextState { vista: LayerEnablementState; @@ -18,6 +18,26 @@ interface DisplayPreferencesContextState { housing: LayerEnablementState; housingSwitch: (e: React.FormEvent) => void; housingSwitchOnClick: React.MouseEventHandler; + + conservation: LayerEnablementState; + conservationSwitch: (e: React.FormEvent) => void; + conservationSwitchOnClick: React.MouseEventHandler; + + parcel: LayerEnablementState; + parcelSwitch: (e: React.FormEvent) => void; + parcelSwitchOnClick: React.MouseEventHandler; + + borough: LayerEnablementState; + boroughSwitch: (e: React.FormEvent) => void; + boroughSwitchOnClick: React.MouseEventHandler; + + historicData: LayerEnablementState; + historicDataSwitch: (e: React.FormEvent) => void; + historicDataSwitchOnClick: React.MouseEventHandler; + + darkLightTheme: MapTheme; + darkLightThemeSwitch: (e: React.FormEvent) => void; + darkLightThemeSwitchOnClick: React.MouseEventHandler; } const stub = (): never => { @@ -41,7 +61,6 @@ export const DisplayPreferencesContext = createContext {}; @@ -66,14 +89,11 @@ export const DisplayPreferencesProvider: React.FC<{}> = ({children}) => { const [flood, setFlood] = useState('disabled'); const [creative, setCreative] = useState('disabled'); const [housing, setHousing] = useState('disabled'); - - /* const [borough, setBorough] = useState('enabled'); const [parcel, setParcel] = useState('disabled'); const [conservation, setConservation] = useState('disabled'); const [historicData, setHistoricData] = useState('disabled'); - */ - + const [darkLightTheme, setDarkLightTheme] = useState('night'); const vistaSwitch = useCallback( (e) => { @@ -135,6 +155,82 @@ export const DisplayPreferencesProvider: React.FC<{}> = ({children}) => { setCreative(newCreative); } + const boroughSwitch = useCallback( + (e) => { + flipBorough(e) + }, + [borough], + ) + const boroughSwitchOnClick = (e) => { + flipBorough(e) + } + function flipBorough(e) { + e.preventDefault(); + const newBorough = (borough === 'enabled')? 'disabled' : 'enabled'; + setBorough(newBorough); + } + + const parcelSwitch = useCallback( + (e) => { + flipParcel(e) + }, + [parcel], + ) + const parcelSwitchOnClick = (e) => { + flipParcel(e) + } + function flipParcel(e) { + e.preventDefault(); + const newParcel = (parcel === 'enabled')? 'disabled' : 'enabled'; + setParcel(newParcel); + } + + const conservationSwitch = useCallback( + (e) => { + flipConservation(e) + }, + [conservation], + ) + const conservationSwitchOnClick = (e) => { + flipConservation(e) + } + function flipConservation(e) { + e.preventDefault(); + const newConservation = (conservation === 'enabled')? 'disabled' : 'enabled'; + setConservation(newConservation); + } + + const historicDataSwitch = useCallback( + (e) => { + flipHistoricData(e) + }, + [historicData], + ) + const historicDataSwitchOnClick = (e) => { + flipHistoricData(e) + } + function flipHistoricData(e) { + e.preventDefault(); + const newHistoric = (historicData === 'enabled')? 'disabled' : 'enabled'; + setHistoricData(newHistoric); + } + + const darkLightThemeSwitch = useCallback( + (e) => { + flipDarkLightTheme(e) + }, + [darkLightTheme], + ) + const darkLightThemeSwitchOnClick = (e) => { + flipDarkLightTheme(e) + } + function flipDarkLightTheme(e) { + e.preventDefault(); + const newDarkLightTheme = (darkLightTheme === 'light')? 'night' : 'light'; + setDarkLightTheme(newDarkLightTheme); + } + + return ( = ({children}) => { creativeSwitchOnClick, housing, housingSwitch, - housingSwitchOnClick + housingSwitchOnClick, + conservation, + conservationSwitch, + conservationSwitchOnClick, + parcel, + parcelSwitch, + parcelSwitchOnClick, + + borough, + boroughSwitch, + boroughSwitchOnClick, + + historicData, + historicDataSwitch, + historicDataSwitchOnClick, + + darkLightTheme, + darkLightThemeSwitch, + darkLightThemeSwitchOnClick }}> {children} diff --git a/app/src/frontend/map/borough-switcher.tsx b/app/src/frontend/map/borough-switcher.tsx index 8995cd7e..68e35efd 100644 --- a/app/src/frontend/map/borough-switcher.tsx +++ b/app/src/frontend/map/borough-switcher.tsx @@ -1,19 +1,16 @@ import React from 'react'; import './borough-switcher.css'; +import { useDisplayPreferences } from '../displayPreferences-context'; -interface BoroughSwitcherProps { - currentDisplay: string; - onSubmit: (e: React.FormEvent) => void; -} - -const BoroughSwitcher: React.FC = (props) => ( -
- -
-); - -export default BoroughSwitcher; +export const BoroughSwitcher: React.FC<{}> = () => { + const { borough, boroughSwitch, darkLightTheme } = useDisplayPreferences(); + return ( +
+ +
+ ); +} \ No newline at end of file diff --git a/app/src/frontend/map/conservation-switcher.tsx b/app/src/frontend/map/conservation-switcher.tsx index 9b7c8a68..33c99c10 100644 --- a/app/src/frontend/map/conservation-switcher.tsx +++ b/app/src/frontend/map/conservation-switcher.tsx @@ -1,19 +1,16 @@ import React from 'react'; import './conservation-switcher.css'; +import { useDisplayPreferences } from '../displayPreferences-context'; -interface ConservationAreaSwitcherProps { - currentDisplay: string; - onSubmit: (e: React.FormEvent) => void; -} - -const ConservationAreaSwitcherProps: React.FC = (props) => ( -
- -
-); - -export default ConservationAreaSwitcherProps; +export const ConservationAreaSwitcher: React.FC<{}> = (props) => { + const { conservation, conservationSwitch, darkLightTheme } = useDisplayPreferences(); + return ( +
+ +
+ ); +} \ No newline at end of file diff --git a/app/src/frontend/map/creative-switcher.tsx b/app/src/frontend/map/creative-switcher.tsx index 4c5ded67..15ab783f 100644 --- a/app/src/frontend/map/creative-switcher.tsx +++ b/app/src/frontend/map/creative-switcher.tsx @@ -4,9 +4,9 @@ import './creative-switcher.css'; import { useDisplayPreferences } from '../displayPreferences-context'; export const CreativeSwitcher: React.FC<{}> = () => { - const { creative, creativeSwitch } = useDisplayPreferences(); + const { creative, creativeSwitch, darkLightTheme } = useDisplayPreferences(); return ( -
+ -
-); +const DataLayerSwitcher: React.FC = (props) => { + const { darkLightTheme } = useDisplayPreferences(); + return ( +
+ +
+ ); +} export default DataLayerSwitcher; diff --git a/app/src/frontend/map/flood-switcher.tsx b/app/src/frontend/map/flood-switcher.tsx index b08cf3ea..36071ea3 100644 --- a/app/src/frontend/map/flood-switcher.tsx +++ b/app/src/frontend/map/flood-switcher.tsx @@ -4,9 +4,9 @@ import './flood-switcher.css'; import { useDisplayPreferences } from '../displayPreferences-context'; export const FloodSwitcher: React.FC<{}> = () => { - const { flood, floodSwitch } = useDisplayPreferences(); + const { flood, floodSwitch, darkLightTheme } = useDisplayPreferences(); return ( -
+ -
-); - -export default HistoricDataSwitcherProps; +export const HistoricDataSwitcher: React.FC<{}> = (props) => { + const { historicData, historicDataSwitch, darkLightTheme } = useDisplayPreferences(); + return ( +
+ +
+ ); +} \ No newline at end of file diff --git a/app/src/frontend/map/housing-switcher.tsx b/app/src/frontend/map/housing-switcher.tsx index f4101c91..a1aac5f7 100644 --- a/app/src/frontend/map/housing-switcher.tsx +++ b/app/src/frontend/map/housing-switcher.tsx @@ -4,9 +4,9 @@ import './housing-switcher.css'; import { useDisplayPreferences } from '../displayPreferences-context'; export const HousingSwitcher: React.FC<{}> = () => { - const { housing, housingSwitch } = useDisplayPreferences(); + const { housing, housingSwitch, darkLightTheme } = useDisplayPreferences(); return ( -
+ -
-); - -export default ParcelSwitcher; +export const ParcelSwitcher: React.FC<{}> = () => { + const { parcel, parcelSwitch, darkLightTheme } = useDisplayPreferences(); + return ( +
+ +
+ ); +} \ No newline at end of file diff --git a/app/src/frontend/map/vista-switcher.tsx b/app/src/frontend/map/vista-switcher.tsx index 351d5b57..92881067 100644 --- a/app/src/frontend/map/vista-switcher.tsx +++ b/app/src/frontend/map/vista-switcher.tsx @@ -4,9 +4,9 @@ import './vista-switcher.css'; import { useDisplayPreferences } from '../displayPreferences-context'; export const VistaSwitcher: React.FC<{}> = () => { - const { vista, vistaSwitch } = useDisplayPreferences(); + const { vista, vistaSwitch, darkLightTheme } = useDisplayPreferences(); return ( -
+