- Notifications
You must be signed in to change notification settings - Fork928
chore: add stories toSearch
#12457
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
4 changes: 2 additions & 2 deletionssite/src/components/Filter/filter.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
105 changes: 0 additions & 105 deletionssite/src/components/Menu/Search.tsx
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
26 changes: 26 additions & 0 deletionssite/src/components/Search/Search.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,26 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { Search, SearchInput } from "./Search"; | ||
const meta: Meta<typeof SearchInput> = { | ||
title: "components/Search", | ||
component: SearchInput, | ||
decorators: [ | ||
(Story) => ( | ||
<Search> | ||
<Story /> | ||
</Search> | ||
), | ||
], | ||
}; | ||
export default meta; | ||
type Story = StoryObj<typeof SearchInput>; | ||
export const Example: Story = {}; | ||
export const WithPlaceholder: Story = { | ||
args: { | ||
label: "uwu", | ||
placeholder: "uwu", | ||
}, | ||
}; |
117 changes: 117 additions & 0 deletionssite/src/components/Search/Search.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,117 @@ | ||
import type { Interpolation, Theme } from "@emotion/react"; | ||
import SearchOutlined from "@mui/icons-material/SearchOutlined"; | ||
// eslint-disable-next-line no-restricted-imports -- use it to have the component prop | ||
import Box, { type BoxProps } from "@mui/material/Box"; | ||
import visuallyHidden from "@mui/utils/visuallyHidden"; | ||
import type { FC, HTMLAttributes, InputHTMLAttributes, Ref } from "react"; | ||
interface SearchProps extends Omit<BoxProps, "ref"> { | ||
$$ref?: Ref<unknown>; | ||
} | ||
/** | ||
* A container component meant for `SearchInput` | ||
* | ||
* ``` | ||
* <Search> | ||
* <SearchInput /> | ||
* </Search> | ||
* ``` | ||
*/ | ||
export const Search: FC<SearchProps> = ({ children, $$ref, ...boxProps }) => { | ||
return ( | ||
<Box ref={$$ref} {...boxProps} css={SearchStyles.container}> | ||
<SearchOutlined css={SearchStyles.icon} /> | ||
{children} | ||
</Box> | ||
); | ||
}; | ||
const SearchStyles = { | ||
container: (theme) => ({ | ||
display: "flex", | ||
alignItems: "center", | ||
paddingLeft: 16, | ||
height: 40, | ||
borderBottom: `1px solid ${theme.palette.divider}`, | ||
}), | ||
icon: (theme) => ({ | ||
fontSize: 14, | ||
color: theme.palette.text.secondary, | ||
}), | ||
} satisfies Record<string, Interpolation<Theme>>; | ||
type SearchInputProps = InputHTMLAttributes<HTMLInputElement> & { | ||
label?: string; | ||
$$ref?: Ref<HTMLInputElement>; | ||
}; | ||
export const SearchInput: FC<SearchInputProps> = ({ | ||
label, | ||
$$ref, | ||
...inputProps | ||
}) => { | ||
return ( | ||
<> | ||
<label css={{ ...visuallyHidden }} htmlFor={inputProps.id}> | ||
{label} | ||
</label> | ||
<input | ||
ref={$$ref} | ||
tabIndex={-1} | ||
type="text" | ||
placeholder="Search..." | ||
css={SearchInputStyles.input} | ||
{...inputProps} | ||
/> | ||
</> | ||
); | ||
}; | ||
const SearchInputStyles = { | ||
input: (theme) => ({ | ||
color: "inherit", | ||
height: "100%", | ||
border: 0, | ||
background: "none", | ||
flex: 1, | ||
marginLeft: 16, | ||
outline: 0, | ||
"&::placeholder": { | ||
color: theme.palette.text.secondary, | ||
}, | ||
}), | ||
} satisfies Record<string, Interpolation<Theme>>; | ||
export const SearchEmpty: FC<HTMLAttributes<HTMLDivElement>> = ({ | ||
children = "Not found", | ||
...props | ||
}) => { | ||
return ( | ||
<div css={SearchEmptyStyles.empty} {...props}> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
const SearchEmptyStyles = { | ||
empty: (theme) => ({ | ||
fontSize: 13, | ||
color: theme.palette.text.secondary, | ||
textAlign: "center", | ||
paddingTop: 8, | ||
paddingBottom: 8, | ||
}), | ||
} satisfies Record<string, Interpolation<Theme>>; | ||
/** | ||
* Reusable styles for consumers of the base components | ||
*/ | ||
export const searchStyles = { | ||
content: { | ||
width: 320, | ||
padding: 0, | ||
borderRadius: 4, | ||
}, | ||
} satisfies Record<string, Interpolation<Theme>>; |
2 changes: 1 addition & 1 deletionsite/src/pages/WorkspacesPage/WorkspacesButton.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
31 changes: 14 additions & 17 deletionssite/src/pages/WorkspacesPage/WorkspacesSearchBox.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
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.