1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

added lab search

This commit is contained in:
Fedor Katurov 2022-03-29 17:40:48 +07:00
parent 16d12f92da
commit ddf2b6eda3
16 changed files with 149 additions and 28 deletions

View file

@ -1,4 +1,13 @@
import React, { ChangeEvent, FC, useCallback, useState } from 'react';
import React, {
ChangeEvent,
DetailedHTMLProps,
FC,
InputHTMLAttributes,
ReactElement,
ReactNode,
useCallback,
useState,
} from 'react';
import classNames from 'classnames';
@ -6,11 +15,21 @@ import { Icon } from '~/components/input/Icon';
import { InputWrapper } from '~/components/input/InputWrapper';
import { useTranslatedError } from '~/hooks/data/useTranslatedError';
import { useFocusEvent } from '~/hooks/dom/useFocusEvent';
import { IInputTextProps } from '~/types';
import styles from './styles.module.scss';
const InputText: FC<IInputTextProps> = ({
export type InputTextProps = Omit<
DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
'prefix'
> & {
handler?: (value: string) => void;
title?: string;
error?: string;
suffix?: ReactNode;
prefix?: ReactNode;
};
const InputText: FC<InputTextProps> = ({
className = '',
handler,
required = false,
@ -43,7 +62,12 @@ const InputText: FC<IInputTextProps> = ({
return (
<InputWrapper title={title} error={translatedError} focused={focused} notEmpty={!!value}>
<div className={classNames(styles.input, { [styles.has_error]: !!error })}>
<div
className={classNames(styles.input, {
[styles.has_error]: !!error,
[styles.has_prefix]: prefix,
})}
>
{!!prefix && <div className={styles.prefix}>{prefix}</div>}
<input

View file

@ -9,6 +9,12 @@
color: $red;
}
&.has_prefix {
input {
padding-left: 0;
}
}
input {
height: $input_height;
border: none;

View file

@ -0,0 +1,12 @@
import React, { VFC } from 'react';
import { Icon } from '~/components/input/Icon';
import { InputText, InputTextProps } from '~/components/input/InputText';
interface SearchInputProps extends Omit<InputTextProps, 'prefix' | 'suffix'> {}
const SearchInput: VFC<SearchInputProps> = ({ ...props }) => (
<InputText {...props} prefix={<Icon icon="search" />} />
);
export { SearchInput };