From 65e9689bfb3dc0c6c24ada341653c7d70ba4e607 Mon Sep 17 00:00:00 2001 From: Gabriele Petronella Date: Fri, 18 Oct 2024 14:07:48 +0200 Subject: [PATCH] Use normal positioning for SearchBar accessories --- .../src/SearchBar/SearchBar.css.ts | 18 ++++-- .../src/SearchBar/SearchBar.tsx | 61 +++++-------------- 2 files changed, 27 insertions(+), 52 deletions(-) diff --git a/packages/bento-design-system/src/SearchBar/SearchBar.css.ts b/packages/bento-design-system/src/SearchBar/SearchBar.css.ts index 6d190c0a1..97209f0c7 100644 --- a/packages/bento-design-system/src/SearchBar/SearchBar.css.ts +++ b/packages/bento-design-system/src/SearchBar/SearchBar.css.ts @@ -1,12 +1,20 @@ import { style } from "@vanilla-extract/css"; +import { bentoSprinkles } from "../internal"; -export const input = style({ - selectors: { - [`&::-webkit-search-decoration, +export const input = style([ + bentoSprinkles({ + outline: "none", + }), + { + selectors: { + [`&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration`]: { - WebkitAppearance: "none", + WebkitAppearance: "none", + }, }, }, -}); +]); + +export const inputContainer = style({}); diff --git a/packages/bento-design-system/src/SearchBar/SearchBar.tsx b/packages/bento-design-system/src/SearchBar/SearchBar.tsx index b05a9585a..9d9ce6c19 100644 --- a/packages/bento-design-system/src/SearchBar/SearchBar.tsx +++ b/packages/bento-design-system/src/SearchBar/SearchBar.tsx @@ -1,10 +1,9 @@ import { useTextField } from "@react-aria/textfield"; import { HTMLAttributes, useRef } from "react"; -import useDimensions from "react-cool-dimensions"; import { LocalizedString, Box, Field, IconButton } from ".."; import { inputRecipe } from "../Field/Field.css"; import { bodyRecipe } from "../Typography/Body/Body.css"; -import { input } from "./SearchBar.css"; +import { input, inputContainer } from "./SearchBar.css"; import { useDefaultMessages } from "../util/useDefaultMessages"; import { useBentoConfig } from "../BentoConfigContext"; import { AtLeast } from "../util/AtLeast"; @@ -25,16 +24,6 @@ export function SearchBar(props: Props) { const config = useBentoConfig().searchBar; const inputRef = useRef(null); - const { observe: leftAccessoryRef, width: leftAccessoryWidth } = useDimensions({ - // This is needed to include the padding in the width calculation - useBorderBoxSize: true, - }); - - const { observe: rightAccessoryRef, width: rightAccessoryWidth } = useDimensions({ - // This is needed to include the padding in the width calculation - useBorderBoxSize: true, - }); - const { labelProps, inputProps, descriptionProps, errorMessageProps } = useTextField( { ...props, @@ -64,19 +53,17 @@ export function SearchBar(props: Props) { assistiveTextProps={descriptionProps} errorMessageProps={errorMessageProps} > - - + + {config.searchIcon({ size: config.searchIconSize })} {rightAccessoryContent && ( - + {rightAccessoryContent} )}