-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
HMILayout via slotchange #41
base: feature/add-tmplits-hmilayout
Are you sure you want to change the base?
HMILayout via slotchange #41
Conversation
}); | ||
|
||
if (+templatesIndex < divs.length) { | ||
divs[templatesIndex].setAttribute('slot', 'content') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The crux of this approach: setting this attribute causes this div to be displayed inside <div class="tmplit-main-content">
, because that div contains the content slot.
|
||
<template title="Button 2"> | ||
<div slot="list" title="Button 1"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some downsides to using divs here instead of templates (harder to of select only visible things)
{{!-- <h1>Cosntent 3</h1> --}} | ||
</div> | ||
|
||
<footer slot="footer"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using footer tag here for readability, and convenience of selection
navBarLoc ==='right' ? 'tmplit-navBar-container-right tmplit-navBar-container-width-size' : | ||
navBarLoc ==='top' ? 'tmplit-navBar-container-top tmplit-navBar-container-height-size' : | ||
navBarLoc ==='bottom' ? 'tmplit-navBar-container-bottom tmplit-navBar-container-height-size' : | ||
${navBarLoc === 'left' ? 'tmplit-navBar-container-left tmplit-navBar-container-width-size' : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines are my auto-formatter's doing, sorry.
What
This a proof of concept / alternative strategy for Sanh's project, for learning and discussion purposes.
This demo shows how to change which content goes into a slot dynamically, by changing the slot attribute's value on various content fed into the component.
Content is put into the component, representing tabbed content. These divs are marked with the attribute/value
slot="list"
. Selecting on this yields a list of pages to make navigation for.The component's template has a content slot set aside for the active page (
slot="content"
). When the buttons for various pages are selected, that then reassigns the slot attributes for the tabbed areas.This concept is based on MDN Web Components example "slotchange" https://github.com/mdn/web-components-examples/blob/main/slotchange/main.js
Why
Exploring other ways to "swap" what content goes into a given slot.