Merge pull request 'feature/text-input-component' (#56) from feature/text-input-component into develop

Reviewed-on: http://85.143.176.51:3000/free-land/front-end/pulls/56
This commit is contained in:
Denis Gorbunov 2022-08-09 10:52:47 +00:00
commit e4b38c7118
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,56 @@
import classNames from "classnames";
import { initial, isEmpty, omit } from "lodash";
import React from "react";
import "../index.css";
type Props = {
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 = ({
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-full",
"text-gray-900",
"rounded",
"outline-none",
"placeholder-text-500",
{
//it this part we define how we style
[`${inputNotInGroup}`] : !inGroup,
[`${inputInGroup}`] : inGroup,
},
className,
])}
/>
);
};

View File

@ -0,0 +1,18 @@
import React from "react";
import { ComponentStory, ComponentMeta } from '@storybook/react';
import {TextInput} from "../components/TextInput";
export default {
title: 'Text Input',
component: TextInput,
} as ComponentMeta<typeof TextInput>;
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"]
};