diff --git a/package.json b/package.json index 7bade61..4748234 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,7 @@ "@types/react-transition-group": "^4.4.1", "@types/styled-components": "^5.1.10", "auto": "^10.29.2", + "babel-loader": "^8.1.0", "chromatic": "^5.9.0", "copyfiles": "^2.4.1", "cross-env": "^7.0.3", diff --git a/src/stories/button/Button.tsx b/src/stories/button/Button.tsx index 208e1fd..26504db 100644 --- a/src/stories/button/Button.tsx +++ b/src/stories/button/Button.tsx @@ -1,8 +1,8 @@ import styled, { DefaultTheme } from "styled-components"; -import getButtonSize from "./getButtonSize"; -import getButtonStyle from "./getButtonStyle"; import { ButtonComponent } from "./_component"; import { ButtonProps } from "./_types"; +import getButtonSize from "./getButtonSize"; +import getButtonStyle from "./getButtonStyle"; export const Button = styled(ButtonComponent)( ({ @@ -13,6 +13,7 @@ export const Button = styled(ButtonComponent)( flat = false, squared = false, variant = false, + alt, }: ButtonProps & { theme: DefaultTheme }) => { let styles = getButtonStyle(type, flat, disabled, variant, theme); styles += getButtonSize(size, squared, theme); diff --git a/src/stories/button/_component.tsx b/src/stories/button/_component.tsx index 646945e..9aa3aa1 100644 --- a/src/stories/button/_component.tsx +++ b/src/stories/button/_component.tsx @@ -13,12 +13,14 @@ export const ButtonComponent = ({ flat, squared, variant, + alt, children, ...props }: ButtonProps) => { let Component = as; return ( ( disabled={true} /> ); + +export const PasswordInput: Story = () => ( + +); diff --git a/src/stories/form/input/Input.tsx b/src/stories/form/input/Input.tsx index 0454d52..95a6acc 100644 --- a/src/stories/form/input/Input.tsx +++ b/src/stories/form/input/Input.tsx @@ -1,6 +1,8 @@ -import { Search } from "react-bootstrap-icons"; +import { useState } from "react"; import styled from "styled-components"; import { InvalidFocusStyle, InvalidInputStyle } from "../_style"; +import PasswordIcon from "./inputIcons/PasswordIcon"; +import SearchIcon from "./inputIcons/SearchIcon"; const Input = ({ id, @@ -13,6 +15,7 @@ const Input = ({ extra, onChange, autocomplete = true, + i18n, }: { id: string; type: string; @@ -24,12 +27,17 @@ const Input = ({ isInvalid?: boolean; extra?: any; onChange?: (val: string) => void; + i18n?: { + showPassword?: string; + hidePassword?: string; + }; }) => { + const [currentType, setType] = useState(type); return ( onChange && onChange(e.target.value)} {...extra} /> - {type === "search" && ( - - - + {type === "search" && } + {type === "password" && ( + )} ); @@ -52,12 +59,18 @@ export const StyledInput = styled.div<{ type: string; isInvalid?: boolean }>` flex-wrap: wrap; align-items: stretch; width: 100%; - .input-group-text { + .input-group-text, + .input-group-button { position: absolute; right: 15px; - top: 29%; + display: flex; + align-items: center; + height: 100%; color: ${(props) => props.theme.variants.primary}; } + .input-group-text { + top: 29%; + } input[type="search"] { -webkit-appearance: none; diff --git a/src/stories/form/input/inputIcons/PasswordIcon.tsx b/src/stories/form/input/inputIcons/PasswordIcon.tsx new file mode 100644 index 0000000..19163f5 --- /dev/null +++ b/src/stories/form/input/inputIcons/PasswordIcon.tsx @@ -0,0 +1,43 @@ +import { EyeFill, EyeSlash } from "react-bootstrap-icons"; +import { Button } from "../../../button/Button"; + +const PasswordIcon = ({ + type, + setType, + i18n, +}: { + type: string; + setType: (value: string) => void; + i18n?: { + showPassword?: string; + hidePassword?: string; + }; +}) => { + return ( + + {type === "text" ? ( + + ) : ( + + )} + + ); +}; + +export default PasswordIcon; diff --git a/src/stories/form/input/inputIcons/SearchIcon.tsx b/src/stories/form/input/inputIcons/SearchIcon.tsx new file mode 100644 index 0000000..4ca16ff --- /dev/null +++ b/src/stories/form/input/inputIcons/SearchIcon.tsx @@ -0,0 +1,11 @@ +import { Search } from "react-bootstrap-icons"; + +const SearchIcon = () => { + return ( + + + + ); +}; + +export default SearchIcon;