-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Расул <[email protected]>
- Loading branch information
Showing
4 changed files
with
61 additions
and
8 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
52 changes: 52 additions & 0 deletions
52
src/components/SourcesTableModal/SourcesView/Topics/Search/index.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,52 @@ | ||
import { Divider } from '@mui/material' | ||
import IconButton from '@mui/material/IconButton' | ||
import InputBase from '@mui/material/InputBase' | ||
import Paper from '@mui/material/Paper' | ||
import { useState } from 'react' | ||
import styled from 'styled-components' | ||
import ClearIcon from '~/components/Icons/ClearIcon' | ||
import SearchIcon from '~/components/Icons/SearchIcon' | ||
import { useTopicsStore } from '~/stores/useTopicsStore' | ||
|
||
export const Search = () => { | ||
const [filters, setFilters] = useTopicsStore((s) => [s.filters, s.setFilters]) | ||
const [inputValue, setInputValue] = useState('') | ||
|
||
const handleSearch = () => setFilters({ search: inputValue }) | ||
|
||
const resetSearch = () => { | ||
setInputValue('') | ||
|
||
if (filters.search) { | ||
setFilters({ search: '' }) | ||
} | ||
} | ||
|
||
return ( | ||
<Paper component="form" sx={{ p: '2px 4px', display: 'flex', alignItems: 'center', width: 300 }}> | ||
<InputBase | ||
inputProps={{ 'aria-label': 'search topic' }} | ||
onChange={(e) => setInputValue(e.target.value)} | ||
placeholder="Search" | ||
size="small" | ||
sx={{ ml: 1, flex: 1 }} | ||
value={inputValue} | ||
/> | ||
{inputValue && ( | ||
<> | ||
<StyledButton aria-label="search" onClick={resetSearch} type="button"> | ||
<ClearIcon /> | ||
</StyledButton> | ||
<Divider orientation="vertical" sx={{ height: 28, m: 0.5 }} /> | ||
</> | ||
)} | ||
<StyledButton aria-label="search" onClick={handleSearch} type="button"> | ||
<SearchIcon /> | ||
</StyledButton> | ||
</Paper> | ||
) | ||
} | ||
|
||
const StyledButton = styled(IconButton)` | ||
font-size: 24px; | ||
` |
File renamed without changes.
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