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

Settings: Metric Configuration: Playtesting Followups - Selection States (2/n) #112

Merged
merged 2 commits into from
Oct 25, 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
36 changes: 20 additions & 16 deletions publisher/src/components/MetricConfiguration/Configuration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
MetricDisaggregations as MetricDisaggregationsType,
} from "../../shared/types";
import { removeSnakeCase } from "../../utils";
import { ReactComponent as RightArrowIcon } from "../assets/right-arrow.svg";
import blueCheck from "../assets/status-check-icon.png";
import { BinaryRadioButton } from "../Forms";
import { TabbedBar, TabbedItem, TabbedOptions } from "../Reports";
Expand All @@ -48,6 +49,7 @@ import {
type MetricConfigurationProps = {
activeMetricKey: string;
filteredMetricSettings: { [key: string]: Metric };
activeDimension: MetricDisaggregationDimensions | undefined;
activeDisaggregation: MetricDisaggregationsType | undefined;
setActiveDisaggregation: React.Dispatch<
React.SetStateAction<MetricDisaggregationsType | undefined>
Expand All @@ -65,6 +67,7 @@ type MetricConfigurationProps = {
export const Configuration: React.FC<MetricConfigurationProps> = ({
activeMetricKey,
filteredMetricSettings,
activeDimension,
activeDisaggregation,
setActiveDisaggregation,
saveAndUpdateMetricSettings,
Expand Down Expand Up @@ -208,6 +211,7 @@ export const Configuration: React.FC<MetricConfigurationProps> = ({
<Dimension
key={dimension.key}
enabled={!metricEnabled || activeDisaggregation.enabled}
inView={dimension.key === activeDimension?.key}
onClick={() => setActiveDimension(dimension)}
>
<CheckboxWrapper>
Expand All @@ -217,22 +221,20 @@ export const Configuration: React.FC<MetricConfigurationProps> = ({
activeDisaggregation.enabled && dimension.enabled
}
onChange={() => {
if (activeDisaggregation.enabled) {
saveAndUpdateMetricSettings("DIMENSION", {
key: activeMetricKey,
disaggregations: [
{
key: activeDisaggregation.key,
dimensions: [
{
key: dimension.key,
enabled: !dimension.enabled,
},
],
},
],
});
}
saveAndUpdateMetricSettings("DIMENSION", {
key: activeMetricKey,
disaggregations: [
{
key: activeDisaggregation.key,
dimensions: [
{
key: dimension.key,
enabled: !dimension.enabled,
},
],
},
],
});
}}
/>
<BlueCheckIcon
Expand All @@ -252,6 +254,8 @@ export const Configuration: React.FC<MetricConfigurationProps> = ({
>
{dimension.label}
</DimensionTitle>

<RightArrowIcon />
</DimensionTitleWrapper>
</Dimension>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ import styled from "styled-components/macro";
import { BinaryRadioGroupWrapper, Button } from "../Forms";
import { palette, typography } from "../GlobalStyles";

const METRICS_VIEW_CONTAINER_BREAKPOINT = 1200;

export const MetricsViewContainer = styled.div`
width: 100%;
display: flex;
flex-direction: column;
align-items: flex-start;
overflow: hidden;

@media only screen and (max-width: ${METRICS_VIEW_CONTAINER_BREAKPOINT}px) {
overflow: unset;
}
`;

export const MetricsViewControlPanel = styled.div`
Expand All @@ -35,6 +41,12 @@ export const MetricsViewControlPanel = styled.div`
flex-wrap: wrap;
justify-content: space-between;
overflow-y: scroll;

@media only screen and (max-width: ${METRICS_VIEW_CONTAINER_BREAKPOINT}px) {
flex-direction: column;
flex-wrap: nowrap;
justify-content: unset;
}
`;

export const MetricsViewControlPanelOverflowHidden = styled(
Expand Down Expand Up @@ -63,6 +75,13 @@ export const PanelContainerRight = styled.div`
overflow-y: scroll;
`;

export const MetricBoxBottomPaddingContainer = styled.div`
display: flex;
flex-wrap: wrap;
padding-bottom: 100px;
overflow-y: scroll;
`;

type MetricBoxContainerProps = {
enabled?: boolean;
};
Expand All @@ -84,6 +103,12 @@ export const MetricBoxContainer = styled.div<MetricBoxContainerProps>`
cursor: pointer;
border: 1px solid ${palette.solid.blue};
}

@media only screen and (max-width: ${METRICS_VIEW_CONTAINER_BREAKPOINT}px) {
width: 100%;
max-width: unset;
flex: unset;
}
`;

export const MetricViewBoxContainer = styled(MetricBoxContainer)<{
Expand Down Expand Up @@ -118,25 +143,34 @@ export const MetricNameBadgeWrapper = styled.div`
align-items: center;
`;

export const Metric = styled.div`
export const Metric = styled.div<{ inView: boolean }>`
width: 100%;
display: flex;
gap: 20px;
align-items: center;
justify-content: flex-start;
border-bottom: 1px solid ${palette.solid.darkgrey};
padding-bottom: 8px;
padding-right: 50px;
padding: 12px;
position: relative;
background: ${({ inView }) =>
inView ? palette.highlight.lightblue1 : `none`};

&:hover {
background: ${palette.highlight.grey1};
cursor: pointer;
}

&:hover:after {
content: "➝";
svg {
position: absolute;
${typography.sizeCSS.title}
right: 0;
opacity: ${({ inView }) => (inView ? `1` : `0`)};
right: ${({ inView }) => (inView ? `13px` : `-20px`)};
transition: opacity 0.2s ease, right 0.3s ease;
}

&:hover svg {
display: block;
right: 13px;
opacity: 1;
}
`;

Expand All @@ -160,7 +194,12 @@ export const MetricDescription = styled.div`
export const MetricDetailsDisplay = styled.div`
width: 100%;
overflow-y: scroll;
padding: 24px 12px 24px 0;
padding: 24px 12px 50px 0;

@media only screen and (max-width: ${METRICS_VIEW_CONTAINER_BREAKPOINT}px) {
overflow-y: unset;
padding: 24px 12px 10px 0;
}
`;

export const MetricOnOffWrapper = styled.div`
Expand Down Expand Up @@ -200,6 +239,8 @@ export const MetricDisaggregations = styled.div<{ enabled?: boolean }>`
height: 100%;
width: 100%;
top: 0;
left: 0;
z-index: 2;
opacity: 0.5;
}
`}
Expand Down Expand Up @@ -236,24 +277,33 @@ export const DisaggregationTab = styled.div`
}
`;

export const Dimension = styled.div<{ enabled?: boolean }>`
export const Dimension = styled.div<{ enabled?: boolean; inView?: boolean }>`
${typography.sizeCSS.medium};
display: flex;
align-items: center;
gap: 12px;
padding: 15px 0;
padding: 17px 10px;
border-bottom: 1px solid ${palette.highlight.grey4};
position: relative;
background: ${({ inView }) =>
inView ? palette.highlight.lightblue1 : `none`};

&:hover {
background: ${palette.highlight.grey1};
cursor: pointer;
}

&:hover::before {
content: "➝";
svg {
position: absolute;
right: 0;
${typography.sizeCSS.title}
opacity: ${({ inView }) => (inView ? `1` : `0`)};
right: ${({ inView }) => (inView ? `13px` : `-20px`)};
transition: opacity 0.2s ease, right 0.3s ease;
}

&:hover svg {
display: block;
right: 13px;
opacity: 1;
}

&:last-child {
Expand All @@ -270,6 +320,7 @@ export const Dimension = styled.div<{ enabled?: boolean }>`
height: 100%;
width: 100%;
top: 0;
left: 0;
opacity: 0.5;
}
`}
Expand All @@ -289,6 +340,7 @@ export const DimensionTitle = styled.div<{ enabled?: boolean }>`
export const CheckboxWrapper = styled.div`
display: flex;
position: relative;
z-index: 1;
`;

export const Checkbox = styled.input`
Expand Down Expand Up @@ -460,16 +512,25 @@ export const MetricConfigurationWrapper = styled.div`
display: flex;
justify-content: space-between;
overflow-y: hidden;

@media only screen and (max-width: ${METRICS_VIEW_CONTAINER_BREAKPOINT}px) {
flex-direction: column;
}
`;

export const DefinitionsDisplayContainer = styled.div`
display: flex;
flex-direction: column;
flex: 1 1 55%;
padding-top: 48px;
padding-right: 12px;
padding-left: 126px;
padding: 48px 12px 50px 126px;
overflow-y: scroll;

@media only screen and (max-width: ${METRICS_VIEW_CONTAINER_BREAKPOINT}px) {
border-top: 1px solid ${palette.highlight.grey3};
padding: 30px 0 50px 0;
overflow-y: unset;
margin-right: 12px;
}
`;

export const DefinitionsDisplay = styled.div`
Expand Down Expand Up @@ -531,6 +592,7 @@ export const DefinitionSelection = styled.div`

export const DefinitionMiniButton = styled(RevertToDefaultButton)<{
selected?: boolean;
showDefault?: boolean;
}>`
width: unset;
padding: 9px 16px;
Expand All @@ -556,6 +618,9 @@ export const DefinitionMiniButton = styled(RevertToDefaultButton)<{


`};

${({ showDefault, selected }) =>
showDefault && !selected && `color: ${palette.highlight.grey4};`};
`;

export const NoDefinitionsSelected = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
} from "../../shared/types";
import { useStore } from "../../stores";
import { removeSnakeCase } from "../../utils";
import { ReactComponent as RightArrowIcon } from "../assets/right-arrow.svg";
import { Badge } from "../Badge";
import { Loading } from "../Loading";
import { TabbedBar, TabbedItem, TabbedOptions } from "../Reports";
Expand All @@ -39,6 +40,7 @@ import {
Configuration,
Metric,
MetricBox,
MetricBoxBottomPaddingContainer,
MetricConfigurationDisplay,
MetricConfigurationWrapper,
MetricDefinitions,
Expand Down Expand Up @@ -278,6 +280,7 @@ export const MetricConfiguration: React.FC<{

return {
...disaggregation,
enabled: true,
dimensions: disaggregation.dimensions.map((dimension) => {
if (
dimension.key ===
Expand Down Expand Up @@ -520,19 +523,21 @@ export const MetricConfiguration: React.FC<{

<MetricsViewControlPanel>
{/* List Of Metrics */}
{filteredMetricSettings &&
!activeMetricKey &&
Object.values(filteredMetricSettings).map((metric) => (
<MetricBox
key={metric.key}
metricKey={metric.key}
displayName={metric.display_name}
frequency={metric.frequency as ReportFrequency}
description={metric.description}
enabled={metric.enabled}
setActiveMetricKey={setActiveMetricKey}
/>
))}
{filteredMetricSettings && !activeMetricKey && (
<MetricBoxBottomPaddingContainer>
{Object.values(filteredMetricSettings).map((metric) => (
<MetricBox
key={metric.key}
metricKey={metric.key}
displayName={metric.display_name}
frequency={metric.frequency as ReportFrequency}
description={metric.description}
enabled={metric.enabled}
setActiveMetricKey={setActiveMetricKey}
/>
))}
</MetricBoxBottomPaddingContainer>
)}

{/* Metric Configuration */}
{activeMetricKey && (
Expand All @@ -547,19 +552,24 @@ export const MetricConfiguration: React.FC<{
← Back to Metrics
</BackToMetrics>

<Metric onClick={() => setActiveDimension(undefined)}>
<Metric
onClick={() => setActiveDimension(undefined)}
inView={!activeDimension}
>
<MetricName isTitle>
{metricSettings[activeMetricKey]?.display_name}
</MetricName>
<Badge color="GREEN" noMargin>
{metricSettings[activeMetricKey]?.frequency?.toLowerCase()}
</Badge>
<RightArrowIcon />
</Metric>

<MetricDetailsDisplay>
<Configuration
activeMetricKey={activeMetricKey}
filteredMetricSettings={filteredMetricSettings}
activeDimension={activeDimension}
activeDisaggregation={activeDisaggregation}
setActiveDisaggregation={setActiveDisaggregation}
saveAndUpdateMetricSettings={saveAndUpdateMetricSettings}
Expand Down
Loading