From da97e5058000923a0d15e973eb8c696d32345a8a Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Fri, 9 Jul 2021 12:17:38 +0200 Subject: [PATCH] move default styles into components instead of searchpage Signed-off-by: Emma Indal --- .../app/src/components/search/SearchPage.tsx | 9 +-- .../src/components/SearchBar/SearchBar.tsx | 64 ++++++++++++------- .../components/SearchFilter/SearchFilter.tsx | 14 ++-- 3 files changed, 51 insertions(+), 36 deletions(-) diff --git a/packages/app/src/components/search/SearchPage.tsx b/packages/app/src/components/search/SearchPage.tsx index 6fe02de837..2818351f41 100644 --- a/packages/app/src/components/search/SearchPage.tsx +++ b/packages/app/src/components/search/SearchPage.tsx @@ -30,9 +30,6 @@ import { DocsResultListItem } from '@backstage/plugin-techdocs'; import { SearchResultSet } from '@backstage/search-common'; const useStyles = makeStyles((theme: Theme) => ({ - bar: { - padding: theme.spacing(1, 0), - }, filters: { padding: theme.spacing(2), }, @@ -100,9 +97,7 @@ const SearchPage = () => { - - - + @@ -112,12 +107,10 @@ const SearchPage = () => { defaultValue="software-catalog" /> diff --git a/plugins/search/src/components/SearchBar/SearchBar.tsx b/plugins/search/src/components/SearchBar/SearchBar.tsx index a1db818488..e011dcbfec 100644 --- a/plugins/search/src/components/SearchBar/SearchBar.tsx +++ b/plugins/search/src/components/SearchBar/SearchBar.tsx @@ -16,7 +16,14 @@ import React, { ChangeEvent, useState } from 'react'; import { useDebounce } from 'react-use'; -import { InputBase, InputAdornment, IconButton } from '@material-ui/core'; +import { + Paper, + InputBase, + InputAdornment, + IconButton, + Theme, + makeStyles, +} from '@material-ui/core'; import SearchIcon from '@material-ui/icons/Search'; import ClearButton from '@material-ui/icons/Clear'; @@ -27,7 +34,14 @@ type Props = { debounceTime?: number; }; +const useStyles = makeStyles((theme: Theme) => ({ + searchBar: { + padding: theme.spacing(1, 0), + }, +})); + export const SearchBar = ({ className, debounceTime = 0 }: Props) => { + const classes = useStyles(); const { term, setTerm } = useSearch(); const [value, setValue] = useState(term); @@ -40,28 +54,30 @@ export const SearchBar = ({ className, debounceTime = 0 }: Props) => { const handleClear = () => setValue(''); return ( - - - - - - } - endAdornment={ - - - - - - } - /> + + + + + + + } + endAdornment={ + + + + + + } + /> + ); }; diff --git a/plugins/search/src/components/SearchFilter/SearchFilter.tsx b/plugins/search/src/components/SearchFilter/SearchFilter.tsx index 52b03c785b..d9da3c4dbd 100644 --- a/plugins/search/src/components/SearchFilter/SearchFilter.tsx +++ b/plugins/search/src/components/SearchFilter/SearchFilter.tsx @@ -24,15 +24,21 @@ import { Select, MenuItem, FormLabel, + Theme, } from '@material-ui/core'; import { useSearch } from '../SearchContext'; -const useStyles = makeStyles({ +const useStyles = makeStyles((theme: Theme) => ({ label: { textTransform: 'capitalize', }, -}); + filter: { + '& + &': { + marginTop: theme.spacing(2.5), + }, + }, +})); export type Component = { className?: string; @@ -80,7 +86,7 @@ const CheckboxFilter = ({ return ( @@ -138,7 +144,7 @@ const SelectFilter = ({ return (