Last active
August 27, 2019 10:32
-
-
Save RubaXa/2b38f7a8490c7d66cb1cd1ed9cebb0af to your computer and use it in GitHub Desktop.
Poor slots. Describe.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type LoginFormProps = { | |
header?: boolean; | |
title?: React.ReactNode; | |
titleEl?: React.ReactNode; // ⬅️ заметьте, я не глупый и делаю универсально | |
email?: string; | |
password?: string; | |
} | |
function LoginForm(props: LoginFormProps) { | |
const titleEl = props.titleEl || <h2/>; | |
const jsxTitle = React.cloneElement( | |
titleEl, | |
titleEl.props, | |
props.title || <>Вход</>, | |
); | |
return ( | |
<Form> | |
{props.header !== false && <div className="header"> | |
{jsxTitle} | |
</div>} | |
<div className="fields"> | |
<Input name="email" value={props.email} /> | |
<Input name="password" value={props.password} /> | |
</div> | |
<div className="controls"> | |
<Button kind="primary"/> | |
</div> | |
</Form> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment