-
Notifications
You must be signed in to change notification settings - Fork 178
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ee5fbb0
feat(protocol-designer): add landing page
jerader 75f2b7d
navigate to overview path
jerader 4a432bc
use desktopStyle instead of as tag
jerader 8f49a76
use as tags to match correct font
jerader 2e44cca
fix styled text again
jerader 14b0f9d
use LargeButton
jerader fd3d214
fix margin and test image
jerader File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' }) | ||
}) | ||
}) | ||
jerader marked this conversation as resolved.
Show resolved
Hide resolved
|
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; | ||
` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.