Commit 0385fabf authored by tom's avatar tom

search bar styles

parent 553d47e6
...@@ -8,6 +8,14 @@ import getDefaultTransitionProps from '../utils/getDefaultTransitionProps'; ...@@ -8,6 +8,14 @@ import getDefaultTransitionProps from '../utils/getDefaultTransitionProps';
import getOutlinedFieldStyles from '../utils/getOutlinedFieldStyles'; import getOutlinedFieldStyles from '../utils/getOutlinedFieldStyles';
const sizes: Record<string, SystemStyleObject> = { const sizes: Record<string, SystemStyleObject> = {
sm: {
fontSize: 'md',
lineHeight: '24px',
px: '8px',
py: '12px',
h: '40px',
borderRadius: 'base',
},
md: { md: {
fontSize: 'md', fontSize: 'md',
lineHeight: '20px', lineHeight: '20px',
...@@ -43,6 +51,10 @@ const variantOutline: PartsStyleFunction<typeof parts> = (props) => { ...@@ -43,6 +51,10 @@ const variantOutline: PartsStyleFunction<typeof parts> = (props) => {
const Input: ComponentStyleConfig = { const Input: ComponentStyleConfig = {
sizes: { sizes: {
sm: {
field: sizes.sm,
addon: sizes.sm,
},
md: { md: {
field: sizes.md, field: sizes.md,
addon: sizes.md, addon: sizes.md,
......
import { HStack, Flex, useColorModeValue } from '@chakra-ui/react'; import { HStack, VStack, Flex, useColorModeValue } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import useIsMobile from 'lib/hooks/useIsMobile'; import useIsMobile from 'lib/hooks/useIsMobile';
...@@ -7,7 +7,7 @@ import NetworkLogo from 'ui/navigation/NetworkLogo'; ...@@ -7,7 +7,7 @@ import NetworkLogo from 'ui/navigation/NetworkLogo';
import Burger from './Burger'; import Burger from './Burger';
import ColorModeToggler from './ColorModeToggler'; import ColorModeToggler from './ColorModeToggler';
import ProfileMenu from './ProfileMenu'; import ProfileMenu from './ProfileMenu';
import SearchBar from './SearchBar'; import SearchBar from './searchBar/SearchBar';
const Header = () => { const Header = () => {
const isMobile = useIsMobile(); const isMobile = useIsMobile();
...@@ -15,22 +15,27 @@ const Header = () => { ...@@ -15,22 +15,27 @@ const Header = () => {
if (isMobile) { if (isMobile) {
return ( return (
<Flex <VStack
as="header" as="header"
width="100%"
alignItems="center"
justifyContent="space-between"
position="fixed" position="fixed"
bgColor={ bgColor }
top={ 0 } top={ 0 }
left={ 0 } left={ 0 }
paddingX={ 4 } paddingX={ 4 }
paddingTop={ 2 } paddingY={ 2 }
bgColor={ bgColor }
width="100%"
> >
<Burger/> <Flex
<NetworkLogo/> width="100%"
<ProfileMenu/> alignItems="center"
</Flex> justifyContent="space-between"
>
<Burger/>
<NetworkLogo/>
<ProfileMenu/>
</Flex>
<SearchBar/>
</VStack>
); );
} }
......
import { SearchIcon } from '@chakra-ui/icons';
import { InputGroup, Input, InputLeftAddon, InputLeftElement, useColorModeValue } from '@chakra-ui/react';
import type { ChangeEvent, FormEvent } from 'react'; import type { ChangeEvent, FormEvent } from 'react';
import React from 'react'; import React from 'react';
import useBasePath from 'lib/hooks/useBasePath'; import useBasePath from 'lib/hooks/useBasePath';
import useIsMobile from 'lib/hooks/useIsMobile';
import SearchBarDesktop from './SearchBarDesktop';
import SearchBarMobile from './SearchBarMobile';
const SearchBar = () => { const SearchBar = () => {
const [ value, setValue ] = React.useState(''); const [ value, setValue ] = React.useState('');
const basePath = useBasePath(); const basePath = useBasePath();
const isMobile = useIsMobile();
const handleChange = React.useCallback((event: ChangeEvent<HTMLInputElement>) => { const handleChange = React.useCallback((event: ChangeEvent<HTMLInputElement>) => {
setValue(event.target.value); setValue(event.target.value);
...@@ -18,21 +21,17 @@ const SearchBar = () => { ...@@ -18,21 +21,17 @@ const SearchBar = () => {
window.location.assign(`https://blockscout.com${ basePath }/search-results?q=${ value }`); window.location.assign(`https://blockscout.com${ basePath }/search-results?q=${ value }`);
}, [ value, basePath ]); }, [ value, basePath ]);
if (isMobile) {
return (
<form noValidate onSubmit={ handleSubmit }>
<SearchBarMobile onChange={ handleChange }/>
</form>
);
}
return ( return (
<form noValidate onSubmit={ handleSubmit }> <form noValidate onSubmit={ handleSubmit }>
<InputGroup> <SearchBarDesktop onChange={ handleChange }/>
<InputLeftAddon w="111px">All filters</InputLeftAddon>
<InputLeftElement w={ 6 } ml="132px" mr={ 2.5 }>
<SearchIcon w={ 5 } h={ 5 } color={ useColorModeValue('blackAlpha.600', 'whiteAlpha.600') }/>
</InputLeftElement>
<Input
paddingInlineStart="50px"
placeholder="Search by addresses / transactions / block / token... "
ml="1px"
onChange={ handleChange }
borderColor={ useColorModeValue('blackAlpha.100', 'whiteAlpha.200') }
/>
</InputGroup>
</form> </form>
); );
}; };
......
import { SearchIcon } from '@chakra-ui/icons';
import { InputGroup, Input, InputLeftAddon, InputLeftElement, useColorModeValue } from '@chakra-ui/react';
import React from 'react';
import type { ChangeEvent } from 'react';
interface Props {
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
}
const SearchBarDesktop = ({ onChange }: Props) => {
return (
<InputGroup>
<InputLeftAddon w="111px">All filters</InputLeftAddon>
<InputLeftElement w={ 6 } ml="132px" mr={ 2.5 }>
<SearchIcon w={ 5 } h={ 5 } color={ useColorModeValue('blackAlpha.600', 'whiteAlpha.600') }/>
</InputLeftElement>
<Input
paddingInlineStart="50px"
placeholder="Search by addresses / transactions / block / token... "
ml="1px"
onChange={ onChange }
borderColor={ useColorModeValue('blackAlpha.100', 'whiteAlpha.200') }
/>
</InputGroup>
);
};
export default React.memo(SearchBarDesktop);
import { SearchIcon } from '@chakra-ui/icons';
import { InputGroup, Input, InputLeftElement, useColorModeValue } from '@chakra-ui/react';
import React from 'react';
import type { ChangeEvent } from 'react';
interface Props {
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
}
const SearchBarMobile = ({ onChange }: Props) => {
return (
<InputGroup size="sm">
<InputLeftElement >
<SearchIcon w={ 4 } h={ 4 } color={ useColorModeValue('blackAlpha.600', 'whiteAlpha.600') }/>
</InputLeftElement>
<Input
paddingInlineStart="38px"
placeholder="Search by addresses / ... "
ml="1px"
onChange={ onChange }
borderColor={ useColorModeValue('blackAlpha.100', 'whiteAlpha.200') }
/>
</InputGroup>
);
};
export default React.memo(SearchBarMobile);
...@@ -19,7 +19,7 @@ const Page = ({ children }: Props) => { ...@@ -19,7 +19,7 @@ const Page = ({ children }: Props) => {
alignItems="stretch" alignItems="stretch"
> >
<Navigation/> <Navigation/>
<VStack width="100%" paddingX={ isMobile ? 4 : 8 } paddingTop={ isMobile ? 12 : 9 }> <VStack width="100%" paddingX={ isMobile ? 4 : 8 } paddingTop={ isMobile ? '104px' : 9 }>
<Header/> <Header/>
<Box <Box
as="main" as="main"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment