Skip to content

Commit

Permalink
add condition to show label and
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyaochen authored and shiyaochen committed Oct 7, 2024
1 parent 64c92f0 commit 7661867
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
1 change: 0 additions & 1 deletion components/src/organisms/Toolbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export function Toolbox(props: ToolboxProps): JSX.Element {
</Flex>
</Flex>
</Flex>
<Box borderBottom={`1px solid ${COLORS.grey30}`} />
<Box
padding={childrenPadding}
flex="1 1 auto"
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/assets/localization/en/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"pickUp": "pick up tip"
},
"magnetAction": {
"label": "Magnet action",
"label": "Magnet state",
"options": {
"disengage": "Disengage",
"engage": "Engage"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('MagnetForm', () => {
screen.getByText('magnet')
screen.getByText('module')
screen.getByText('mock name')
screen.getByText('Magnet action')
screen.getByText('Magnet state')
const engage = screen.getByText('Engage')
screen.getByText('Disengage')
fireEvent.click(engage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface ToggleExpandStepFormFieldProps extends FieldProps {
toggleUpdateValue: (value: unknown) => void
toggleValue: unknown
caption?: string
islabel?: boolean
}
export function ToggleExpandStepFormField(
props: ToggleExpandStepFormFieldProps
Expand All @@ -37,6 +38,7 @@ export function ToggleExpandStepFormField(
toggleUpdateValue,
toggleValue,
caption,
islabel,
...restProps
} = props

Expand All @@ -59,19 +61,22 @@ export function ToggleExpandStepFormField(
<Flex justifyContent={JUSTIFY_SPACE_BETWEEN} alignItems={ALIGN_CENTER}>
<StyledText desktopStyle="bodyDefaultRegular">{title}</StyledText>
<Flex alignItems={ALIGN_CENTER} gridGap={SPACING.spacing4}>
<StyledText
{islabel ? (
<StyledText
desktopStyle="bodyDefaultRegular"
color={COLORS.grey60}
>
{isSelected ? onLabel : offLabel}
</StyledText>
<ToggleButton
onClick={() => {
onToggleUpdateValue()
}}
label={isSelected ? onLabel : offLabel}
toggledOn={isSelected}
/>
</StyledText>
) : null}

<ToggleButton
onClick={() => {
onToggleUpdateValue()
}}
label={isSelected ? onLabel : offLabel}
toggledOn={isSelected}
/>
</Flex>
</Flex>
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing10}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export function MagnetTools(props: StepFormProps): JSX.Element {
'form:step_edit_form.field.magnetAction.options.disengage'
)}
caption={engageHeightCaption}
islabel={true}
/>
</Flex>
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('MagnetTools', () => {
render(props)
screen.getByText('Module')
screen.getByText('mock name')
screen.getByText('Magnet action')
screen.getByText('Magnet state')
screen.getByLabelText('Engage')
const toggleButton = screen.getByRole('switch')
screen.getByText('Engage height')
Expand Down

0 comments on commit 7661867

Please sign in to comment.