Skip to content

Commit

Permalink
SearchBox: Unify suggestions and input design (#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dlurak authored Jan 27, 2025
1 parent b1372ec commit cf35cb9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/SearchBox/AutocompleteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useGetOptions } from './useGetOptions';
import { useInputValueState } from './options/geocoder';
import { useRouter } from 'next/router';
import { useUserSettingsContext } from '../utils/UserSettingsContext';
import { OptionsPaper, OptionsPopper } from './optionsPopper';

type SearchBoxInputProps = {
params: any;
Expand Down Expand Up @@ -113,6 +114,7 @@ export const AutocompleteInput: React.FC<AutocompleteInputProps> = ({
autocompleteRef={autocompleteRef}
/>
)}
slots={{ paper: OptionsPaper, popper: OptionsPopper }}
renderOption={renderOptionFactory(
inputValue,
currentTheme,
Expand Down
21 changes: 21 additions & 0 deletions src/components/SearchBox/optionsPopper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import styled from '@emotion/styled';
import { Paper, PaperProps, Popper, PopperProps } from '@mui/material';
import { useFeatureContext } from '../utils/FeatureContext';

const StyledPaper = styled(Paper)<PaperProps & { $solidBg: boolean }>`
background-color: ${({ theme, $solidBg }) =>
$solidBg
? theme.palette.background.searchInputSolid
: theme.palette.background.searchInput};
-webkit-backdrop-filter: blur(35px);
backdrop-filter: blur(35px);
`;

export const OptionsPaper = (props: PaperProps) => {
const { feature } = useFeatureContext();
return <StyledPaper {...props} $solidBg={!!feature} />;
};

export const OptionsPopper = styled(Popper)<PopperProps>`
padding-top: 5px;
`;
2 changes: 2 additions & 0 deletions src/helpers/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const lightTheme = createTheme({
hover: '#f2f3f2',
searchBox: '#eb5757',
searchInput: 'rgba(255,255,255,0.6)',
searchInputSolid: 'rgb(249, 248, 244)',
searchInputPanel: 'rgba(255,255,255,0.8)',
},
invertFilter: 'invert(0)',
Expand Down Expand Up @@ -68,6 +69,7 @@ const darkTheme = createTheme({
hover: grey['700'],
searchBox: '#963838',
searchInput: 'rgba(0,0,0,0.5)',
searchInputSolid: 'rgb(35, 26, 26)',
searchInputPanel: 'rgba(0,0,0,0.7)',
},
invertFilter: 'invert(1)',
Expand Down
1 change: 1 addition & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ declare module '@mui/material/styles' {
hover?: string;
searchBox?: string;
searchInput?: string;
searchInputSolid?: string;
searchInputPanel?: string;
}

Expand Down

0 comments on commit cf35cb9

Please sign in to comment.