Last active
August 27, 2019 06:44
-
-
Save RubaXa/c8c280d09c553532f481e19c298535be to your computer and use it in GitHub Desktop.
TrueSlots
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
import { Slot, SlotComponent, createComponentDescriptor } from '@truekit/core/component'; | |
type LoginFormProps = { | |
title?: Slot< SlotComponent >; // ⬅ опа 1️⃣ | |
email?: string; | |
password?: string; | |
} | |
const $LoginForm = createComponentDescriptor('@myapp/LoginForm', {} as LoginFormProps); | |
const LoginForm = $LoginForm.createComponent(( | |
jsx, | |
{ email, password }, | |
{ Slot }, // 2️⃣ а вот компонент для использования слотов | |
) => ( | |
<Form> | |
<div className="header"> | |
<h2><Slot name="title">Вход</Slot></h2> {/* 3️⃣ готово */ } | |
</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