For every level of detail it's possible to create a component. They can be re-used and nested endlessly.
function Welcome(props) {
return html`
<h1>Hello ${props.name}</h1>
`;
}
function App() {
return html`
<div>
<${Welcome} name="Sara" />
<${Welcome} name="Cahal" />
<${Welcome} name="Edite" />
</div>
`;
}
document.body.append(
html`
<${App} />
`
);
Try it on Codesandbox
function Comment(props) {
return html`
<div class="comment">
<${UserInfo} user=${props.author} />
<div class="comment-text">
${props.text}
</div>
<div class="comment-date">
${formatDate(props.date)}
</div>
</div>
`;
}
function UserInfo(props) {
return html`
<div class="userInfo">
<${Avatar} user=${props.user} />
<div class="userInfo-name">
${props.user.name}
</div>
</div>
`;
}
function Avatar(props) {
return html`
<img class="avatar" src=${props.user.avatarUrl} alt=${props.user.name} />
`;
}
Try it on Codesandbox