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(opentrons-ai-client): Header component with title and log out button #16542

Merged
merged 6 commits into from
Oct 22, 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"ai": "AI",
"api": "API: An API level is 2.15",
"application": "Application: Your protocol's name, describing what it does.",
"commands": "Commands: List the protocol's steps, specifying quantities in microliters (uL) and giving exact source and destination locations.",
Expand All @@ -15,6 +16,7 @@
"make_sure_your_prompt": "Write a prompt in a natural language for OpentronsAI to generate a protocol using the Opentrons Python Protocol API v2. The better the prompt, the better the quality of the protocol produced by OpentronsAI.",
"modules_and_adapters": "Modules and adapters: Specify the modules and labware adapters required by your protocol.",
"notes": "A few important things to note:",
"opentrons": "Opentrons",
"opentronsai": "OpentronsAI",
"ot2_pipettes": "OT-2 pipettes: Include volume, number of channels, and generation.",
"pcr_flex": "PCR (Flex)",
Expand Down
20 changes: 20 additions & 0 deletions opentrons-ai-client/src/molecules/Header/Header.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Meta, StoryObj } from '@storybook/react'
import { Header as HeaderComponent } from '.'
import { COLORS, Flex, SPACING } from '@opentrons/components'

const meta: Meta<typeof HeaderComponent> = {
title: 'AI/Molecules/Header',
component: HeaderComponent,
decorators: [
Story => (
<Flex backgroundColor={COLORS.grey10} padding={SPACING.spacing40}>
<Story />
</Flex>
),
],
}
export default meta

type Story = StoryObj<typeof HeaderComponent>

export const ChatHeaderExample: Story = {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { renderWithProviders } from '../../../__testing-utils__'
import { i18n } from '../../../i18n'
import { Header } from '../index'
import { describe, it } from 'vitest'
import { screen } from '@testing-library/react'

const render = (): ReturnType<typeof renderWithProviders> => {
return renderWithProviders(<Header />, {
i18nInstance: i18n,
})
}

describe('Header', () => {
it('should render Header component', () => {
render()
screen.getByText('Opentrons')
})

it('should render log out button', () => {
render()
screen.getByText('Logout')
})
})
63 changes: 63 additions & 0 deletions opentrons-ai-client/src/molecules/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'

import {
Flex,
StyledText,
Link as LinkButton,
POSITION_ABSOLUTE,
TYPOGRAPHY,
COLORS,
POSITION_RELATIVE,
ALIGN_CENTER,
JUSTIFY_SPACE_BETWEEN,
} from '@opentrons/components'
import { useAuth0 } from '@auth0/auth0-react'

const HeaderBar = styled(Flex)`
position: ${POSITION_RELATIVE};
background-color: ${COLORS.white};
width: 100%;
align-items: ${ALIGN_CENTER};
height: 60px;
`

const HeaderBarContent = styled(Flex)`
position: ${POSITION_ABSOLUTE};
padding: 18px 32px;
justify-content: ${JUSTIFY_SPACE_BETWEEN};
width: 100%;
`

const HeaderGradientTitle = styled(StyledText)`
background: linear-gradient(90deg, #562566 0%, #893ba4 47.5%, #c189d4 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-size: 16px;
`

const HeaderTitle = styled(StyledText)`
font-size: 16px;
`

const LogoutButton = styled(LinkButton)`
color: ${COLORS.grey50};
font-size: ${TYPOGRAPHY.fontSizeH3};
`

export function Header(): JSX.Element {
const { t } = useTranslation('protocol_generator')
const { logout } = useAuth0()

return (
<HeaderBar>
<HeaderBarContent>
<Flex>
<HeaderTitle>{t('opentrons')}</HeaderTitle>
<HeaderGradientTitle>{t('ai')}</HeaderGradientTitle>
</Flex>
<LogoutButton onClick={() => logout()}>{t('logout')}</LogoutButton>
</HeaderBarContent>
</HeaderBar>
)
}
Loading