added 2 views of text input component: when it in group and not in group

This commit is contained in:
Maximus 2022-08-08 16:27:54 +03:00
parent 00c29d39d0
commit f89be00751
2 changed files with 50 additions and 29 deletions

View File

@ -1,37 +1,56 @@
import classNames from "classnames"; import classNames from "classnames";
import { omit } from "lodash"; import { initial, isEmpty, omit } from "lodash";
import React from "react"; import React from "react";
import "../index.css"; import "../index.css";
type Props = { type Props = {
placeholder?: string | undefined, inGroup?: boolean,
className?: string | undefined, placeholder?: string | undefined;
} & Omit<React.InputHTMLAttributes<HTMLInputElement> ,"">; className?: string | undefined;
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, "">;
const inputNotInGroup = [
`border
border-2
border-solid
border-gray-200
hover:border-gray-500
active:border-gray-500
focus:border-gray-500`
]
const inputInGroup = [
`border-none
hover:none
active:none
focus:none
`
]
export const TextInput = ({ export const TextInput = ({
placeholder = undefined, inGroup = false, // We should use this flag to choose how we will style our text input component
placeholder,
className, className,
...props ...props
} :Props) => { }: Props) => {
return(
<input return (
type="text" <input
placeholder={placeholder} type="text"
className={classNames( placeholder={placeholder}
'w-100', className={classNames([
'border', "w-full",
'border-2', "text-gray-900",
'border-solid', "rounded",
'border-gray-200', "outline-none",
'text-gray-900', "placeholder-text-500",
'rounded', {
'outline-none', //it this part we define how we style
'hover:border-gray-300', [`${inputNotInGroup}`] : !inGroup,
'focus:border-gray-500', [`${inputInGroup}`] : inGroup,
{ },
className className,
})} ])}
/> />
); );
};
}

View File

@ -12,5 +12,7 @@ const Template: ComponentStory<typeof TextInput> = (args) => <TextInput {...args
export const TextInputStory = Template.bind({}); export const TextInputStory = Template.bind({});
TextInputStory.args ={ TextInputStory.args ={
inGroup: true,
placeholder: "Search", placeholder: "Search",
} className: ["px-4", "py-2.5"]
};