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

Race & Ethnicities (Playtesting Followup): Grey Out Grid When Disaggregation Is Disabled #178

Merged
merged 1 commit into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,13 @@ export const Configuration: React.FC<MetricConfigurationProps> = observer(
{/* Dimension Fields (Enable/Disable) */}
{/* Race & Ethnicities Grid (when active disaggregation is Race / Ethnicity) */}
{activeDisaggregationKey === RACE_ETHNICITY_DISAGGREGATION_KEY ? (
<RaceEthnicitiesGrid />
<RaceEthnicitiesGrid
disaggregationEnabled={Boolean(
disaggregations[systemMetricKey][
RACE_ETHNICITY_DISAGGREGATION_KEY
]?.enabled
)}
/>
) : (
activeDimensionKeys?.map((dimensionKey) => {
const currentDisaggregation =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
palette,
typography,
} from "@justice-counts/common/components/GlobalStyles";
import styled from "styled-components/macro";
import styled, { css } from "styled-components/macro";

import {
DefinitionDisplayName,
Expand All @@ -34,8 +34,26 @@ import {
MetricOnOffWrapper,
} from ".";

export const RaceEthnicitiesBreakdownContainer = styled.div`
export const RaceEthnicitiesBreakdownContainer = styled.div<{
disaggregationEnabled?: boolean;
}>`
padding-top: 14px;
position: relative;

${({ disaggregationEnabled }) =>
!disaggregationEnabled &&
css`
&::after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: ${palette.solid.white};
opacity: 0.5;
}
`}
`;

export const CalloutBox = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,47 +36,50 @@ import {
RaceEthnicitiesTable,
} from ".";

export const RaceEthnicitiesGrid: React.FC = observer(() => {
const { metricConfigStore } = useStore();
const { ethnicitiesByRace } = metricConfigStore;
export const RaceEthnicitiesGrid: React.FC<{ disaggregationEnabled: boolean }> =
observer(({ disaggregationEnabled }) => {
const { metricConfigStore } = useStore();
const { ethnicitiesByRace } = metricConfigStore;

return (
<RaceEthnicitiesBreakdownContainer>
<CalloutBox>
<Description>
Answer the questions on the <span>Race and Ethnicity</span> form; the
grid below will reflect your responses.
</Description>
<RightArrowIcon />
</CalloutBox>
return (
<RaceEthnicitiesBreakdownContainer
disaggregationEnabled={disaggregationEnabled}
>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All indentation below this.

<CalloutBox>
<Description>
Answer the questions on the <span>Race and Ethnicity</span> form;
the grid below will reflect your responses.
</Description>
<RightArrowIcon />
</CalloutBox>

<GridHeaderContainer>
<GridRaceHeader>Race</GridRaceHeader>
<GridEthnicitiesHeader>
<EthnicityLabel>
Ethnicity <RightArrowIcon />
</EthnicityLabel>
<Ethnicity>Hispanic</Ethnicity>
<Ethnicity>Not Hispanic</Ethnicity>
<Ethnicity>Unknown</Ethnicity>
</GridEthnicitiesHeader>
</GridHeaderContainer>
<GridHeaderContainer>
<GridRaceHeader>Race</GridRaceHeader>
<GridEthnicitiesHeader>
<EthnicityLabel>
Ethnicity <RightArrowIcon />
</EthnicityLabel>
<Ethnicity>Hispanic</Ethnicity>
<Ethnicity>Not Hispanic</Ethnicity>
<Ethnicity>Unknown</Ethnicity>
</GridEthnicitiesHeader>
</GridHeaderContainer>

<RaceEthnicitiesTable>
{Object.entries(ethnicitiesByRace).map(([race, ethnicities]) => (
<RaceEthnicitiesRow key={race}>
<RaceCell>{race}</RaceCell>
<EthnicitiesRow>
{Object.values(ethnicities).map((ethnicity) => (
<EthnicityCell
key={ethnicity.key}
enabled={ethnicity.enabled}
/>
))}
</EthnicitiesRow>
</RaceEthnicitiesRow>
))}
</RaceEthnicitiesTable>
</RaceEthnicitiesBreakdownContainer>
);
});
<RaceEthnicitiesTable>
{Object.entries(ethnicitiesByRace).map(([race, ethnicities]) => (
<RaceEthnicitiesRow key={race}>
<RaceCell>{race}</RaceCell>
<EthnicitiesRow>
{Object.values(ethnicities).map((ethnicity) => (
<EthnicityCell
key={ethnicity.key}
enabled={ethnicity.enabled}
/>
))}
</EthnicitiesRow>
</RaceEthnicitiesRow>
))}
</RaceEthnicitiesTable>
</RaceEthnicitiesBreakdownContainer>
);
});