mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-13 11:17:26 +02:00
https://linear.app/unleash/issue/2-849/dark-mode-ui-fixes    Also includes misc UI fixes and improvements we identified along the way. Co-authored by @NicolaeUnleash --------- Co-authored-by: NicolaeUnleash <103567375+NicolaeUnleash@users.noreply.github.com>
69 lines
1.6 KiB
TypeScript
69 lines
1.6 KiB
TypeScript
import { styled } from '@mui/material';
|
|
import GeneralSelect, {
|
|
IGeneralSelectProps,
|
|
} from 'component/common/GeneralSelect/GeneralSelect';
|
|
|
|
const StyledTitle = styled('h2')(({ theme }) => ({
|
|
margin: 0,
|
|
marginBottom: theme.spacing(1),
|
|
fontSize: theme.fontSizes.smallBody,
|
|
fontWeight: theme.fontWeight.thin,
|
|
color: theme.palette.text.secondary,
|
|
}));
|
|
|
|
interface IFeatureMetricsHoursProps {
|
|
hoursBack: number;
|
|
setHoursBack: (value: number) => void;
|
|
}
|
|
|
|
export const FEATURE_METRIC_HOURS_BACK_MAX = 48;
|
|
|
|
export const FeatureMetricsHours = ({
|
|
hoursBack,
|
|
setHoursBack,
|
|
}: IFeatureMetricsHoursProps) => {
|
|
const onChange: IGeneralSelectProps['onChange'] = key => {
|
|
setHoursBack(parseFeatureMetricsHour(key));
|
|
};
|
|
|
|
return (
|
|
<div>
|
|
<StyledTitle>Period</StyledTitle>
|
|
<GeneralSelect
|
|
name="feature-metrics-period"
|
|
id="feature-metrics-period"
|
|
options={hourOptions}
|
|
value={String(hoursBack)}
|
|
onChange={onChange}
|
|
fullWidth
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
const parseFeatureMetricsHour = (value: unknown) => {
|
|
switch (value) {
|
|
case '1':
|
|
return 1;
|
|
case '24':
|
|
return 24;
|
|
default:
|
|
return FEATURE_METRIC_HOURS_BACK_MAX;
|
|
}
|
|
};
|
|
|
|
const hourOptions: { key: `${number}`; label: string }[] = [
|
|
{
|
|
key: '1',
|
|
label: 'Last hour',
|
|
},
|
|
{
|
|
key: '24',
|
|
label: 'Last 24 hours',
|
|
},
|
|
{
|
|
key: `${FEATURE_METRIC_HOURS_BACK_MAX}`,
|
|
label: `Last ${FEATURE_METRIC_HOURS_BACK_MAX} hours`,
|
|
},
|
|
];
|