Skip to content

Instantly share code, notes, and snippets.

@RubaXa
Last active August 27, 2019 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RubaXa/c8c280d09c553532f481e19c298535be to your computer and use it in GitHub Desktop.
Save RubaXa/c8c280d09c553532f481e19c298535be to your computer and use it in GitHub Desktop.
TrueSlots
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