-
Notifications
You must be signed in to change notification settings - Fork 179
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): add jotai and custom hook for call api #15029
Merged
+378
−231
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f1436ae
feat(opentrons-ai-client): add api call function
koji 70641ab
feat(opentrons-ai-client): add jotai to make state management easy ad…
koji 45513cd
export send button as an atom component
koji 2ebabb1
Update yarn.lock
koji eefcf91
Merge branch 'edge' into feat_add-custom-hook-for-callAPI
koji 5f77e33
add favicon to the page
koji cbb8bef
add styles to markdown component
koji bf17386
fix ChatDisplay test
koji bbc967d
fix test cases
koji 6a98036
clean up code
koji 17225bd
fix linting error
koji a07ae48
fix lint error
koji 79a36a2
address feedback
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
Binary file added
BIN
+12.2 KB
opentrons-ai-client/src/assets/images/favicon/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+40.5 KB
opentrons-ai-client/src/assets/images/favicon/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
opentrons-ai-client/src/assets/images/favicon/site.webmanifest
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,19 @@ | ||
{ | ||
"name": "opentrons_favicon", | ||
"short_name": "favicon", | ||
"icons": [ | ||
{ | ||
"src": "/android-chrome-192x192.png", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
}, | ||
{ | ||
"src": "/android-chrome-512x512.png", | ||
"sizes": "512x512", | ||
"type": "image/png" | ||
} | ||
], | ||
"theme_color": "#ffffff", | ||
"background_color": "#ffffff", | ||
"display": "standalone" | ||
} |
53 changes: 53 additions & 0 deletions
53
opentrons-ai-client/src/atoms/SendButton/__tests__/SendButton.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,53 @@ | ||
import React from 'react' | ||
import { describe, it, vi, beforeEach, expect } from 'vitest' | ||
import { fireEvent, screen } from '@testing-library/react' | ||
import { renderWithProviders } from '../../../__testing-utils__' | ||
|
||
import { SendButton } from '../index' | ||
|
||
const mockHandleClick = vi.fn() | ||
const render = (props: React.ComponentProps<typeof SendButton>) => { | ||
return renderWithProviders(<SendButton {...props} />) | ||
} | ||
|
||
describe('SendButton', () => { | ||
let props: React.ComponentProps<typeof SendButton> | ||
|
||
beforeEach(() => { | ||
props = { | ||
handleClick: mockHandleClick, | ||
disabled: true, | ||
isLoading: false, | ||
} | ||
}) | ||
it('should render button with send icon and its initially disabled', () => { | ||
render(props) | ||
const button = screen.getByRole('button') | ||
expect(button).toBeDisabled() | ||
screen.getByTestId('SendButton_icon_send') | ||
}) | ||
|
||
it('should render button and its not disabled when disabled false', () => { | ||
props = { ...props, disabled: false } | ||
render(props) | ||
const button = screen.getByRole('button') | ||
expect(button).not.toBeDisabled() | ||
screen.getByTestId('SendButton_icon_send') | ||
}) | ||
|
||
it('should render button with spinner icon when isLoading', () => { | ||
props = { ...props, isLoading: true } | ||
render(props) | ||
const button = screen.getByRole('button') | ||
expect(button).toBeDisabled() | ||
screen.getByTestId('SendButton_icon_ot-spinner') | ||
}) | ||
|
||
it('should call a mock function when clicking the button', () => { | ||
props = { ...props, disabled: false } | ||
render(props) | ||
const button = screen.getByRole('button') | ||
fireEvent.click(button) | ||
expect(mockHandleClick).toHaveBeenCalled() | ||
}) | ||
}) |
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,74 @@ | ||
import React from 'react' | ||
import { css } from 'styled-components' | ||
|
||
import { | ||
ALIGN_CENTER, | ||
BORDERS, | ||
Btn, | ||
COLORS, | ||
DISPLAY_FLEX, | ||
Icon, | ||
JUSTIFY_CENTER, | ||
} from '@opentrons/components' | ||
|
||
interface SendButtonProps { | ||
handleClick: () => void | ||
disabled?: boolean | ||
isLoading?: boolean | ||
} | ||
|
||
export function SendButton({ | ||
handleClick, | ||
disabled = false, | ||
isLoading = false, | ||
}: SendButtonProps): JSX.Element { | ||
const playButtonStyle = css` | ||
-webkit-tap-highlight-color: transparent; | ||
&:focus { | ||
background-color: ${COLORS.blue60}; | ||
color: ${COLORS.white}; | ||
} | ||
|
||
&:hover { | ||
background-color: ${COLORS.blue50}; | ||
color: ${COLORS.white}; | ||
} | ||
|
||
&:focus-visible { | ||
background-color: ${COLORS.blue50}; | ||
} | ||
|
||
&:active { | ||
background-color: ${COLORS.blue60}; | ||
color: ${COLORS.white}; | ||
} | ||
|
||
&:disabled { | ||
background-color: ${COLORS.grey35}; | ||
color: ${COLORS.grey50}; | ||
} | ||
` | ||
return ( | ||
<Btn | ||
alignItems={ALIGN_CENTER} | ||
backgroundColor={disabled ? COLORS.grey35 : COLORS.blue50} | ||
borderRadius={BORDERS.borderRadiusFull} | ||
display={DISPLAY_FLEX} | ||
justifyContent={JUSTIFY_CENTER} | ||
width="4.25rem" | ||
height="3.75rem" | ||
disabled={disabled || isLoading} | ||
onClick={handleClick} | ||
aria-label="play" | ||
css={playButtonStyle} | ||
> | ||
<Icon | ||
color={disabled ? COLORS.grey50 : COLORS.white} | ||
name={isLoading ? 'ot-spinner' : 'send'} | ||
spin={isLoading} | ||
size="2rem" | ||
data-testid={`SendButton_icon_${isLoading ? 'ot-spinner' : 'send'}`} | ||
/> | ||
</Btn> | ||
) | ||
} |
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
Oops, something went wrong.
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.
forgot to delete this?
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.
I will use this soon for adding style to markdown part.