Skip to content

Commit

Permalink
feat(protocol-designer): deck setup tools
Browse files Browse the repository at this point in the history
closes AUTh-673
  • Loading branch information
jerader committed Aug 20, 2024
1 parent f595599 commit 1f8a736
Show file tree
Hide file tree
Showing 14 changed files with 763 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { SPACING } from '../../../ui-style-constants'
import { StyledText } from '../../StyledText'

interface ListButtonAccordionProps {
headline: string
children: React.ReactNode
// determines if the accordion is expanded or not
isExpanded?: boolean
// is it nested into another accordion?
isNested?: boolean
// optional main headline for the top level accordion
mainHeadline?: string
headline?: string
}

/*
Expand All @@ -33,7 +33,11 @@ export function ListButtonAccordion(
return (
<Flex flexDirection={DIRECTION_COLUMN} width="100%">
{mainHeadline != null ? (
<Flex marginBottom={isExpanded ? SPACING.spacing40 : '0'}>
<Flex
marginBottom={
isExpanded && headline != null ? SPACING.spacing40 : '0'
}
>
<StyledText desktopStyle="bodyDefaultSemiBold">
{mainHeadline}
</StyledText>
Expand All @@ -46,11 +50,13 @@ export function ListButtonAccordion(
gridGap={SPACING.spacing4}
marginLeft={isNested ? SPACING.spacing40 : '0'}
>
<Flex marginBottom={SPACING.spacing4}>
<StyledText desktopStyle="bodyDefaultSemiBold">
{headline}
</StyledText>
</Flex>
{headline != null ? (
<Flex marginBottom={SPACING.spacing4}>
<StyledText desktopStyle="bodyDefaultSemiBold">
{headline}
</StyledText>
</Flex>
) : null}
<Flex flexDirection={DIRECTION_COLUMN}>{children}</Flex>
</Flex>
) : null}
Expand Down
1 change: 1 addition & 0 deletions components/src/atoms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './Checkbox'
export * from './CheckboxField'
export * from './Chip'
export * from './InputField'
export * from './ListButton'
export * from './ListItem'
export * from './ListItem/ListItemChildren//ListItemDescriptor'
export * from './MenuList'
Expand Down
2 changes: 1 addition & 1 deletion components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export * from './primitives'
export * from './slotmap'
export * from './structure'
export * from './tooltips'

export * from './organisms'
// styles
export * from './styles'
// new ui-overhaul style vars
Expand Down
1 change: 1 addition & 0 deletions components/src/organisms/Toolbox/Toolbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ export const Toolbox: Story = {
onCloseClick: () => {},
titleIconName: 'swap-horizontal',
closeButtonText: 'Text link',
onConfirmClick: () => {},
},
}
3 changes: 2 additions & 1 deletion components/src/organisms/Toolbox/__tests__/Toolbox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ describe('Toolbox', () => {
titleIconName: 'swap-horizontal',
onCloseClick: vi.fn(),
closeButtonText: 'exit',
onConfirmClick: vi.fn(),
}
render(props)
screen.getByText('header')
screen.getByText('done')
fireEvent.click(screen.getByTestId('Toolbox_confirmButton'))
expect(props.onCloseClick).toHaveBeenCalled()
expect(props.onConfirmClick).toHaveBeenCalled()
screen.getByText('mock children')
screen.getByText('exit')
fireEvent.click(screen.getByTestId('Toolbox_exit'))
Expand Down
13 changes: 8 additions & 5 deletions components/src/organisms/Toolbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ export interface ToolboxProps {
title: string
children: React.ReactNode
confirmButtonText: string
onConfirmClick: () => void
onCloseClick: () => void
titleIconName: IconName
closeButtonText?: string
closeButtonText: string
width?: string
titleIconName?: IconName
}

export function Toolbox(props: ToolboxProps): JSX.Element {
Expand All @@ -29,6 +30,7 @@ export function Toolbox(props: ToolboxProps): JSX.Element {
children,
confirmButtonText,
onCloseClick,
onConfirmClick,
titleIconName,
closeButtonText,
width = '19.5rem',
Expand Down Expand Up @@ -76,10 +78,11 @@ export function Toolbox(props: ToolboxProps): JSX.Element {
borderBottom={`1px solid ${COLORS.grey30}`}
>
<Flex gridGap={SPACING.spacing8} alignItems={ALIGN_CENTER}>
<Icon name={titleIconName} size="1.25rem" />
{titleIconName != null ? (
<Icon name={titleIconName} size="1.25rem" />
) : null}
<StyledText desktopStyle="bodyLargeSemiBold">{title}</StyledText>
</Flex>

<Btn
onClick={onCloseClick}
textDecoration={textDecorationUnderline}
Expand Down Expand Up @@ -110,7 +113,7 @@ export function Toolbox(props: ToolboxProps): JSX.Element {
<PrimaryButton
width="100%"
data-testid="Toolbox_confirmButton"
onClick={onCloseClick}
onClick={onConfirmClick}
>
{confirmButtonText}
</PrimaryButton>
Expand Down
1 change: 1 addition & 0 deletions components/src/organisms/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './DeckLabelSet'
export * from './Toolbox'
4 changes: 4 additions & 0 deletions protocol-designer/src/assets/localization/en/shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@
"protocol_designer": "Protocol Designer",
"remove": "remove",
"slot_stack_information": "Slot Stack Information",
"stagingArea": "Staging area",
"step_count": "Step {{current}}",
"step": "Step {{current}} / {{max}}",
"trashBin": "Trash bin",
"version": "Version # {{version}}",
"wasteChute": "Waste chute",
"wasteChuteAndStagingArea": "Waste chute and staging area",
"welcome": "Welcome to Protocol Designer",
"yes": "Yes"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{
"adapter": "Adapter",
"adapter_compatible_lab": "Adapter compatible labware",
"add_fixture": "Add a fixture",
"add_labware": "Add labware",
"add_module": "Add a module",
"aluminumBlock": "Aluminum block",
"clear": "Clear",
"customize_slot": "Customize slot {{slotName}}",
"deck_hardware": "Deck hardware",
"done": "Done",
"edit": "Edit",
"starting_deck_state": "Starting deck state"
"labware": "Labware",
"reservoir": "Reservoir",
"starting_deck_state": "Starting deck state",
"tiprack": "Tiprack",
"tubeRack": "Tube rack",
"wellPlate": "Well plate"
}
Loading

0 comments on commit 1f8a736

Please sign in to comment.