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

refactor(app, components, protocol-designer): add touch odd css class #15997

Open
wants to merge 4 commits into
base: edge
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion app/src/App/OnDeviceDisplayApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {

import { OnDeviceDisplayAppFallback } from './OnDeviceDisplayAppFallback'

import { hackWindowNavigatorOnLine } from './hacks'
import { hackWindowNavigatorOnLine, hackAddTouchClass } from './hacks'

import type { Dispatch } from '../redux/types'

Expand Down Expand Up @@ -176,6 +176,11 @@ export const OnDeviceDisplayApp = (): JSX.Element => {
}
}, [dispatch, isIdle, userSetBrightness])

React.useEffect(() => {
// add a touch class to the window object to tell CSS that we're in ODD mode
hackAddTouchClass()
}, [])

// TODO (sb:6/12/23) Create a notification manager to set up preference and order of takeover modals
return (
<ApiHostProvider hostname="127.0.0.1">
Expand Down
9 changes: 9 additions & 0 deletions app/src/App/hacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@
// This function is exposed in its own module so it can be mocked in testing
// since jest really doesn't like you doing this.

import { RESPONSIVENESS } from '@opentrons/components'

export const hackWindowNavigatorOnLine = (): void => {
Object.defineProperty(window.navigator, 'onLine', {
get: () => true,
})
window.dispatchEvent(new Event('online'))
}

// explicitly add a touch class to the body so UI elements know to render in ODD mode
export const hackAddTouchClass = (): void => {
if (!document.body.classList.contains(RESPONSIVENESS.TOUCH_ODD_CLASS)) {
document.body.classList.add(RESPONSIVENESS.TOUCH_ODD_CLASS)
}
}
2 changes: 1 addition & 1 deletion app/src/atoms/Banner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export function Banner(props: BannerProps): JSX.Element {
font-weight: ${TYPOGRAPHY.fontWeightRegular};
border-radius: ${SPACING.spacing4};

@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
font-size: 1.25rem;
font-weight: ${TYPOGRAPHY.fontWeightSemiBold};
background-color: ${COLORS.yellow35};
Expand Down
12 changes: 6 additions & 6 deletions app/src/atoms/InlineNotification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function InlineNotification(
gap: ${SPACING.spacing8};
border-radius: ${BORDERS.borderRadius4};
padding: ${SPACING.spacing8} ${SPACING.spacing12};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
gap: ${SPACING.spacing12};
border-radius: ${BORDERS.borderRadius8};
padding: ${SPACING.spacing12} ${SPACING.spacing16};
Expand All @@ -108,7 +108,7 @@ export function InlineNotification(
flexDirection={DIRECTION_ROW}
css={css`
gap: ${SPACING.spacing8};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
gap: ${SPACING.spacing12};
}
`}
Expand All @@ -117,7 +117,7 @@ export function InlineNotification(
css={css`
width: ${SPACING.spacing16};
height: ${SPACING.spacing16};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
width: 1.75rem;
height: 1.75rem;
}
Expand All @@ -141,7 +141,7 @@ export function InlineNotification(
inline text layout on ODD. Soooo here you go */}
<br
css={`
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
display: none;
}
`}
Expand Down Expand Up @@ -173,7 +173,7 @@ export function InlineNotification(
css={css`
width: 28px;
height: 28px;
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
width: ${SPACING.spacing48};
height: ${SPACING.spacing48};
}
Expand All @@ -187,7 +187,7 @@ export function InlineNotification(
css={css`
width: 28px;
height: 28px;
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
width: ${SPACING.spacing48};
height: ${SPACING.spacing48};
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/atoms/StepMeter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const StepMeter = (props: StepMeterProps): JSX.Element => {
position: ${POSITION_RELATIVE};
height: ${SPACING.spacing4};
background-color: ${COLORS.grey30};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
height: ${SPACING.spacing12};
}
`
Expand Down
2 changes: 1 addition & 1 deletion app/src/atoms/buttons/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function IconButton(props: IconButtonProps): JSX.Element {
: COLORS.transparent};
color: ${COLORS.grey50};
}
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
cursor: default;
}
`}
Expand Down
2 changes: 1 addition & 1 deletion app/src/atoms/buttons/TextOnlyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const GO_BACK_BUTTON_STYLE = css`
opacity: 70%;
}

@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
&:hover {
opacity: 100%;
}
Expand Down
14 changes: 7 additions & 7 deletions app/src/molecules/Command/Command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const PROPS_BY_STATE: Record<
style: `
border-radius: ${BORDERS.borderRadius4};
padding: ${SPACING.spacing8};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
border-radius: ${BORDERS.borderRadius8};
padding: ${SPACING.spacing12} ${SPACING.spacing24};
}
Expand All @@ -88,7 +88,7 @@ const PROPS_BY_STATE: Record<
border-radius: ${BORDERS.borderRadius4};
padding: ${SPACING.spacing8};
background-color: ${COLORS.red20};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
border-radius: ${BORDERS.borderRadius8};
padding: ${SPACING.spacing12} ${SPACING.spacing24};
background-color: ${COLORS.red35};
Expand All @@ -106,7 +106,7 @@ const PROPS_BY_STATE: Record<
background-color: ${COLORS.grey20};
border-radius: ${BORDERS.borderRadius4};
padding: ${SPACING.spacing8};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
border-radius: ${BORDERS.borderRadius8};
background-color: ${COLORS.grey35};
padding: ${SPACING.spacing12} ${SPACING.spacing24};
Expand Down Expand Up @@ -138,7 +138,7 @@ export function CenteredCommand(
margin-right: ${SPACING.spacing8};
max-height: ${ICON_SIZE_DESKTOP};
max-width: ${ICON_SIZE_DESKTOP};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
margin-right: ${SPACING.spacing12};
max-height: ${ICON_SIZE_ODD};
max-width: ${ICON_SIZE_ODD};
Expand All @@ -156,7 +156,7 @@ export function CenteredCommand(
width="100%"
css={`
min-height: ${ICON_SIZE_DESKTOP};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
min-height: ${ICON_SIZE_ODD};
}
`}
Expand Down Expand Up @@ -194,7 +194,7 @@ export function LeftAlignedCommand(
margin-right: ${SPACING.spacing8};
max-height: ${ICON_SIZE_DESKTOP};
max-width: ${ICON_SIZE_DESKTOP};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
margin-right: ${SPACING.spacing12};
max-height: ${ICON_SIZE_ODD};
max-width: ${ICON_SIZE_ODD};
Expand All @@ -212,7 +212,7 @@ export function LeftAlignedCommand(
width="100%"
css={`
min-height: ${ICON_SIZE_DESKTOP};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
min-height: ${ICON_SIZE_ODD};
}
`}
Expand Down
2 changes: 1 addition & 1 deletion app/src/molecules/Command/CommandIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function CommandIndex({
width="100%"
maxWidth={`${Math.max(allowSpaceForNDigits ?? 0, 3)}ch`}
css={`
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
display: none;
}
`}
Expand Down
4 changes: 2 additions & 2 deletions app/src/molecules/Command/CommandText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ function ThermocyclerRunProfile(
{...styleProps}
alignItems={shouldPropagateCenter ? ALIGN_CENTER : undefined}
css={`
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
display: flex !important;
} ;
}
`}
>
<CommandStyledText
Expand Down
6 changes: 3 additions & 3 deletions app/src/molecules/GenericWizardTile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { SmallButton, TextOnlyButton } from '../../atoms/buttons'
const ALIGN_BUTTONS = css`
align-items: ${ALIGN_FLEX_END};

