-
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(opentron-ai-client): add Side Panel component #14886
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b4b124e
feat(opentrons-ai-client): add sidebar component
koji 661d1e2
rename component name
koji cac565e
add feedback form link
koji 7cbda0f
Update README.md
koji 58c1d81
add feedback form link
koji df16e18
Update App.tsx
koji 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
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
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
21 changes: 21 additions & 0 deletions
21
opentrons-ai-client/src/molecules/SidePanel/SidePanel.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,21 @@ | ||
import React from 'react' | ||
import { I18nextProvider } from 'react-i18next' | ||
import { i18n } from '../../i18n' | ||
import { SidePanel as SidePanelComponent } from './index' | ||
|
||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
const meta: Meta<typeof SidePanelComponent> = { | ||
title: 'AI/molecules/SidePanel', | ||
component: SidePanelComponent, | ||
decorators: [ | ||
Story => ( | ||
<I18nextProvider i18n={i18n}> | ||
<Story /> | ||
</I18nextProvider> | ||
), | ||
], | ||
} | ||
export default meta | ||
type Story = StoryObj<typeof SidePanelComponent> | ||
export const SidePanel: Story = {} |
41 changes: 41 additions & 0 deletions
41
opentrons-ai-client/src/molecules/SidePanel/__tests__/SidePanel.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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react' | ||
import { screen } from '@testing-library/react' | ||
import { describe, it, expect } from 'vitest' | ||
|
||
import { renderWithProviders } from '../../../__testing-utils__' | ||
import { i18n } from '../../../i18n' | ||
|
||
import { SidePanel } from '../index' | ||
|
||
const LOGO_FILE_NAME = | ||
'/opentrons-ai-client/src/assets/images/opentrons_logo.svg' | ||
|
||
const render = (): ReturnType<typeof renderWithProviders> => { | ||
return renderWithProviders(<SidePanel />, { | ||
i18nInstance: i18n, | ||
}) | ||
} | ||
|
||
describe('SidePanel', () => { | ||
it('should render logo and text', () => { | ||
render() | ||
const image = screen.getByRole('img') | ||
expect(image.getAttribute('src')).toEqual(LOGO_FILE_NAME) | ||
screen.getByText( | ||
'Use natural language to generate protocols with OpentronsAI powered by OpenAI' | ||
) | ||
screen.getByText( | ||
'Write a prompt in natural language to generate a Reagent Transfer or a PCR protocol for the OT-2 or Opentrons Flex using the Opentrons Python Protocol API.' | ||
) | ||
screen.getByText('Stuck? Try these example prompts to get started.') | ||
}) | ||
|
||
it('should render buttons', () => { | ||
render() | ||
screen.getByRole('button', { name: 'PCR' }) | ||
screen.getByRole('button', { name: 'PCR (Flex)' }) | ||
screen.getByRole('button', { name: 'Reagent Transfer' }) | ||
screen.getByRole('button', { name: 'Reagent Transfer (Flex)' }) | ||
}) | ||
it.todo('should call a mock function when clicking a button') | ||
}) |
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,103 @@ | ||
import React from 'react' | ||
import styled, { css } from 'styled-components' | ||
import { useTranslation } from 'react-i18next' | ||
import { | ||
COLORS, | ||
DIRECTION_COLUMN, | ||
Flex, | ||
Link, | ||
PrimaryButton, | ||
SPACING, | ||
StyledText, | ||
TYPOGRAPHY, | ||
WRAP, | ||
} from '@opentrons/components' | ||
import LOGO_PATH from '../../assets/images/opentrons_logo.svg' | ||
|
||
const IMAGE_ALT = 'Opentrons logo' | ||
const FEEDBACK_FORM_LINK = '' | ||
koji marked this conversation as resolved.
Show resolved
Hide resolved
|
||
export function SidePanel(): JSX.Element { | ||
const { t } = useTranslation('protocol_generator') | ||
return ( | ||
<Flex | ||
padding={SPACING.spacing40} | ||
gridGap={SPACING.spacing80} | ||
flexDirection={DIRECTION_COLUMN} | ||
backgroundColor={COLORS.black90} | ||
width="24.375rem" | ||
height="64rem" | ||
> | ||
{/* logo */} | ||
<Flex> | ||
<img src={LOGO_PATH} width="194.192" height="48.133" alt={IMAGE_ALT} /> | ||
</Flex> | ||
|
||
{/* body text */} | ||
<Flex gridGap={SPACING.spacing24} flexDirection={DIRECTION_COLUMN}> | ||
<StyledText css={HEADER_TEXT_STYLE}> | ||
{t('side_panel_header')} | ||
</StyledText> | ||
<StyledText css={BODY_TEXT_STYLE}>{t('side_panel_body')}</StyledText> | ||
</Flex> | ||
|
||
{/* buttons */} | ||
<Flex gridGap={SPACING.spacing24} flexDirection={DIRECTION_COLUMN}> | ||
<StyledText css={BUTTON_GUIDE_TEXT_STYLE}> | ||
{t('try_example_prompts')} | ||
</StyledText> | ||
|
||
<Flex gridGap={SPACING.spacing16} flexWrap={WRAP}> | ||
{/* ToDo(kk:04/11/2024) add a button component */} | ||
<PromptButton>{t('reagent_transfer')}</PromptButton> | ||
<PromptButton>{t('reagent_transfer_flex')}</PromptButton> | ||
<PromptButton>{t('prc')}</PromptButton> | ||
<PromptButton>{t('prc_flex')}</PromptButton> | ||
</Flex> | ||
</Flex> | ||
<Flex flexDirection={DIRECTION_COLUMN}> | ||
<StyledText | ||
fontSize={TYPOGRAPHY.fontSize20} | ||
lineHeight={TYPOGRAPHY.lineHeight24} | ||
color={COLORS.white} | ||
> | ||
{t('got_feedback')} | ||
</StyledText> | ||
<FeedbackLink external href={FEEDBACK_FORM_LINK}> | ||
{t('share_your_thoughts')} | ||
</FeedbackLink> | ||
</Flex> | ||
</Flex> | ||
) | ||
} | ||
|
||
const HEADER_TEXT_STYLE = css` | ||
font-size: ${TYPOGRAPHY.fontSize32}; | ||
line-height: ${TYPOGRAPHY.lineHeight42}; | ||
font-weight: ${TYPOGRAPHY.fontWeightBold}; | ||
color: ${COLORS.white}; | ||
` | ||
const BODY_TEXT_STYLE = css` | ||
font-size: ${TYPOGRAPHY.fontSize20}; | ||
line-height: ${TYPOGRAPHY.lineHeight24}; | ||
font-weight: ${TYPOGRAPHY.fontWeightRegular}; | ||
color: ${COLORS.white}; | ||
` | ||
const BUTTON_GUIDE_TEXT_STYLE = css` | ||
font-size: ${TYPOGRAPHY.fontSize20}; | ||
line-height: ${TYPOGRAPHY.lineHeight24}; | ||
font-weight: ${TYPOGRAPHY.fontWeightSemiBold}; | ||
color: ${COLORS.white}; | ||
` | ||
|
||
const PromptButton = styled(PrimaryButton)` | ||
border-radius: 2rem; | ||
white-space: nowrap; | ||
` | ||
|
||
const FeedbackLink = styled(Link)` | ||
font-size: ${TYPOGRAPHY.fontSize20}; | ||
line-height: ${TYPOGRAPHY.lineHeight24}; | ||
font-weight: ${TYPOGRAPHY.fontWeightBold}; | ||
color: ${COLORS.white}; | ||
text-decoration: ${TYPOGRAPHY.textDecorationUnderline}; | ||
` |
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 @@ | ||
export * from './SidePanel' |
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.
oh good idea