-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): add a few components for deck configuration on ODD (#13688)
* feat(app): add a few components for deck configuration on ODD
- Loading branch information
Showing
15 changed files
with
481 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/src/organisms/DeviceDetailsDeckConfiguration/AddDeckConfigurationModal.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from 'react' | ||
import { touchScreenViewport } from '../../DesignTokens/constants' | ||
import { AddDeckConfigurationModal } from './AddDeckConfigurationModal' | ||
import type { Story, Meta } from '@storybook/react' | ||
|
||
export default { | ||
title: 'ODD/Organisms/AddDeckConfigurationModal', | ||
argTypes: { | ||
modalSize: { | ||
options: ['small', 'medium', 'large'], | ||
control: { type: 'radio' }, | ||
}, | ||
onOutsideClick: { action: 'clicked' }, | ||
}, | ||
parameters: touchScreenViewport, | ||
} as Meta | ||
|
||
const Template: Story< | ||
React.ComponentProps<typeof AddDeckConfigurationModal> | ||
> = args => <AddDeckConfigurationModal {...args} /> | ||
export const Default = Template.bind({}) | ||
Default.args = { | ||
slotName: 'D3', | ||
} |
112 changes: 112 additions & 0 deletions
112
app/src/organisms/DeviceDetailsDeckConfiguration/AddDeckConfigurationModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import * as React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { css } from 'styled-components' | ||
import { | ||
ALIGN_CENTER, | ||
BORDERS, | ||
Btn, | ||
COLORS, | ||
DIRECTION_COLUMN, | ||
DIRECTION_ROW, | ||
Flex, | ||
JUSTIFY_SPACE_BETWEEN, | ||
SPACING, | ||
TYPOGRAPHY, | ||
} from '@opentrons/components' | ||
|
||
import { StyledText } from '../../atoms/text' | ||
import { ODD_FOCUS_VISIBLE } from '../../atoms/buttons/constants' | ||
import { Modal } from '../../molecules/Modal' | ||
|
||
import type { ModalHeaderBaseProps } from '../../molecules/Modal/types' | ||
|
||
interface AddDeckConfigurationModalProps { | ||
slotName: string | ||
} | ||
|
||
// ToDo (kk:09/29/2023) | ||
// update this component when Deck configuration component is ready | ||
// Need to use getFixtureDisplayName | ||
export function AddDeckConfigurationModal({ | ||
slotName, | ||
}: AddDeckConfigurationModalProps): JSX.Element { | ||
const { t } = useTranslation('device_details') | ||
|
||
const modalHeader: ModalHeaderBaseProps = { | ||
title: t('add_to_slot', { slotName: slotName }), | ||
hasExitIcon: true, | ||
} | ||
|
||
return ( | ||
<Modal header={modalHeader}> | ||
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing32}> | ||
<StyledText as="p">{t('add_to_slot_description')}</StyledText> | ||
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing8}> | ||
<AddFixtureButton fixtureLoadName={t('staging_area_slot')} /> | ||
<AddFixtureButton fixtureLoadName={t('trash')} /> | ||
<AddFixtureButton fixtureLoadName={t('waste_chute')} /> | ||
</Flex> | ||
</Flex> | ||
</Modal> | ||
) | ||
} | ||
|
||
interface AddFixtureButtonProps { | ||
fixtureLoadName: string | ||
} | ||
function AddFixtureButton({ | ||
fixtureLoadName, | ||
}: AddFixtureButtonProps): JSX.Element { | ||
const { t } = useTranslation('device_details') | ||
|
||
// ToDo (kk:10/02/2023) | ||
// Need to update a function for onClick | ||
return ( | ||
<Btn | ||
onClick={() => {}} | ||
display="flex" | ||
justifyContent={JUSTIFY_SPACE_BETWEEN} | ||
flexDirection={DIRECTION_ROW} | ||
alignItems={ALIGN_CENTER} | ||
padding={`${SPACING.spacing16} ${SPACING.spacing24}`} | ||
css={FIXTIRE_BUTTON_STYLE} | ||
> | ||
<StyledText as="p" fontWeight={TYPOGRAPHY.fontWeightSemiBold}> | ||
{fixtureLoadName} | ||
</StyledText> | ||
<StyledText as="p">{t('add')}</StyledText> | ||
</Btn> | ||
) | ||
} | ||
|
||
const FIXTIRE_BUTTON_STYLE = css` | ||
background-color: ${COLORS.light1}; | ||
cursor: default; | ||
border-radius: ${BORDERS.borderRadiusSize3}; | ||
box-shadow: none; | ||
&:focus { | ||
background-color: ${COLORS.light1Pressed}; | ||
box-shadow: none; | ||
} | ||
&:hover { | ||
border: none; | ||
box-shadow: none; | ||
background-color: ${COLORS.light1}; | ||
} | ||
&:focus-visible { | ||
box-shadow: ${ODD_FOCUS_VISIBLE}; | ||
background-color: ${COLORS.light1}; | ||
} | ||
&:active { | ||
background-color: ${COLORS.light1Pressed}; | ||
} | ||
&:disabled { | ||
background-color: ${COLORS.light1}; | ||
color: ${COLORS.darkBlack60}; | ||
} | ||
` |
24 changes: 24 additions & 0 deletions
24
...organisms/DeviceDetailsDeckConfiguration/DeckConfigurationDiscardChangesModal.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from 'react' | ||
import { touchScreenViewport } from '../../DesignTokens/constants' | ||
import { DeckConfigurationDiscardChangesModal } from './DeckConfigurationDiscardChangesModal' | ||
import type { Story, Meta } from '@storybook/react' | ||
|
||
export default { | ||
title: 'ODD/Organisms/DeckConfigurationDiscardChangesModalProps', | ||
argTypes: { | ||
modalSize: { | ||
options: ['small', 'medium', 'large'], | ||
control: { type: 'radio' }, | ||
}, | ||
onOutsideClick: { action: 'clicked' }, | ||
}, | ||
parameters: touchScreenViewport, | ||
} as Meta | ||
|
||
const Template: Story< | ||
React.ComponentProps<typeof DeckConfigurationDiscardChangesModal> | ||
> = args => <DeckConfigurationDiscardChangesModal {...args} /> | ||
export const Default = Template.bind({}) | ||
Default.args = { | ||
setShowConfirmationModal: () => {}, | ||
} |
58 changes: 58 additions & 0 deletions
58
app/src/organisms/DeviceDetailsDeckConfiguration/DeckConfigurationDiscardChangesModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import * as React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { | ||
DIRECTION_COLUMN, | ||
DIRECTION_ROW, | ||
Flex, | ||
SPACING, | ||
} from '@opentrons/components' | ||
|
||
import { StyledText } from '../../atoms/text' | ||
import { SmallButton } from '../../atoms/buttons' | ||
import { Modal } from '../../molecules/Modal' | ||
|
||
import { ModalHeaderBaseProps } from '../../molecules/Modal/types' | ||
|
||
interface DeckConfigurationDiscardChangesModalProps { | ||
setShowConfirmationModal: (showConfirmationModal: boolean) => void | ||
} | ||
|
||
export function DeckConfigurationDiscardChangesModal({ | ||
setShowConfirmationModal, | ||
}: DeckConfigurationDiscardChangesModalProps): JSX.Element { | ||
const { t } = useTranslation('device_details') | ||
const modalHeader: ModalHeaderBaseProps = { | ||
title: t('changes_will_be_lost'), | ||
} | ||
|
||
const handleDiscard = (): void => { | ||
// ToDo (kk: 09/29/2023) discard deck configuration changes | ||
setShowConfirmationModal(false) | ||
// close the modal and then back the previous screen | ||
} | ||
|
||
return ( | ||
<Modal header={modalHeader}> | ||
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing32}> | ||
<StyledText as="p">{t('changes_will_be_lost_description')}</StyledText> | ||
<Flex | ||
width="100%" | ||
flexDirection={DIRECTION_ROW} | ||
gridGap={SPACING.spacing8} | ||
> | ||
<SmallButton | ||
width="100%" | ||
buttonType="alert" | ||
buttonText={t('discard_changes')} | ||
onClick={handleDiscard} | ||
/> | ||
<SmallButton | ||
width="100%" | ||
buttonText={t('continue_editing')} | ||
onClick={() => setShowConfirmationModal(false)} | ||
/> | ||
</Flex> | ||
</Flex> | ||
</Modal> | ||
) | ||
} |
24 changes: 24 additions & 0 deletions
24
...src/organisms/DeviceDetailsDeckConfiguration/DeckFixtureSetupInstructionModal.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from 'react' | ||
import { touchScreenViewport } from '../../DesignTokens/constants' | ||
import { DeckFixtureSetupInstructionModal } from './DeckFixtureSetupInstructionModal' | ||
import type { Story, Meta } from '@storybook/react' | ||
|
||
export default { | ||
title: 'ODD/Organisms/DeckFixtureSetupInstructionModal', | ||
argTypes: { | ||
modalSize: { | ||
options: ['small', 'medium', 'large'], | ||
control: { type: 'radio' }, | ||
}, | ||
onOutsideClick: { action: 'clicked' }, | ||
}, | ||
parameters: touchScreenViewport, | ||
} as Meta | ||
|
||
const Template: Story< | ||
React.ComponentProps<typeof DeckFixtureSetupInstructionModal> | ||
> = args => <DeckFixtureSetupInstructionModal {...args} /> | ||
export const Default = Template.bind({}) | ||
Default.args = { | ||
setShowSetupInstructionsModal: () => {}, | ||
} |
68 changes: 68 additions & 0 deletions
68
app/src/organisms/DeviceDetailsDeckConfiguration/DeckFixtureSetupInstructionModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import * as React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { | ||
BORDERS, | ||
COLORS, | ||
DIRECTION_COLUMN, | ||
DIRECTION_ROW, | ||
Flex, | ||
SPACING, | ||
TYPOGRAPHY, | ||
} from '@opentrons/components' | ||
import { StyledText } from '../../atoms/text' | ||
import { Modal } from '../../molecules/Modal' | ||
|
||
import type { ModalHeaderBaseProps } from '../../molecules/Modal/types' | ||
|
||
import imgSrc from '../../assets/images/on-device-display/deck_fixture_setup.png' | ||
|
||
const SETUP_INSTRUCTION_URL = 'www.opentrons.com/support/fixtures' | ||
const IMG_ALT = 'QRCode for Deck fixture setup instructions page' | ||
|
||
interface DeckFixtureSetupInstructionModalProps { | ||
setShowSetupInstructionsModal: (showSetupInstructionsModal: boolean) => void | ||
} | ||
|
||
export function DeckFixtureSetupInstructionModal({ | ||
setShowSetupInstructionsModal, | ||
}: DeckFixtureSetupInstructionModalProps): JSX.Element { | ||
const { t } = useTranslation('device_details') | ||
const modalHeader: ModalHeaderBaseProps = { | ||
title: t('deck_fixture_setup_instructions'), | ||
iconName: 'information', | ||
iconColor: COLORS.darkBlack100, | ||
hasExitIcon: true, | ||
} | ||
|
||
return ( | ||
<Modal | ||
header={modalHeader} | ||
onOutsideClick={() => setShowSetupInstructionsModal(false)} | ||
> | ||
<Flex flexDirection={DIRECTION_ROW} gridGap={SPACING.spacing40}> | ||
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing24}> | ||
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing12}> | ||
<StyledText as="p"> | ||
{t('deck_fixture_setup_modal_top_description')} | ||
</StyledText> | ||
<StyledText as="p"> | ||
{t('deck_fixture_setup_modal_bottom_description')} | ||
</StyledText> | ||
</Flex> | ||
<Flex | ||
padding={`${SPACING.spacing16} ${SPACING.spacing24}`} | ||
backgroundColor={COLORS.light1} | ||
borderRadius={BORDERS.borderRadiusSize3} | ||
> | ||
<StyledText as="p" fontWeight={TYPOGRAPHY.fontWeightSemiBold}> | ||
{SETUP_INSTRUCTION_URL} | ||
</StyledText> | ||
</Flex> | ||
</Flex> | ||
<Flex> | ||
<img src={imgSrc} alt={IMG_ALT} width="178px" height="178px" /> | ||
</Flex> | ||
</Flex> | ||
</Modal> | ||
) | ||
} |
Oops, something went wrong.