mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
update search input styles
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { useHotkeys } from '@mantine/hooks';
|
import { useHotkeys } from '@mantine/hooks';
|
||||||
import { ChangeEvent, KeyboardEvent, useRef } from 'react';
|
import { ChangeEvent, KeyboardEvent, useRef, useState } from 'react';
|
||||||
import { shallow } from 'zustand/shallow';
|
import { shallow } from 'zustand/shallow';
|
||||||
|
|
||||||
import { useSettingsStore } from '/@/renderer/store';
|
import { useSettingsStore } from '/@/renderer/store';
|
||||||
@@ -35,14 +35,21 @@ export const SearchInput = ({ onChange, ...props }: SearchInputProps) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [isFocused, setIsFocused] = useState(false);
|
||||||
|
|
||||||
|
const hasValue = props.value || ref.current?.value;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TextInput
|
<TextInput
|
||||||
leftSection={<Icon icon="search" />}
|
leftSection={<Icon icon="search" />}
|
||||||
|
maw="20dvw"
|
||||||
|
onBlur={() => setIsFocused(false)}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
onFocus={() => setIsFocused(true)}
|
||||||
onKeyDown={handleEscape}
|
onKeyDown={handleEscape}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
size="sm"
|
size="sm"
|
||||||
width={200}
|
width={isFocused || hasValue ? '200px' : '100px'}
|
||||||
{...props}
|
{...props}
|
||||||
rightSection={
|
rightSection={
|
||||||
ref.current?.value ? (
|
ref.current?.value ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user