-
Notifications
You must be signed in to change notification settings - Fork 789
Open
Labels
a:language-slintCompiler for the .slint language (mO,bF)Compiler for the .slint language (mO,bF)rfcRequest for comments: proposals for changesRequest for comments: proposals for changes
Description
Vue.js has a slot concept.
The following code imagines how this concept could manifest in Slint:
component Page {
VerticalLayout {
Rectangle {
background: gray;
@children["header"] // Or `@children[0]`.
}
Rectangle {
border-width: 1px;
border-color: black;
VerticalLayout {
@children["body"]
// Or `@children[1]`.
// Or just `@children`, if it'd be named "default" (`slot`'s/`name`'s default value).
}
}
if @has-slot("footer") : {
SeparatorLine {}
@children["footer"] // Or `@children[2]`.
} else {
Text { text: "Fallback Footer"; }
}
}
}
export component Demo {
Page {
Text {
slot: "header"; // This property can be used on any element.
text: "The Header";
}
Slot {
name: "body";
Text { text: "Some Content"; }
Text { text: "More Content"; }
}
Slot {
name: "footer";
Text { text: "The Footer"; }
}
}
}This feature would allow for better abstractions.
This SlintPad demo shows the use case that made me desire the feature. Change the size of the preview to see what it's about. In my app, there are control buttons that must always be centered, no matter what's displayed to their left or right. To the left of the buttons, there may be informational Texts, right-aligned in their block (so, directly next to the buttons). The space to the right of the buttons is used to show error messages, if needed.
JoeJoeTV
Metadata
Metadata
Assignees
Labels
a:language-slintCompiler for the .slint language (mO,bF)Compiler for the .slint language (mO,bF)rfcRequest for comments: proposals for changesRequest for comments: proposals for changes