-
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(opentrons-ai-client): add jotai and custom hook for call api (#1…
…5029) * feat(opentrons-ai-client): add jotai and custom hook for call api
- Loading branch information
Showing
26 changed files
with
378 additions
and
231 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
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.