Skip to content

Commit 38f455a

Browse files
authored
refactor(app): add a one-column component (#15439)
provided basically for completeness. it's a box with width=100%. Closes EXEC-527
1 parent f194dc7 commit 38f455a

File tree

5 files changed

+99
-25
lines changed

5 files changed

+99
-25
lines changed

app/src/molecules/InterventionModal/ModalContentOneColSimpleButtons.tsx

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
StyledText,
77
TYPOGRAPHY,
88
} from '@opentrons/components'
9+
import { OneColumn } from './OneColumn'
910
import { RadioButton } from '../../atoms/buttons/RadioButton'
1011

1112
export interface ButtonProps {
@@ -32,29 +33,31 @@ export function ModalContentOneColSimpleButtons(
3233
const furtherButtons = props.furtherButtons ?? []
3334
const buttons = [props.firstButton, props.secondButton, ...furtherButtons]
3435
return (
35-
<Flex flexDirection={DIRECTION_COLUMN} gap={SPACING.spacing16}>
36-
<StyledText
37-
fontSize={TYPOGRAPHY.fontSize28}
38-
fontWeight={TYPOGRAPHY.fontWeightSemiBold}
39-
lineHeight={TYPOGRAPHY.lineHeight36}
40-
>
41-
{props.headline}
42-
</StyledText>
43-
<Flex flexDirection={DIRECTION_COLUMN} gap={SPACING.spacing4}>
44-
{buttons.map((buttonProps, idx) => (
45-
<RadioButton
46-
key={`button${idx}-${buttonProps.value}`}
47-
buttonLabel={buttonProps.label}
48-
buttonValue={buttonProps.value}
49-
isSelected={selected === buttonProps.value}
50-
onChange={event => {
51-
setSelected(event.target.value)
52-
buttonProps?.onChange && buttonProps.onChange(event)
53-
props?.onSelect && props.onSelect(event)
54-
}}
55-
/>
56-
))}
36+
<OneColumn>
37+
<Flex flexDirection={DIRECTION_COLUMN} gap={SPACING.spacing16}>
38+
<StyledText
39+
fontSize={TYPOGRAPHY.fontSize28}
40+
fontWeight={TYPOGRAPHY.fontWeightSemiBold}
41+
lineHeight={TYPOGRAPHY.lineHeight36}
42+
>
43+
{props.headline}
44+
</StyledText>
45+
<Flex flexDirection={DIRECTION_COLUMN} gap={SPACING.spacing4}>
46+
{buttons.map((buttonProps, idx) => (
47+
<RadioButton
48+
key={`button${idx}-${buttonProps.value}`}
49+
buttonLabel={buttonProps.label}
50+
buttonValue={buttonProps.value}
51+
isSelected={selected === buttonProps.value}
52+
onChange={event => {
53+
setSelected(event.target.value)
54+
buttonProps?.onChange && buttonProps.onChange(event)
55+
props?.onSelect && props.onSelect(event)
56+
}}
57+
/>
58+
))}
59+
</Flex>
5760
</Flex>
58-
</Flex>
61+
</OneColumn>
5962
)
6063
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import * as React from 'react'
2+
3+
import {
4+
StyledText,
5+
Box,
6+
Flex,
7+
BORDERS,
8+
RESPONSIVENESS,
9+
SPACING,
10+
ALIGN_CENTER,
11+
JUSTIFY_CENTER,
12+
} from '@opentrons/components'
13+
14+
import { OneColumn as OneColumnComponent } from './'
15+
16+
import type { Meta, StoryObj } from '@storybook/react'
17+
18+
function StandInContent(): JSX.Element {
19+
return (
20+
<Flex
21+
border={'4px dashed #A864FFFF'}
22+
borderRadius={BORDERS.borderRadius8}
23+
margin={SPACING.spacing16}
24+
height="104px"
25+
backgroundColor="#A864FF19"
26+
alignItems={ALIGN_CENTER}
27+
justifyContent={JUSTIFY_CENTER}
28+
>
29+
<StyledText as="h1">
30+
This is a standin for some other component
31+
</StyledText>
32+
</Flex>
33+
)
34+
}
35+
36+
const meta: Meta<React.ComponentProps<OneColumnComponent>> = {
37+
title: 'App/Molecules/InterventionModal/OneColumn',
38+
component: OneColumnComponent,
39+
render: args => (
40+
<Box
41+
css={`
42+
width: 500;
43+
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
44+
width: 500;
45+
}
46+
`}
47+
>
48+
<OneColumnComponent>
49+
<StandInContent />
50+
</OneColumnComponent>
51+
</Box>
52+
),
53+
}
54+
55+
export default meta
56+
57+
export type Story = StoryObj<OneColumnComponent>
58+
59+
export const ExampleOneColumn: Story = { args: {} }
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from 'react'
2+
3+
import { Box } from '@opentrons/components'
4+
5+
export interface OneColumnProps {
6+
children: React.ReactNode
7+
}
8+
9+
export function OneColumn({ children }: OneColumnProps): JSX.Element {
10+
return <Box width="100%">{children}</Box>
11+
}

app/src/molecules/InterventionModal/TwoColumn.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function StandInContent(): JSX.Element {
3535
<Box
3636
border={'4px dashed #A864FFFF'}
3737
borderRadius={BORDERS.borderRadius8}
38-
width="207px"
38+
margin={SPACING.spacing16}
3939
height="104px"
4040
backgroundColor="#A864FF19"
4141
/>

app/src/molecules/InterventionModal/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import { getIsOnDevice } from '../../redux/config'
2222
import type { IconName } from '@opentrons/components'
2323
import { ModalContentOneColSimpleButtons } from './ModalContentOneColSimpleButtons'
2424
import { TwoColumn } from './TwoColumn'
25-
export { ModalContentOneColSimpleButtons, TwoColumn }
25+
import { OneColumn } from './OneColumn'
26+
export { ModalContentOneColSimpleButtons, TwoColumn, OneColumn }
2627

2728
export type ModalType = 'intervention-required' | 'error'
2829

0 commit comments

Comments
 (0)