mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
feat: Use a toggling button for impression data on/off (#7682)
Instead of using a dropdown list for impression data, this PR introduces a new config button that is a switch type button. It will be filled (contained) when impression data is on and will be outlined when impression data is off. Off: ![image](https://github.com/user-attachments/assets/4710c8aa-a853-43c3-bf3b-86dbbf1a2779) On: ![image](https://github.com/user-attachments/assets/08316155-83d1-45a2-941f-1c49c254a02b)
This commit is contained in:
parent
1f2d47bd91
commit
3a3aaad37d
@ -0,0 +1,51 @@
|
|||||||
|
import { ButtonLabel, StyledTooltipContent } from './ConfigButton.styles';
|
||||||
|
import { TooltipResolver } from 'component/common/TooltipResolver/TooltipResolver';
|
||||||
|
import { Button } from '@mui/material';
|
||||||
|
import type { ReactNode } from 'react';
|
||||||
|
|
||||||
|
type ToggleConfigButtonProps = {
|
||||||
|
onClick: () => void;
|
||||||
|
currentValue: boolean;
|
||||||
|
label: string;
|
||||||
|
icon: ReactNode;
|
||||||
|
labelWidth?: string;
|
||||||
|
tooltip: {
|
||||||
|
header: string;
|
||||||
|
description: string;
|
||||||
|
additionalContent?: ReactNode;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function ToggleConfigButton({
|
||||||
|
onClick,
|
||||||
|
currentValue,
|
||||||
|
label,
|
||||||
|
icon,
|
||||||
|
labelWidth,
|
||||||
|
tooltip,
|
||||||
|
}: ToggleConfigButtonProps) {
|
||||||
|
return (
|
||||||
|
<TooltipResolver
|
||||||
|
titleComponent={
|
||||||
|
<StyledTooltipContent>
|
||||||
|
<h3>{tooltip.header}</h3>
|
||||||
|
<p>{tooltip.description}</p>
|
||||||
|
{tooltip.additionalContent}
|
||||||
|
</StyledTooltipContent>
|
||||||
|
}
|
||||||
|
variant='custom'
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
aria-role='switch'
|
||||||
|
aria-checked={currentValue}
|
||||||
|
variant={currentValue ? 'contained' : 'outlined'}
|
||||||
|
color='primary'
|
||||||
|
startIcon={icon}
|
||||||
|
onClick={onClick}
|
||||||
|
disableElevation={true}
|
||||||
|
>
|
||||||
|
<ButtonLabel labelWidth={labelWidth}>{label}</ButtonLabel>
|
||||||
|
</Button>
|
||||||
|
</TooltipResolver>
|
||||||
|
);
|
||||||
|
}
|
@ -36,6 +36,7 @@ import Label from '@mui/icons-material/Label';
|
|||||||
import { ProjectIcon } from 'component/common/ProjectIcon/ProjectIcon';
|
import { ProjectIcon } from 'component/common/ProjectIcon/ProjectIcon';
|
||||||
import { MultiSelectConfigButton } from 'component/common/DialogFormTemplate/ConfigButtons/MultiSelectConfigButton';
|
import { MultiSelectConfigButton } from 'component/common/DialogFormTemplate/ConfigButtons/MultiSelectConfigButton';
|
||||||
import type { ITag } from 'interfaces/tags';
|
import type { ITag } from 'interfaces/tags';
|
||||||
|
import { ToggleConfigButton } from 'component/common/DialogFormTemplate/ConfigButtons/ToggleConfigButton';
|
||||||
|
|
||||||
interface ICreateFeatureDialogProps {
|
interface ICreateFeatureDialogProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -335,35 +336,19 @@ export const CreateFeatureDialog = ({
|
|||||||
onClose={clearDocumentationOverride}
|
onClose={clearDocumentationOverride}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SingleSelectConfigButton<boolean>
|
<ToggleConfigButton
|
||||||
tooltip={{
|
tooltip={{
|
||||||
header: 'Enable or disable impression data',
|
header: 'Enable or disable impression data',
|
||||||
|
description:
|
||||||
|
configButtonData.impressionData.text,
|
||||||
}}
|
}}
|
||||||
description={
|
currentValue={impressionData}
|
||||||
configButtonData.impressionData.text
|
onClick={() =>
|
||||||
|
setImpressionData(!impressionData)
|
||||||
}
|
}
|
||||||
options={[
|
label={`Impression data ${impressionData ? 'on' : 'off'}`}
|
||||||
{ label: 'On', value: true },
|
icon={<ImpressionDataIcon />}
|
||||||
{ label: 'Off', value: false },
|
labelWidth={`${'impression data off'.length}ch`}
|
||||||
]}
|
|
||||||
onChange={(value: boolean) => {
|
|
||||||
setImpressionData(value);
|
|
||||||
}}
|
|
||||||
button={{
|
|
||||||
label: `Impression data ${impressionData ? 'on' : 'off'}`,
|
|
||||||
icon: <ImpressionDataIcon />,
|
|
||||||
labelWidth: `${'impression data off'.length}ch`,
|
|
||||||
}}
|
|
||||||
search={{
|
|
||||||
label: 'Filter impression data states',
|
|
||||||
placeholder: 'Select impression data state',
|
|
||||||
}}
|
|
||||||
onOpen={() =>
|
|
||||||
setDocumentation(
|
|
||||||
configButtonData.impressionData,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
onClose={clearDocumentationOverride}
|
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user