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 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(
|
|
||||||
|
return (
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
className={classNames(
|
className={classNames([
|
||||||
'w-100',
|
"w-full",
|
||||||
'border',
|
"text-gray-900",
|
||||||
'border-2',
|
"rounded",
|
||||||
'border-solid',
|
"outline-none",
|
||||||
'border-gray-200',
|
"placeholder-text-500",
|
||||||
'text-gray-900',
|
|
||||||
'rounded',
|
|
||||||
'outline-none',
|
|
||||||
'hover:border-gray-300',
|
|
||||||
'focus:border-gray-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({});
|
export const TextInputStory = Template.bind({});
|
||||||
|
|
||||||
TextInputStory.args ={
|
TextInputStory.args ={
|
||||||
|
inGroup: true,
|
||||||
placeholder: "Search",
|
placeholder: "Search",
|
||||||
}
|
className: ["px-4", "py-2.5"]
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user