From 857c9eb65b1790cc2b1ac8ffe14e031582fc69ee Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Sun, 10 May 2026 11:21:17 +0200 Subject: [PATCH] Redesign input and empty state components: improve search input interactions with clear button and icons, update compatibility questions empty state styling, and adjust profile form input widths and button properties for consistency and usability. --- .../compatibility-questions-display.tsx | 9 +++- web/components/optional-profile-form.tsx | 10 +++-- web/components/widgets/input.tsx | 45 +++++++++++++++---- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/web/components/answers/compatibility-questions-display.tsx b/web/components/answers/compatibility-questions-display.tsx index 73d5d81f..b32d4203 100644 --- a/web/components/answers/compatibility-questions-display.tsx +++ b/web/components/answers/compatibility-questions-display.tsx @@ -313,7 +313,14 @@ export function CompatibilityQuestionsDisplay(props: { ) })} {shownAnswers.length === 0 && ( -
{t('answers.display.none', 'None')}
+ +
+ {t('answers.display.no_results', 'No questions match your search')} +
+
+ {t('answers.display.try_different', 'Try adjusting your search or filters')} +
+ )} )} diff --git a/web/components/optional-profile-form.tsx b/web/components/optional-profile-form.tsx index 998b1f77..80d3fcd4 100644 --- a/web/components/optional-profile-form.tsx +++ b/web/components/optional-profile-form.tsx @@ -387,6 +387,7 @@ export const OptionalProfileUserForm = (props: { {buttonLabel ?? t('common.next', 'Next')} diff --git a/web/components/widgets/input.tsx b/web/components/widgets/input.tsx index 6bac6d42..6e8f4162 100644 --- a/web/components/widgets/input.tsx +++ b/web/components/widgets/input.tsx @@ -1,5 +1,6 @@ import clsx from 'clsx' -import {ComponentPropsWithoutRef, forwardRef, Ref} from 'react' +import {Search, X} from 'lucide-react' +import {ComponentPropsWithoutRef, forwardRef, Ref, useState} from 'react' import {Row} from 'web/components/layout/row' /** Text input. Wraps html `` */ @@ -11,21 +12,40 @@ export const Input = forwardRef( } & ComponentPropsWithoutRef<'input'>, ref: Ref, ) => { - const {error, searchIcon, className, ...rest} = props + const {error, searchIcon, className, value, onChange, ...rest} = props + const [hasValue, setHasValue] = useState(!!value) + + const rowClassName = clsx( + 'bg-canvas-50 h-12 rounded-xl border border-canvas-200 px-4 shadow-sm transition-colors items-center gap-2', + className, + ) + + const handleChange = (e: React.ChangeEvent) => { + setHasValue(!!e.target.value) + onChange?.(e) + } + + const handleClear = () => { + setHasValue(false) + // Trigger onChange with empty value + const syntheticEvent = { + target: {value: ''}, + } as React.ChangeEvent + onChange?.(syntheticEvent) + } - const rowClassName = - 'bg-canvas-50 h-12 rounded-xl border border-canvas-200 px-4 shadow-sm transition-colors items-center gap-2' const elem = ( @@ -33,9 +53,18 @@ export const Input = forwardRef( if (searchIcon) return ( - - {searchIcon && 🔍} + + {elem} + {hasValue && ( + + )} )