added 2 views of text input component: when it in group and not in group
This commit is contained in:
parent
00c29d39d0
commit
f89be00751
@ -1,37 +1,56 @@
|
||||
import classNames from "classnames";
|
||||
import { omit } from "lodash";
|
||||
import { initial, isEmpty, omit } from "lodash";
|
||||
import React from "react";
|
||||
import "../index.css";
|
||||
|
||||
type Props = {
|
||||
placeholder?: string | undefined,
|
||||
className?: string | undefined,
|
||||
inGroup?: boolean,
|
||||
placeholder?: string | undefined;
|
||||
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 = ({
|
||||
placeholder = undefined,
|
||||
inGroup = false, // We should use this flag to choose how we will style our text input component
|
||||
placeholder,
|
||||
className,
|
||||
...props
|
||||
}: Props) => {
|
||||
|
||||
return (
|
||||
<input
|
||||
type="text"
|
||||
placeholder={placeholder}
|
||||
className={classNames(
|
||||
'w-100',
|
||||
'border',
|
||||
'border-2',
|
||||
'border-solid',
|
||||
'border-gray-200',
|
||||
'text-gray-900',
|
||||
'rounded',
|
||||
'outline-none',
|
||||
'hover:border-gray-300',
|
||||
'focus:border-gray-500',
|
||||
className={classNames([
|
||||
"w-full",
|
||||
"text-gray-900",
|
||||
"rounded",
|
||||
"outline-none",
|
||||
"placeholder-text-500",
|
||||
{
|
||||
className
|
||||
})}
|
||||
//it this part we define how we style
|
||||
[`${inputNotInGroup}`] : !inGroup,
|
||||
[`${inputInGroup}`] : inGroup,
|
||||
},
|
||||
className,
|
||||
])}
|
||||
/>
|
||||
);
|
||||
|
||||
}
|
||||
};
|
||||
|
@ -12,5 +12,7 @@ const Template: ComponentStory<typeof TextInput> = (args) => <TextInput {...args
|
||||
export const TextInputStory = Template.bind({});
|
||||
|
||||
TextInputStory.args ={
|
||||
inGroup: true,
|
||||
placeholder: "Search",
|
||||
}
|
||||
className: ["px-4", "py-2.5"]
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user