Skip to content

Commit

Permalink
Revert "Feat: Highlight currently selected row in table. (covid19indi…
Browse files Browse the repository at this point in the history
…a#1482)"

This reverts commit df8f2fd.
  • Loading branch information
nayakrahul committed Apr 25, 2020
1 parent 1259f76 commit a298645
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 46 deletions.
5 changes: 1 addition & 4 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1545,13 +1545,10 @@ table {
tr {
cursor: pointer;

&.is-highlighted {
background: $gray-hover !important;
}

&:hover {
background: $gray-hover !important;


.dropdown {
background: $gray-hover;
}
Expand Down
22 changes: 2 additions & 20 deletions src/components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ function Home(props) {
const [fetched, setFetched] = useState(false);
const [activeStateCode, setActiveStateCode] = useState('TT');
const [regionHighlighted, setRegionHighlighted] = useState(undefined);
const [rowHighlighted, setRowHighlighted] = useState({
statecode: undefined,
isDistrict: false,
districtName: undefined,
});
const [showUpdates, setShowUpdates] = useState(false);
const [anchor, setAnchor] = useState(null);
const [lastViewedLog, setLastViewedLog] = useLocalStorage(
Expand Down Expand Up @@ -115,20 +110,8 @@ function Home(props) {
setRegionHighlighted({district, state, index});
};

const onMapHighlightChange = useCallback((region) => {
setActiveStateCode(region.statecode);
if ('districtName' in region)
setRowHighlighted({
statecode: region.statecode,
isDistrict: true,
districtName: region.districtName,
});
else
setRowHighlighted({
statecode: region.statecode,
isDistrict: false,
districtName: undefined,
});
const onMapHighlightChange = useCallback(({statecode}) => {
setActiveStateCode(statecode);
}, []);

return (
Expand Down Expand Up @@ -176,7 +159,6 @@ function Home(props) {
states={states}
summary={false}
stateDistrictWiseData={stateDistrictWiseData}
rowHighlighted={rowHighlighted}
onHighlightState={onHighlightState}
onHighlightDistrict={onHighlightDistrict}
/>
Expand Down
1 change: 0 additions & 1 deletion src/components/mapexplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ function MapExplorer({
setPanelRegion(panelRegion);
currentHoveredRegion.statecode = panelRegion.statecode;
setCurrentHoveredRegion(currentHoveredRegion);
panelRegion.districtName = currentHoveredRegion.name;
if (onMapHighlightChange) onMapHighlightChange(panelRegion);
}
},
Expand Down
8 changes: 2 additions & 6 deletions src/components/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function Row(props) {
<tr
className={`state ${props.total ? 'is-total' : ''} ${
props.index % 2 === 0 ? 'is-odd' : ''
} ${props.isHighlighted ? 'is-highlighted' : ''}`}
}`}
onMouseEnter={() => props.onHighlightState?.(state, props.index)}
onMouseLeave={() => props.onHighlightState?.()}
onClick={!props.total ? handleReveal : null}
Expand Down Expand Up @@ -275,11 +275,7 @@ function Row(props) {
return (
<tr
key={index}
className={`district ${index % 2 === 0 ? 'is-odd' : ''} ${
props.highlightedDistrict === district
? 'is-highlighted'
: ''
}`}
className={`district ${index % 2 === 0 ? 'is-odd' : ''}`}
style={{
background: index % 2 === 0 ? '#f8f9fa' : '',
}}
Expand Down
17 changes: 2 additions & 15 deletions src/components/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ import Row from './row';
import React, {useState, useEffect} from 'react';
import {Link} from 'react-router-dom';

const isEqual = (prevProps, currProps) => {
return (
JSON.stringify(prevProps.rowHighlighted) ===
JSON.stringify(currProps.rowHighlighted)
);
const isEqual = () => {
return true;
};

function Table(props) {
Expand Down Expand Up @@ -274,16 +271,6 @@ function Table(props) {
? districts[state.state].districtData
: []
}
isHighlighted={
!props.rowHighlighted.isDistrict &&
props.rowHighlighted.statecode === state.statecode
}
highlightedDistrict={
props.rowHighlighted.isDistrict &&
props.rowHighlighted.statecode === state.statecode
? props.rowHighlighted.districtName
: null
}
onHighlightState={props.onHighlightState}
onHighlightDistrict={props.onHighlightDistrict}
handleReveal={handleReveal}
Expand Down

0 comments on commit a298645

Please sign in to comment.