|
| 1 | +import { Input as BaseInput, Button as BaseButton, SearchField as BaseSearchField } from 'react-aria-components'; |
| 2 | +import styled from 'styled-components'; |
| 3 | + |
| 4 | +import { getSemanticValue } from '../../../essentials/experimental'; |
| 5 | +import SearchIcon from '../../../icons/experimental/SearchIcon'; |
| 6 | +import { get } from '../../../utils/experimental/themeGet'; |
| 7 | +import { textStyles } from '../Text/Text'; |
| 8 | + |
| 9 | +export const Icon = styled(SearchIcon)` |
| 10 | + position: absolute; |
| 11 | + left: ${get('space.3')}; |
| 12 | + top: 50%; |
| 13 | + transform: translateY(-50%); |
| 14 | + pointer-events: none; |
| 15 | +`; |
| 16 | + |
| 17 | +export const SearchField = styled(BaseSearchField)` |
| 18 | + position: relative; |
| 19 | + border-radius: ${get('radii.4')}; |
| 20 | + background: ${getSemanticValue('surface-variant')}; |
| 21 | + color: ${getSemanticValue('on-surface-variant')}; |
| 22 | +
|
| 23 | + &::before { |
| 24 | + position: absolute; |
| 25 | + pointer-events: none; |
| 26 | + inset: 0; |
| 27 | + content: ''; |
| 28 | + border-radius: inherit; |
| 29 | + opacity: 0; |
| 30 | + transition: opacity ease 200ms; |
| 31 | + } |
| 32 | +
|
| 33 | + &:has([data-hovered])::before { |
| 34 | + opacity: 0.16; |
| 35 | + background-color: ${getSemanticValue('on-surface-variant')}; |
| 36 | + } |
| 37 | +
|
| 38 | + &:has([data-focused]) { |
| 39 | + background: ${getSemanticValue('surface')}; |
| 40 | + color: ${getSemanticValue('interactive')}; |
| 41 | + outline: ${getSemanticValue('interactive')} solid 0.125rem; |
| 42 | + outline-offset: -0.125rem; |
| 43 | +
|
| 44 | + &::before { |
| 45 | + opacity: 0; |
| 46 | + } |
| 47 | + } |
| 48 | +
|
| 49 | + &:has([data-disabled]) { |
| 50 | + opacity: 0.38; |
| 51 | + } |
| 52 | +`; |
| 53 | + |
| 54 | +export const Button = styled(BaseButton)` |
| 55 | + appearance: none; |
| 56 | + background: none; |
| 57 | + display: flex; |
| 58 | + margin: 0; |
| 59 | + padding: 0; |
| 60 | + border: 0; |
| 61 | + outline: 0; |
| 62 | + cursor: pointer; |
| 63 | + position: absolute; |
| 64 | + right: ${get('space.3')}; |
| 65 | + top: 50%; |
| 66 | + transform: translateY(-50%); |
| 67 | +`; |
| 68 | + |
| 69 | +export const Input = styled(BaseInput)` |
| 70 | + background-color: unset; |
| 71 | + display: block; |
| 72 | + padding: ${get('space.2')} ${get('space.9')}; |
| 73 | + border: 0; |
| 74 | + outline: 0; |
| 75 | + caret-color: ${getSemanticValue('interactive')}; |
| 76 | + color: ${getSemanticValue('on-surface')}; |
| 77 | +
|
| 78 | + ${textStyles.variants.label1} |
| 79 | +
|
| 80 | + &[data-placeholder] { |
| 81 | + color: ${getSemanticValue('on-surface-variant')}; |
| 82 | + } |
| 83 | +
|
| 84 | + &::-webkit-search-cancel-button { |
| 85 | + display: none; |
| 86 | + } |
| 87 | +`; |
0 commit comments