Skip to content

Commit

Permalink
fix(AMSB-story): add support for onAllSubmodesDisabled prop
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-willis-arcadis committed Sep 24, 2024
1 parent 5ba1bb3 commit d5680c6
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ function pipe<T>(...fns: Array<(arg: T) => T>) {
const MetroModeSubsettingsComponent = ({
fillModeIcons,
modeButtonDefinitions,
onAllSubmodesDisabled,
onSetModeSettingValue,
onToggleModeButton
}: {
fillModeIcons?: boolean;
modeButtonDefinitions: Array<ModeButtonDefinition>;
onAllSubmodesDisabled?: (modeButton: ModeButtonDefinition) => void;
onSetModeSettingValue: (event: QueryParamChangeEvent) => void;
onToggleModeButton: (key: string, newState: boolean) => void;
}): ReactElement => {
Expand Down Expand Up @@ -74,6 +76,12 @@ const MetroModeSubsettingsComponent = ({
onToggleModeButton(key, newState);
};

const onAllSubmodesDisabledAction = (modeButton: ModeButtonDefinition) => {
toggleModeButtonAction(modeButton.key, false);
// Storybook Action:
onAllSubmodesDisabled?.(modeButton);
};

const setModeSettingValueAction = (event: QueryParamChangeEvent) => {
setModeSettingValues({ ...modeSettingValues, ...event });
// Storybook Action:
Expand All @@ -86,6 +94,7 @@ const MetroModeSubsettingsComponent = ({
fillModeIcons={fillModeIcons}
label="Select a transit mode"
modeButtons={processedModeButtons}
onAllSubmodesDisabled={onAllSubmodesDisabledAction}
onSettingsUpdate={setModeSettingValueAction}
onToggleModeButton={toggleModeButtonAction}
/>
Expand All @@ -111,7 +120,8 @@ export default {
argTypes: {
fillModeIcons: { control: "boolean" },
onSetModeSettingValue: { action: "set mode setting value" },
onToggleModeButton: { action: "toggle button" }
onToggleModeButton: { action: "toggle button" },
onAllSubmodesDisabled: { action: "all submodes disabled" }
},
component: MetroModeSubsettingsComponent,
title: "Trip Form Components/Advanced Mode Settings Buttons"
Expand Down

0 comments on commit d5680c6

Please sign in to comment.