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:
commit
e4b38c7118
56
src/components/TextInput.tsx
Normal file
56
src/components/TextInput.tsx
Normal 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,
|
||||
])}
|
||||
/>
|
||||
);
|
||||
};
|
18
src/stories/TextInput.stories.tsx
Normal file
18
src/stories/TextInput.stories.tsx
Normal 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"]
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user