-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(protocol-designer): add landing page (#15912)
closes AUTH-639
- Loading branch information
Showing
6 changed files
with
124 additions
and
21 deletions.
There are no files selected for viewing
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
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
40 changes: 38 additions & 2 deletions
40
protocol-designer/src/pages/Landing/__tests__/Landing.test.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 |
---|---|---|
@@ -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' }) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -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; | ||
` |