import * as React from "react"; import * as SVG from "~/common/svg"; import { P1 } from "~/components/system/components/Typography"; import { Input } from "~/components/system"; import { css } from "@emotion/react"; const STYLES_SMALL_TEXT = (theme) => css` font-size: ${theme.typescale.lvlN1}; line-height: 15.6px; `; const STYLES_PASSWORD_VALIDATIONS = (theme) => css` margin-top: 16px; border: 1px solid ${theme.system.white}; background-color: white; @supports ((-webkit-backdrop-filter: blur(25px)) or (backdrop-filter: blur(25px))) { background-color: ${theme.semantic.bgBlurWhiteTRN}; backdrop-filter: blur(75px); } padding: 8px 12px; border-radius: 8px; `; const STYLES_PASSWORD_VALIDATION = (theme) => css` display: flex; align-items: center; & > * + * { margin-left: 8px; } `; const STYLES_CIRCLE = (theme) => css` height: 8px; width: 8px; border-radius: 50%; border: 1.25px solid ${theme.system.grayLight2}; `; const STYLES_CIRCLE_SUCCESS = (theme) => css` border: 1.25px solid ${theme.system.green}; `; const STYLES_INPUT = (theme) => css` background-color: rgba(242, 242, 247, 0.7); box-shadow: ${theme.shadow.lightLarge}; border-radius: 8px; &::placeholder { color: ${theme.semantic.textGrayDark}; } `; const STYLES_INPUT_ERROR = (theme) => css` background-color: rgba(242, 242, 247, 0.5); border: 1px solid ${theme.system.red}; &::placeholder { color: ${theme.semantic.textGrayDark}; } `; const STYLES_INPUT_SUCCESS = (theme) => css` background-color: rgba(242, 242, 247, 0.5); border: 1px solid ${theme.system.green}; &::placeholder { color: ${theme.semantic.textGrayDark}; } `; const PasswordValidations = ({ validations }) => { return (
Passwords should
Be at least 8 characters long
Contain both uppercase and lowercase letters
Contain at least 1 number
Contain at least 1 symbol
); }; export default function Field({ touched, error, success, validations, errorAs, containerAs, ...props }) { const showError = touched && error; const showSuccess = touched && !error; const STYLES = React.useMemo(() => { if (showError) return STYLES_INPUT_ERROR; if (showSuccess) return STYLES_INPUT_SUCCESS; return STYLES_INPUT; }, [touched, error]); const ContainerComponent = containerAs || "div"; const ErrorWrapper = errorAs || "div"; return (
{props.name === "password" && validations ? ( ) : ( {(showError && error) || (showSuccess && success)} )}
); }