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

feat(protocol-designer): add landing page #15912

Merged
merged 7 commits into from
Aug 8, 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
4 changes: 2 additions & 2 deletions components/src/atoms/buttons/LargeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type LargeButtonTypes =
| 'alertStroke'
| 'alertAlt'
interface LargeButtonProps extends StyleProps {
onClick: () => void
onClick?: () => void
buttonType?: LargeButtonTypes
buttonText: React.ReactNode
iconName?: IconName
Expand Down Expand Up @@ -203,7 +203,7 @@ export function LargeButton(props: LargeButtonProps): JSX.Element {
<LegacyStyledText
css={css`
font-size: ${fontSizeBodyLargeSemiBold};
padding-right: ${SPACING.spacing8};
padding-right: ${iconName != null ? SPACING.spacing8 : '0'};
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
${TYPOGRAPHY.level3HeaderSemiBold}
}
Expand Down
2 changes: 1 addition & 1 deletion components/src/helix-design-system/product/typography.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const fontFamilyHeadingSmall = fontFamily
export const fontSizeHeadingSmallRegular = fontSizeHeadingSmall
export const lineHeightHeadingSmallRegular = lineHeightHeadingSmall
export const fontFamilyHeadingSmallRegular = fontFamilyHeadingSmall
export const fontWeightHeadingSmallRegular = '600'
export const fontWeightHeadingSmallRegular = '400'
export const fontStyleHeadingSmallRegular = `${fontWeightHeadingSmallRegular} ${fontSizeHeadingSmallRegular}/${lineHeightHeadingSmallRegular} ${fontFamilyHeadingSmallRegular}`

// Heading-Small-Bold
Expand Down
Binary file added protocol-designer/src/images/welcome_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions protocol-designer/src/localization/en/shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
"amount": "Amount:",
"cancel": "Cancel",
"confirm_reorder": "Are you sure you want to reorder these steps, it may cause errors?",
"create_new": "Create new",
"create_opentrons_protocol": "Create Opentrons protocol",
"create_new_protocol": "Create new protocol",
"create_a_protocol": "Create a protocol",
"confirm_import": "Are you sure you want to upload this protocol?",
"done": "Done",
"edit": "edit",
"exit": "exit",
"go_back": "go back",
"import_existing": "Import existing protocol",
"import": "Import",
"next": "next",
"no-code-solution": "A no-code solution to create protocols that x, y and z meaning for your lab and workflow.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"no-code-solution": "A no-code solution to create protocols that x, y and z meaning for your lab and workflow.",
"no-code-solution": "A no-code solution to create protocols that x, y and z tailored to your lab and workflow.",

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks for flagging this Elyor! The copy isn't finalized yet - so we will have to go back and fix it after Ed has reviewed everything.

"remove": "remove",
"step": "Step {{current}} / {{max}}"
"step": "Step {{current}} / {{max}}",
"welcome": "Welcome to Protocol Designer"
}
40 changes: 38 additions & 2 deletions protocol-designer/src/pages/Landing/__tests__/Landing.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
import { it } from 'vitest'
import * as React from 'react'

it.todo('write test for Landing page')
import { describe, it, vi, beforeEach } from 'vitest'
import { MemoryRouter } from 'react-router-dom'
import { screen } from '@testing-library/react'
import { i18n } from '../../../localization'
import { renderWithProviders } from '../../../__testing-utils__'
import { loadProtocolFile } from '../../../load-file/actions'
import { Landing } from '../index'

vi.mock('../../../load-file/actions')

const render = () => {
return renderWithProviders(
<MemoryRouter>
<Landing />
</MemoryRouter>,
{
i18nInstance: i18n,
}
)[0]
}

describe('Landing', () => {
beforeEach(() => {
vi.mocked(loadProtocolFile).mockReturnValue(vi.fn())
})
it('renders the landing page image and text', () => {
render()
screen.getByLabelText('welcome image')
screen.getByText('Welcome to Protocol Designer')
screen.getByText(
'A no-code solution to create protocols that x, y and z meaning for your lab and workflow.'
)
screen.getByRole('button', { name: 'Create a protocol' })
screen.getByText('Import existing protocol')
screen.getByRole('img', { name: 'welcome image' })
})
})
jerader marked this conversation as resolved.
Show resolved Hide resolved
89 changes: 76 additions & 13 deletions protocol-designer/src/pages/Landing/index.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,90 @@
import * as React from 'react'
import { NavLink } from 'react-router-dom'
import { NavLink, useNavigate } from 'react-router-dom'
import styled from 'styled-components'
import { useDispatch } from 'react-redux'
import { useTranslation } from 'react-i18next'
import {
ALIGN_CENTER,
COLORS,
DIRECTION_COLUMN,
Flex,
LargeButton,
SPACING,
DIRECTION_COLUMN,
ALIGN_CENTER,
StyledText,
TYPOGRAPHY,
} from '@opentrons/components'
import { useTranslation } from 'react-i18next'
import { actions as loadFileActions } from '../../load-file'
import welcomeImage from '../../images/welcome_page.png'
import type { ThunkDispatch } from '../../types'

export function Landing(): JSX.Element {
const { t } = useTranslation('shared')
const dispatch: ThunkDispatch<any> = useDispatch()
const navigate = useNavigate()
const loadFile = (
fileChangeEvent: React.ChangeEvent<HTMLInputElement>
): void => {
if (window.confirm(t('confirm_import') as string)) {
dispatch(loadFileActions.loadProtocolFile(fileChangeEvent))
navigate('/overview')
}
}

return (
<Flex flexDirection={DIRECTION_COLUMN} margin={SPACING.spacing24}>
{t('create_opentrons_protocol')}
<Flex
alignItems={ALIGN_CENTER}
marginTop={SPACING.spacing24}
gridGap={SPACING.spacing16}
<Flex
backgroundColor={COLORS.grey20}
flexDirection={DIRECTION_COLUMN}
alignItems={ALIGN_CENTER}
paddingTop="14.875rem"
height="100vh"
width="100%"
>
<img
src={welcomeImage}
height="132px"
width="548px"
aria-label="welcome image"
/>
<StyledText desktopStyle="headingLargeBold" marginY={SPACING.spacing16}>
{t('welcome')}
</StyledText>
<StyledText
desktopStyle="headingSmallRegular"
color={COLORS.grey60}
maxWidth="34.25rem"
textAlign={TYPOGRAPHY.textAlignCenter}
>
<NavLink to={'/createNew'}>{t('create_new')}</NavLink>
{t('import')}
</Flex>
{t('no-code-solution')}
</StyledText>
<LargeButton
marginY={SPACING.spacing32}
buttonText={
<StyledNavLink to={'/createNew'}>
<StyledText desktopStyle="bodyLargeRegular">
{t('create_a_protocol')}
</StyledText>
</StyledNavLink>
}
/>

<StyledLabel>
<StyledText desktopStyle="bodyLargeRegular" color={COLORS.grey60}>
{t('import_existing')}
</StyledText>
<input type="file" onChange={loadFile}></input>
</StyledLabel>
</Flex>
)
}

const StyledLabel = styled.label`
display: inline-block;
cursor: pointer;
input[type='file'] {
display: none;
}
`
const StyledNavLink = styled(NavLink)<React.ComponentProps<typeof NavLink>>`
color: ${COLORS.white};
text-decoration: none;
`
Loading