@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
align-items: ${ALIGN_CENTER};
}
`
Expand All @@ -42,7 +42,7 @@ const CAPITALIZE_FIRST_LETTER_STYLE = css`

const Title = styled.h1`
${TYPOGRAPHY.h1Default};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
${TYPOGRAPHY.level4HeaderSemiBold};
height: ${SPACING.spacing40};
display: ${DISPLAY_INLINE_BLOCK};
Expand All @@ -54,7 +54,7 @@ const TILE_CONTAINER_STYLE = css`
justify-content: ${JUSTIFY_SPACE_BETWEEN};
padding: ${SPACING.spacing32};
height: 24.625rem;
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
height: 29.5rem;
}
`
Expand Down
10 changes: 5 additions & 5 deletions app/src/molecules/InProgressModal/InProgressModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const DESCRIPTION_STYLE = css`
margin-top: ${SPACING.spacing24};
margin-bottom: ${SPACING.spacing8};

@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
font-weight: ${TYPOGRAPHY.fontWeightBold};
font-size: ${TYPOGRAPHY.fontSize32};
margin-top: ${SPACING.spacing32};
Expand All @@ -41,7 +41,7 @@ const BODY_STYLE = css`
${TYPOGRAPHY.pRegular}
text-align: ${TYPOGRAPHY.textAlignCenter};

@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
${TYPOGRAPHY.level4HeaderRegular}
color: ${COLORS.grey60}
}
Expand All @@ -52,7 +52,7 @@ const MODAL_STYLE = css`
justify-content: ${JUSTIFY_CENTER};
padding: ${SPACING.spacing32};
height: 24.625rem;
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
max-height: 29.5rem;
height: 100%;
}
Expand All @@ -61,7 +61,7 @@ const SPINNER_STYLE = css`
color: ${COLORS.grey60};
width: 5.125rem;
height: 5.125rem;
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
width: 6.25rem;
height: 6.25rem;
}
Expand All @@ -70,7 +70,7 @@ const SPINNER_STYLE = css`
const DESCRIPTION_CONTAINER_STYLE = css`
padding-x: 6.5625rem;
gap: ${SPACING.spacing8};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
padding-x: ${SPACING.spacing40};
gap: ${SPACING.spacing4};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const meta: Meta<React.ComponentProps<typeof Wrapper>> = {
border: 4px solid #000000;
border-radius: ${BORDERS.borderRadius8};
max-width: 47rem;
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
max-width: 62rem;
max-height: 33.5rem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function CategorizedStepContent(
justifyContent={JUSTIFY_FLEX_START}
css={css`
gap: ${SPACING.spacing16};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
gap: ${SPACING.spacing24};
}
`}
Expand Down Expand Up @@ -153,7 +153,7 @@ export function CategorizedStepContent(
}

const HIDE_ON_TOUCHSCREEN_STYLE = `
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
display: none;
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const meta: Meta<React.ComponentProps<typeof DeckMapContent>> = {
border: 4px solid #000000;
border-radius: ${BORDERS.borderRadius8};
max-width: 47rem;
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
max-width: 62rem;
max-height: 33.5rem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function DescriptionContent(
flexDirection={DIRECTION_COLUMN}
css={`
gap: ${SPACING.spacing16};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
gap: ${SPACING.spacing8};
}
`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function InterventionInfo(props: InterventionInfoProps): JSX.Element {
color={COLORS.grey60}
css={css`
${LINE_CLAMP_STYLE}
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
display: none;
}
`}
Expand All @@ -61,7 +61,7 @@ export function InterventionInfo(props: InterventionInfoProps): JSX.Element {
<Divider
borderColor={COLORS.grey35}
css={`
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
display: none;
}
`}
Expand Down Expand Up @@ -91,7 +91,7 @@ const buildLocArrowLoc = (props: InterventionInfoProps): JSX.Element => {
alignItems={ALIGN_CENTER}
css={`
gap: ${SPACING.spacing4};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
gap: ${SPACING.spacing8};
}
`}
Expand Down Expand Up @@ -125,7 +125,7 @@ const buildLocColonLoc = (props: InterventionInfoProps): JSX.Element => {
alignItems={ALIGN_CENTER}
css={`
gap: ${SPACING.spacing4};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
gap: ${SPACING.spacing8};
}
`}
Expand All @@ -143,7 +143,7 @@ const buildLocColonLoc = (props: InterventionInfoProps): JSX.Element => {
const ICON_STYLE = css`
width: ${SPACING.spacing24};
height: ${SPACING.spacing24};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
width: ${SPACING.spacing40};
height: ${SPACING.spacing40};
}
Expand All @@ -153,7 +153,7 @@ const CARD_STYLE = css`
background-color: ${COLORS.grey20};
border-radius: ${BORDERS.borderRadius4};
gap: ${SPACING.spacing8};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
body.${RESPONSIVENESS.TOUCH_ODD_CLASS} & {
background-color: ${COLORS.grey35};
border-radius: ${BORDERS.borderRadius8};
}
Expand Down
Loading
Loading