-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add input component to research panel (#784) #785
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d061704
feat: add input component to research panel (#784)
frano-m 7c8c8c3
Update src/views/ExploreView/research/panel/components/Input/input.tsx
frano-m d092809
Update src/views/ExploreView/research/panel/components/Input/constant…
frano-m 34dd390
Update src/views/ExploreView/research/panel/components/Input/input.tsx
frano-m 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
21 changes: 21 additions & 0 deletions
21
src/components/common/CustomIcon/components/UpArrowIcon/upArrowIcon.tsx
This file contains hidden or 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 { SvgIcon, SvgIconProps } from "@mui/material"; | ||
| import { JSX } from "react"; | ||
|
|
||
| /** | ||
| * Custom up arrow icon. | ||
| */ | ||
|
|
||
| export const UpArrowIcon = ({ | ||
| fontSize = "xsmall", | ||
| viewBox = "0 0 18 18", | ||
| ...props /* SvgIconProps */ | ||
| }: SvgIconProps): JSX.Element => { | ||
| return ( | ||
| <SvgIcon fontSize={fontSize} viewBox={viewBox} {...props}> | ||
| <path | ||
| d="M8.24985 6.60005L6.07485 8.77505C5.93735 8.91255 5.76235 8.9813 5.54985 8.9813C5.33735 8.9813 5.16235 8.91255 5.02485 8.77505C4.88735 8.63755 4.8186 8.46255 4.8186 8.25005C4.8186 8.03755 4.88735 7.86255 5.02485 7.72505L8.47485 4.27505C8.62485 4.12505 8.79985 4.05005 8.99985 4.05005C9.19985 4.05005 9.37485 4.12505 9.52485 4.27505L12.9749 7.72505C13.1124 7.86255 13.1811 8.03755 13.1811 8.25005C13.1811 8.46255 13.1124 8.63755 12.9749 8.77505C12.8374 8.91255 12.6624 8.9813 12.4499 8.9813C12.2374 8.9813 12.0624 8.91255 11.9249 8.77505L9.74985 6.60005V12.75C9.74985 12.9625 9.67798 13.1407 9.53423 13.2844C9.39048 13.4282 9.21235 13.5 8.99985 13.5C8.78735 13.5 8.60923 13.4282 8.46548 13.2844C8.32173 13.1407 8.24985 12.9625 8.24985 12.75V6.60005Z" | ||
| fill="currentColor" | ||
| /> | ||
| </SvgIcon> | ||
| ); | ||
| }; |
This file contains hidden or 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,38 @@ | ||
| import { InputBaseProps } from "@mui/material"; | ||
|
|
||
| type InputBasePropsOptions = { | ||
| COLOR: typeof COLOR; | ||
| MARGIN: typeof MARGIN; | ||
| SIZE: typeof SIZE; | ||
| TYPE: typeof TYPE; | ||
| }; | ||
|
|
||
| const COLOR: Record<string, InputBaseProps["color"]> = { | ||
| ERROR: "error", | ||
| INFO: "info", | ||
| PRIMARY: "primary", | ||
| SECONDARY: "secondary", | ||
| SUCCESS: "success", | ||
| WARNING: "warning", | ||
| }; | ||
|
|
||
| const MARGIN: Record<string, InputBaseProps["margin"]> = { | ||
| DENSE: "dense", | ||
| NONE: "none", | ||
| }; | ||
|
|
||
| const SIZE: Record<string, InputBaseProps["size"]> = { | ||
| MEDIUM: "medium", | ||
| SMALL: "small", | ||
| }; | ||
|
|
||
| const TYPE: Record<string, InputBaseProps["type"]> = { | ||
| TEXT: "text", | ||
| }; | ||
|
|
||
| export const INPUT_BASE_PROPS: InputBasePropsOptions = { | ||
| COLOR, | ||
| MARGIN, | ||
| SIZE, | ||
| TYPE, | ||
| }; |
This file contains hidden or 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,33 @@ | ||
| import { StackProps } from "@mui/material"; | ||
|
|
||
| type StackPropsOptions = { | ||
| ALIGN_ITEMS: typeof ALIGN_ITEMS; | ||
| DIRECTION: typeof DIRECTION; | ||
| FLEX_WRAP: typeof FLEX_WRAP; | ||
| }; | ||
|
|
||
| const ALIGN_ITEMS: Record<string, StackProps["alignItems"]> = { | ||
| BASELINE: "baseline", | ||
| CENTER: "center", | ||
| FLEX_END: "flex-end", | ||
| FLEX_START: "flex-start", | ||
| STRETCH: "stretch", | ||
| } as const; | ||
|
|
||
| const DIRECTION: Record<string, StackProps["direction"]> = { | ||
| COLUMN: "column", | ||
| COLUMN_REVERSE: "column-reverse", | ||
| ROW: "row", | ||
| ROW_REVERSE: "row-reverse", | ||
| } as const; | ||
|
|
||
| const FLEX_WRAP: Record<string, StackProps["flexWrap"]> = { | ||
| WRAP: "wrap", | ||
| WRAP_REVERSE: "wrap-reverse", | ||
| } as const; | ||
|
|
||
| export const STACK_PROPS: StackPropsOptions = { | ||
| ALIGN_ITEMS, | ||
| DIRECTION, | ||
| FLEX_WRAP, | ||
| }; |
15 changes: 15 additions & 0 deletions
15
src/views/ExploreView/research/panel/components/Input/constants.ts
This file contains hidden or 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,15 @@ | ||
| import { InputBaseProps } from "@mui/material"; | ||
| import { INPUT_BASE_PROPS as MUI_INPUT_BASE_PROPS } from "../../../../../../styles/common/mui/inputBase"; | ||
|
|
||
| export const INPUT_BASE_PROPS: InputBaseProps = { | ||
| autoFocus: true, | ||
| color: MUI_INPUT_BASE_PROPS.COLOR.PRIMARY, | ||
| fullWidth: true, | ||
| inputProps: { autoComplete: "off", spellCheck: false }, | ||
| margin: MUI_INPUT_BASE_PROPS.MARGIN.DENSE, | ||
| maxRows: 4, | ||
| minRows: 1, | ||
| multiline: true, | ||
| name: "ai-prompt", | ||
| placeholder: "Ask anything", | ||
| }; |
17 changes: 17 additions & 0 deletions
17
src/views/ExploreView/research/panel/components/Input/input.styles.ts
This file contains hidden or 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,17 @@ | ||
| import styled from "@emotion/styled"; | ||
| import { RoundedPaper } from "../../../../../../components/common/Paper/components/RoundedPaper/roundedPaper"; | ||
|
|
||
| export const StyledPaper = styled(RoundedPaper)` | ||
| display: flex; | ||
| flex-direction: column; | ||
| margin: 16px; | ||
|
|
||
| .MuiInputBase-root { | ||
| padding: 16px; | ||
| } | ||
|
|
||
| .MuiStack-root { | ||
| justify-content: flex-end; | ||
| padding: 8px; | ||
| } | ||
| `; |
30 changes: 30 additions & 0 deletions
30
src/views/ExploreView/research/panel/components/Input/input.tsx
This file contains hidden or 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,30 @@ | ||
| import { IconButton, InputBase, InputBaseProps, Stack } from "@mui/material"; | ||
| import { JSX } from "react"; | ||
| import { INPUT_BASE_PROPS } from "./constants"; | ||
| import { StyledPaper } from "./input.styles"; | ||
| import { UpArrowIcon } from "../../../../../../components/common/CustomIcon/components/UpArrowIcon/upArrowIcon"; | ||
| import { ICON_BUTTON_PROPS } from "../../../../../../styles/common/mui/iconButton"; | ||
| import { SVG_ICON_PROPS } from "../../../../../../styles/common/mui/svgIcon"; | ||
| import { STACK_PROPS } from "../../../../../../styles/common/mui/stack"; | ||
|
|
||
| /** | ||
| * Renders an input component for the research panel. | ||
| * @param props - Input component props. | ||
| * @returns Research panel input component. | ||
| */ | ||
| export const Input = (props: InputBaseProps): JSX.Element => { | ||
| return ( | ||
| <StyledPaper elevation={0}> | ||
| <InputBase {...INPUT_BASE_PROPS} {...props} /> | ||
| <Stack direction={STACK_PROPS.DIRECTION.ROW} gap={2}> | ||
| <IconButton | ||
| color={ICON_BUTTON_PROPS.COLOR.SECONDARY} | ||
| size={ICON_BUTTON_PROPS.SIZE.XSMALL} | ||
| type="submit" | ||
| > | ||
| <UpArrowIcon fontSize={SVG_ICON_PROPS.FONT_SIZE.SMALL} /> | ||
| </IconButton> | ||
| </Stack> | ||
| </StyledPaper> | ||
| ); | ||
| }; | ||
21 changes: 21 additions & 0 deletions
21
src/views/ExploreView/research/panel/components/Input/stories/input.stories.tsx
This file contains hidden or 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 { type Meta, type StoryObj } from "@storybook/nextjs-vite"; | ||
| import { Input } from "../input"; | ||
| import { Box } from "@mui/material"; | ||
| import { JSX } from "react"; | ||
|
|
||
| const meta: Meta<typeof Input> = { | ||
| component: Input, | ||
| decorators: [ | ||
| (Story): JSX.Element => ( | ||
| <Box sx={{ width: "412px" }}> | ||
| <Story /> | ||
| </Box> | ||
| ), | ||
| ], | ||
| }; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const Default: Story = {}; |
This file contains hidden or 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,10 +1,15 @@ | ||
| import { JSX } from "react"; | ||
| import { TEST_IDS } from "../../../../tests/testIds"; | ||
| import { Input } from "./components/Input/input"; | ||
|
|
||
| /** | ||
| * Renders the research panel. | ||
| * @returns The research panel container element. | ||
| */ | ||
| export const Panel = (): JSX.Element => { | ||
| return <div data-testid={TEST_IDS.RESEARCH_PANEL}>research panel</div>; | ||
| return ( | ||
| <div data-testid={TEST_IDS.RESEARCH_PANEL}> | ||
| <Input /> | ||
| </div> | ||
| ); | ||
| }; |
32 changes: 32 additions & 0 deletions
32
src/views/ExploreView/research/panel/stories/panel.stories.tsx
This file contains hidden or 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,32 @@ | ||
| import { type Meta, type StoryObj } from "@storybook/nextjs-vite"; | ||
| import { Panel } from "../panel"; | ||
| import { Box } from "@mui/material"; | ||
| import { PALETTE } from "../../../../../styles/common/constants/palette"; | ||
| import { JSX } from "react"; | ||
|
|
||
| const meta: Meta<typeof Panel> = { | ||
| component: Panel, | ||
| decorators: [ | ||
| (Story): JSX.Element => ( | ||
| <Box | ||
| sx={{ | ||
| backgroundColor: PALETTE.BACKGROUND_DEFAULT, | ||
| height: "100vh", | ||
| minHeight: 0, | ||
| width: "412px", | ||
| }} | ||
| > | ||
| <Story /> | ||
| </Box> | ||
| ), | ||
| ], | ||
| parameters: { layout: "padding" }, | ||
| }; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const Default: Story = { | ||
| args: {}, | ||
| }; |
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.
Uh oh!
There was an error while loading. Please reload this page.