Commit 0b4f1762 authored by tom's avatar tom

bring search bar to life

parent c2996843
...@@ -8,6 +8,9 @@ const global = (props: StyleFunctionProps) => ({ ...@@ -8,6 +8,9 @@ const global = (props: StyleFunctionProps) => ({
bg: mode('white', 'black')(props), bg: mode('white', 'black')(props),
...getDefaultTransitionProps(), ...getDefaultTransitionProps(),
}, },
form: {
w: '100%',
},
}); });
export default global; export default global;
...@@ -25,7 +25,7 @@ export interface ColorModeTogglerProps ...@@ -25,7 +25,7 @@ export interface ColorModeTogglerProps
ThemingProps<'Switch'> { ThemingProps<'Switch'> {
} }
export const ColorModeToggler = forwardRef<ColorModeTogglerProps, 'input'>((props, ref) => { const ColorModeToggler = forwardRef<ColorModeTogglerProps, 'input'>((props, ref) => {
const ownProps = omitThemingProps(props); const ownProps = omitThemingProps(props);
const { toggleColorMode, colorMode } = useColorMode(); const { toggleColorMode, colorMode } = useColorMode();
...@@ -91,3 +91,5 @@ export const ColorModeToggler = forwardRef<ColorModeTogglerProps, 'input'>((prop ...@@ -91,3 +91,5 @@ export const ColorModeToggler = forwardRef<ColorModeTogglerProps, 'input'>((prop
if (__DEV__) { if (__DEV__) {
ColorModeToggler.displayName = 'ColorModeToggler'; ColorModeToggler.displayName = 'ColorModeToggler';
} }
export default ColorModeToggler;
import { SearchIcon } from '@chakra-ui/icons'; import { HStack, Center, useColorModeValue } from '@chakra-ui/react';
import { HStack, InputGroup, Input, InputLeftAddon, InputLeftElement, Center, useColorModeValue } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import Identicon from 'react-identicons'; import Identicon from 'react-identicons';
import { ColorModeToggler } from './ColorModeToggler'; import ColorModeToggler from './ColorModeToggler';
import styles from './Header.module.css'; import styles from './Header.module.css';
import SearchBar from './SearchBar';
const Header = () => { const Header = () => {
return ( return (
...@@ -17,13 +17,7 @@ const Header = () => { ...@@ -17,13 +17,7 @@ const Header = () => {
marginTop={ 9 } marginTop={ 9 }
gap={ 12 } gap={ 12 }
> >
<InputGroup> <SearchBar/>
<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"/>
</InputGroup>
<ColorModeToggler/> <ColorModeToggler/>
<Center minWidth="50px" width="50px" height="50px" bg={ useColorModeValue('blackAlpha.100', 'white') } borderRadius="50%" overflow="hidden"> <Center minWidth="50px" width="50px" height="50px" bg={ useColorModeValue('blackAlpha.100', 'white') } borderRadius="50%" overflow="hidden">
{ /* the displayed size is 48px, but we need to generate x2 for retina displays */ } { /* the displayed size is 48px, but we need to generate x2 for retina displays */ }
......
import { SearchIcon } from '@chakra-ui/icons';
import { InputGroup, Input, InputLeftAddon, InputLeftElement, useColorModeValue } from '@chakra-ui/react';
import type { ChangeEvent, FormEvent } from 'react';
import React from 'react';
const SearchBar = () => {
const [ value, setValue ] = React.useState('');
const handleChange = React.useCallback((event: ChangeEvent<HTMLInputElement>) => {
setValue(event.target.value);
}, []);
const handleSubmit = React.useCallback((event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
window.location.assign(`https://blockscout.com/xdai/mainnet/search-results?q=${ value }`);
}, [ value ]);
return (
<form noValidate onSubmit={ handleSubmit }>
<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={ handleChange }
/>
</InputGroup>
</form>
);
};
export default SearchBar;
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