Skip to content

Commit 5bd8f03

Browse files
authored
fix(components,-protocol-designer): fix ToggleStepFormField style, realign step title (#17372)
This PR makes two small style changes: 1) fixes disabled style for ToggleStepFormField (and ListButton by implication), and 2) aligns the protocol step title to the center of its container.
1 parent 8f8b055 commit 5bd8f03

File tree

3 files changed

+33
-25
lines changed
  • components/src/atoms/ListButton
  • protocol-designer/src

3 files changed

+33
-25
lines changed

components/src/atoms/ListButton/index.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { css } from 'styled-components'
22
import { Flex } from '../../primitives'
33
import { SPACING } from '../../ui-style-constants'
44
import { BORDERS, COLORS } from '../../helix-design-system'
5-
import { CURSOR_POINTER } from '../../styles'
5+
import { CURSOR_DEFAULT, CURSOR_POINTER } from '../../styles'
66

77
import type { ReactNode } from 'react'
88
import type { StyleProps } from '../../primitives'
@@ -42,21 +42,23 @@ const LISTBUTTON_PROPS_BY_TYPE: Record<
4242
odd stylings
4343
**/
4444
export function ListButton(props: ListButtonProps): JSX.Element {
45-
const { type, children, disabled, onClick, ...styleProps } = props
45+
const { type, children, disabled = false, onClick, ...styleProps } = props
4646
const listButtonProps = LISTBUTTON_PROPS_BY_TYPE[type]
4747

4848
const LIST_BUTTON_STYLE = css`
49-
cursor: ${CURSOR_POINTER};
49+
cursor: ${disabled ? CURSOR_DEFAULT : CURSOR_POINTER};
5050
background-color: ${disabled
51-
? COLORS.grey35
51+
? COLORS.grey20
5252
: listButtonProps.backgroundColor};
5353
max-width: 26.875rem;
5454
padding: ${styleProps.padding ??
5555
`${SPACING.spacing20} ${SPACING.spacing24}`};
5656
border-radius: ${BORDERS.borderRadius8};
5757
5858
&:hover {
59-
background-color: ${listButtonProps.hoverBackgroundColor};
59+
background-color: ${disabled
60+
? COLORS.grey20
61+
: listButtonProps.hoverBackgroundColor};
6062
}
6163
`
6264

protocol-designer/src/molecules/ToggleStepFormField/index.tsx

+22-19
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
ListButton,
88
SPACING,
99
StyledText,
10-
TOOLTIP_BOTTOM,
1110
Tooltip,
1211
useHoverTooltip,
1312
} from '@opentrons/components'
@@ -37,43 +36,47 @@ export function ToggleStepFormField(
3736
tooltipContent,
3837
isDisabled,
3938
} = props
40-
const [targetProps, tooltipProps] = useHoverTooltip({
41-
placement: TOOLTIP_BOTTOM,
42-
})
39+
const [targetProps, tooltipProps] = useHoverTooltip()
4340

4441
return (
4542
<>
4643
<ListButton
4744
type="noActive"
4845
padding={SPACING.spacing12}
4946
onClick={() => {
50-
toggleUpdateValue(!toggleValue)
47+
if (!isDisabled) {
48+
toggleUpdateValue(!toggleValue)
49+
}
5150
}}
51+
disabled={isDisabled}
5252
>
53-
<Flex width="100%" flexDirection={DIRECTION_COLUMN}>
53+
{tooltipContent != null ? (
54+
<Tooltip tooltipProps={tooltipProps}>{tooltipContent}</Tooltip>
55+
) : null}
56+
57+
<Flex width="100%" flexDirection={DIRECTION_COLUMN} {...targetProps}>
5458
<Flex
5559
justifyContent={JUSTIFY_SPACE_BETWEEN}
5660
alignItems={ALIGN_CENTER}
5761
>
58-
<StyledText desktopStyle="bodyDefaultRegular">{title}</StyledText>
62+
<StyledText
63+
desktopStyle="bodyDefaultRegular"
64+
color={isDisabled ? COLORS.grey40 : COLORS.black90}
65+
>
66+
{title}
67+
</StyledText>
5968
<Flex alignItems={ALIGN_CENTER} gridGap={SPACING.spacing4}>
60-
{tooltipContent != null ? (
61-
<Tooltip tooltipProps={tooltipProps}>{tooltipContent}</Tooltip>
62-
) : null}
6369
<StyledText
6470
desktopStyle="bodyDefaultRegular"
65-
color={COLORS.grey60}
66-
{...targetProps}
71+
color={isDisabled ? COLORS.grey40 : COLORS.grey60}
6772
>
6873
{isSelected ? onLabel : offLabel}
6974
</StyledText>
70-
{isDisabled ? null : (
71-
<ToggleButton
72-
disabled={isDisabled}
73-
label={isSelected ? onLabel : offLabel}
74-
toggledOn={isSelected}
75-
/>
76-
)}
75+
<ToggleButton
76+
disabled={isDisabled}
77+
label={isSelected ? onLabel : offLabel}
78+
toggledOn={isSelected}
79+
/>
7780
</Flex>
7881
</Flex>
7982
</Flex>

protocol-designer/src/pages/Designer/ProtocolSteps/index.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ export function ProtocolSteps(): JSX.Element {
111111
gridGap={SPACING.spacing4}
112112
/>
113113
) : null}
114-
<Flex justifyContent={JUSTIFY_SPACE_BETWEEN}>
114+
<Flex
115+
justifyContent={JUSTIFY_SPACE_BETWEEN}
116+
alignItems={ALIGN_CENTER}
117+
>
115118
{currentStep != null && hoveredTerminalItem == null ? (
116119
<StyledText desktopStyle="headingSmallBold">
117120
{i18n.format(currentStep.stepName, 'capitalize')}

0 commit comments

Comments
 (0)