Skip to content

Commit

Permalink
fix(app): fix choose csv file radio button size and text displayissue
Browse files Browse the repository at this point in the history
fix choose csv file radio button size and text

close RQA-3003
  • Loading branch information
koji committed Aug 14, 2024
1 parent afba276 commit 1a031e8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions app/src/atoms/buttons/RadioButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface RadioButtonProps extends StyleProps {
radioButtonType?: 'large' | 'small'
subButtonLabel?: string
id?: string
maxLines?: number | null
}

export function RadioButton(props: RadioButtonProps): JSX.Element {
Expand All @@ -33,6 +34,7 @@ export function RadioButton(props: RadioButtonProps): JSX.Element {
radioButtonType = 'large',
subButtonLabel,
id = buttonLabel,
maxLines = null,
} = props

const isLarge = radioButtonType === 'large'
Expand Down Expand Up @@ -77,6 +79,9 @@ export function RadioButton(props: RadioButtonProps): JSX.Element {
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
cursor: default;
display: ${maxLines != null ? '-webkit-box' : undefined};
-webkit-line-clamp: ${maxLines ?? undefined};
-webkit-box-orient: ${maxLines != null ? 'vertical' : undefined};
}
}
`
Expand Down
19 changes: 16 additions & 3 deletions app/src/organisms/ProtocolSetupParameters/ChooseCsvFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Flex,
LegacyStyledText,
SPACING,
truncateString,
TYPOGRAPHY,
} from '@opentrons/components'
import { useAllCsvFilesQuery } from '@opentrons/react-api-client'
Expand All @@ -27,6 +28,8 @@ import type {
} from '@opentrons/shared-data'
import type { CsvFileData } from '@opentrons/api-client'

const MAX_CHARS = 52
const CSV_FILENAME_BREAK_POINT = 46
interface ChooseCsvFileProps {
protocolId: string
handleGoBack: () => void
Expand Down Expand Up @@ -118,13 +121,18 @@ export function ChooseCsvFile({
csvFilesOnRobot.map((csv: CsvFileData) => (
<React.Fragment key={csv.id}>
<RadioButton
buttonLabel={csv.name}
buttonLabel={truncateString(
csv.name,
MAX_CHARS,
CSV_FILENAME_BREAK_POINT
)}
buttonValue={csv.id}
onChange={() => {
setCsvFileSelected({ id: csv.id, fileName: csv.name })
}}
id={`${csv.id}-on-robot`}
isSelected={csvFileSelected?.id === csv.id}
maxLines={3}
/>
</React.Fragment>
))
Expand All @@ -145,7 +153,11 @@ export function ChooseCsvFile({
<React.Fragment key={fileName}>
{csvFilePath.length !== 0 && fileName !== undefined ? (
<RadioButton
buttonLabel={fileName}
buttonLabel={truncateString(
fileName,
MAX_CHARS,
CSV_FILENAME_BREAK_POINT
)}
buttonValue={csvFilePath}
onChange={() => {
setCsvFileSelected({
Expand All @@ -155,6 +167,7 @@ export function ChooseCsvFile({
}}
id={`${csvFilePath.replace('/', '-')}}-on-usb`}
isSelected={csvFileSelected?.filePath === csvFilePath}
maxLines={3}
/>
) : null}
</React.Fragment>
Expand All @@ -180,7 +193,7 @@ const HEADER_TEXT_STYLE = css`
const CONTAINER_STYLE = css`
flex-direction: ${DIRECTION_COLUMN};
grid-gap: ${SPACING.spacing16};
flex: 1;
width: 28rem;
`

const LIST_CONTAINER_STYLE = css`
Expand Down

0 comments on commit 1a031e8

Please sign in to comment.