diff --git a/.changeset/flat-guests-matter.md b/.changeset/flat-guests-matter.md new file mode 100644 index 0000000..1a455c7 --- /dev/null +++ b/.changeset/flat-guests-matter.md @@ -0,0 +1,5 @@ +--- +"@openfun/cunningham-react": minor +--- + +add InputPassword diff --git a/packages/react/src/components/Forms/Input/InputPassword.stories.tsx b/packages/react/src/components/Forms/Input/InputPassword.stories.tsx new file mode 100644 index 0000000..6533989 --- /dev/null +++ b/packages/react/src/components/Forms/Input/InputPassword.stories.tsx @@ -0,0 +1,13 @@ +import { Meta } from "@storybook/react"; +import { InputPassword } from ":/components/Forms/Input/InputPassword"; + +export default { + title: "Components/Forms/Input", + component: InputPassword, +} as Meta; + +export const Password = { + args: { + label: "Your most secret password", + }, +}; diff --git a/packages/react/src/components/Forms/Input/InputPassword.tsx b/packages/react/src/components/Forms/Input/InputPassword.tsx new file mode 100644 index 0000000..6d53695 --- /dev/null +++ b/packages/react/src/components/Forms/Input/InputPassword.tsx @@ -0,0 +1,41 @@ +import React, { forwardRef } from "react"; +import { Input, InputProps } from ":/components/Forms/Input/index"; +import { Button } from ":/components/Button"; +import { useCunningham } from ":/components/Provider"; + +export const InputPassword = forwardRef< + HTMLInputElement, + Omit +>((props: InputProps, ref) => { + const [showPassword, setShowPassword] = React.useState(false); + const { className, ...otherProps } = props; + const customClassName = "c__input--password"; + const { t } = useCunningham(); + return ( + setShowPassword(false)} + icon={visibility_off} + color="tertiary-text" + size="small" + aria-label={t("components.forms.input.password.hide_password")} + /> + ) : ( +