Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): Properly truncate ODD command text #17003

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/src/organisms/ErrorRecoveryFlows/RecoverySplash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ALIGN_CENTER,
COLORS,
DIRECTION_COLUMN,
RESPONSIVENESS,
DISPLAY_FLEX,
Flex,
Icon,
Expand Down Expand Up @@ -200,6 +201,7 @@ export function RecoverySplash(props: RecoverySplashProps): JSX.Element | null {
overflowWrap={OVERFLOW_WRAP_BREAK_WORD}
color={COLORS.white}
textAlign={TEXT_ALIGN_CENTER}
css={TEXT_TRUNCATION_STYLE}
/>
</Flex>
</SplashFrame>
Expand Down Expand Up @@ -253,6 +255,7 @@ export function RecoverySplash(props: RecoverySplashProps): JSX.Element | null {
overflow="hidden"
overflowWrap={OVERFLOW_WRAP_BREAK_WORD}
textAlign={TEXT_ALIGN_CENTER}
css={TEXT_TRUNCATION_STYLE}
/>
</Flex>
</Flex>
Expand Down Expand Up @@ -301,6 +304,18 @@ const SplashFrame = styled(Flex)`
padding-bottom: 0px;
`

const TEXT_TRUNCATION_STYLE = css`
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;

@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
font-size: ${TYPOGRAPHY.fontSize22};
}
`

Comment on lines +307 to +318
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe adding this as a style-constants?
like

export const TEXT_TRUNCATION_STYLE = (
  lineClamp: number
): FlattenSimpleInterpolation => css`
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: ${OVERFLOW_HIDDEN};
  text-overflow: ellipsis;
  word-wrap: break-word;
  -webkit-line-clamp: ${lineClamp};
  word-break: break-all; // for a non word case like aaaaaaaa
  
   @media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
     font-size: ${TYPOGRAPHY.fontSize22};
    }
`

pd is use this 
https://github.com/Opentrons/opentrons/blob/edge/protocol-designer/src/atoms/constants.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the style is local to RecoverySplash, and we want the lineclamp to always be 2, I think hardcoding it is ok.

That being said, since it sounds like we use this in PD + elsewhere in the app, maybe we could do as you say in some more centralized location, perhaps moving more in the direction of style factories? Maybe we can talk about this in the next FE guild meeting!

const SHARED_BUTTON_STYLE_ODD = css`
width: 29rem;
height: 13.5rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,31 @@ const RUN_TIMER_STYLE = css`
color: ${COLORS.black90};
`

const COMMAND_ROW_STYLE_ANIMATED = css`
const COMMAND_ROW_STYLE_BASE = css`
font-size: 1.375rem;
line-height: 1.75rem;
font-weight: ${TYPOGRAPHY.fontWeightRegular};
text-align: center;
width: fit-content;
width: 100%;
max-width: 100%;
margin: auto;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
max-height: 4.6rem; // This ensures we don't show any extra text after truncating.
word-break: break-word;
white-space: normal;
`

const COMMAND_ROW_STYLE_ANIMATED = css`
${COMMAND_ROW_STYLE_BASE}
animation: ${fadeIn} 1.5s ease-in-out;
${ODD_ANIMATION_OPTIMIZATIONS}
`

const COMMAND_ROW_STYLE = css`
font-size: 1.375rem;
line-height: 1.75rem;
font-weight: ${TYPOGRAPHY.fontWeightRegular};
text-align: center;
width: fit-content;
margin: auto;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
${COMMAND_ROW_STYLE_BASE}
`

interface RunTimerInfo {
Expand Down
Loading