Commit c53d7fcc authored by Kaylee George's avatar Kaylee George Committed by GitHub

fix: fix Explore search bar styling (#4405)

* fix search

* fix responsive

* fix width
parent 3de2e655
...@@ -8,7 +8,7 @@ import { ExternalLink } from 'theme' ...@@ -8,7 +8,7 @@ import { ExternalLink } from 'theme'
import { Color } from 'theme/styled' import { Color } from 'theme/styled'
const Label = styled.div<{ color: Color }>` const Label = styled.div<{ color: Color }>`
width: 284px; width: 100%;
padding: 12px 20px; padding: 12px 20px;
background-color: ${({ color }) => color + '1F'}; background-color: ${({ color }) => color + '1F'};
border-radius: 16px; border-radius: 16px;
......
import searchIcon from 'assets/svg/search.svg' import searchIcon from 'assets/svg/search.svg'
import xIcon from 'assets/svg/x.svg' import xIcon from 'assets/svg/x.svg'
import { useAtom } from 'jotai' import { useAtom } from 'jotai'
import { useState } from 'react'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { MEDIUM_MEDIA_BREAKPOINT } from '../constants' import { MEDIUM_MEDIA_BREAKPOINT } from '../constants'
...@@ -12,33 +11,31 @@ const SearchBarContainer = styled.div` ...@@ -12,33 +11,31 @@ const SearchBarContainer = styled.div`
display: flex; display: flex;
flex: 1; flex: 1;
` `
const SearchInput = styled.input<{ expanded: boolean }>` const SearchInput = styled.input`
background: no-repeat scroll 7px 7px; background: no-repeat scroll 7px 7px;
background-image: ${({ expanded }) => !expanded && `url(${searchIcon})`}; background-image: url(${searchIcon});
background-size: 20px 20px; background-size: 20px 20px;
background-position: 14px center; background-position: 12px center;
background-color: 'transparent'; background-color: 'transparent';
border-radius: 12px; border-radius: 12px;
border: 1px solid ${({ theme }) => theme.backgroundOutline}; border: 1px solid ${({ theme }) => theme.backgroundOutline};
height: 100%; height: 100%;
width: ${({ expanded }) => (expanded ? '100%' : '52px')}; width: min(300px, 100%);
font-size: 16px; font-size: 16px;
padding-left: 35px; padding-left: 40px;
color: ${({ theme }) => theme.textPrimary}; color: ${({ theme }) => theme.textPrimary};
transition: width 0.75s cubic-bezier(0, 0.795, 0, 1);
:hover { :hover {
cursor: ${({ expanded }) => !expanded && 'pointer'};
background-color: ${({ theme }) => theme.backgroundModule}; background-color: ${({ theme }) => theme.backgroundModule};
} }
:focus { :focus {
outline: none; outline: none;
background-color: ${({ theme }) => theme.accentActionSoft}; background-color: ${({ theme }) => theme.backgroundSurface};
border: none; border: 1.5px solid ${({ theme }) => theme.accentActionSoft};
} }
::placeholder { ::placeholder {
color: ${({ expanded, theme }) => (expanded ? theme.textTertiary : 'transparent')}; color: ${({ theme }) => theme.textTertiary};
} }
::-webkit-search-cancel-button { ::-webkit-search-cancel-button {
-webkit-appearance: none; -webkit-appearance: none;
...@@ -58,16 +55,12 @@ const SearchInput = styled.input<{ expanded: boolean }>` ...@@ -58,16 +55,12 @@ const SearchInput = styled.input<{ expanded: boolean }>`
export default function SearchBar() { export default function SearchBar() {
const [filterString, setFilterString] = useAtom(filterStringAtom) const [filterString, setFilterString] = useAtom(filterStringAtom)
const [isExpanded, setExpanded] = useState(false)
return ( return (
<SearchBarContainer> <SearchBarContainer>
<SearchInput <SearchInput
expanded={isExpanded}
type="search" type="search"
placeholder="Search by name or token address" placeholder="Search tokens"
id="searchBar" id="searchBar"
onBlur={() => isExpanded && filterString.length === 0 && setExpanded(false)}
onFocus={() => setExpanded(true)}
autoComplete="off" autoComplete="off"
value={filterString} value={filterString}
onChange={({ target: { value } }) => setFilterString(value)} onChange={({ target: { value } }) => setFilterString(value)}
......
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