An app defines a layout within its response method and uses the yield_page method to yield the content of a page in its layout.
Use core components
app/matestack/example_app/app.rb
classExampleApp::App<Matestack::Ui::Appdefresponse heading size: 1, text: "My Example App Layout"endend
Use registered custom components
Imagine having created and registered a custom component card. Go ahead and use it on your page:
app/matestack/example_app/pages/example_page.rb
classExampleApp::Pages<Matestack::Ui::Pagedefresponse heading size: 1, text: "My Example App Layout"# calling your registered card component without using matestack_component helper! card title: "hello"endend
Yielding Matestack pages
app/matestack/example_app/app.rb
classExampleApp::App<Matestack::Ui::Appdefresponse heading size: 1, text: "My Example App Layout" main do#yield_page is a core method which yields the page and enables dynamic transitions#it can be placed anywhere in your layout yield_pageendendend
Transitions between pages without page reload
app/matestack/example_app/app.rb
classExampleApp::App<Matestack::Ui::Appdefresponse heading size: 1, text: "My Example App Layout" nav do transition path: :app_specs_page1_path do button text: "Page 1"end transition path: :app_specs_page2_path do button text: "Page 2"endend main do yield_pageendendend
The transition components will trigger async HTTP requests and exchange the page content without a page reload.
Transitions between pages with loading element
app/matestack/example_app/app.rb
classExampleApp::App<Matestack::Ui::Appdefresponse#... main do yield_page slots: { loading_state: my_loading_state_slot }end#...enddefmy_loading_state_slot slot do span class: "some-loading-spinner"do plain "loading..."endendendend
which will render:
<main>
<div class="matestack-page-container">
<div class="loading-state-element-wrapper">
<span class="some-loading-spinner">
loading...
</span>
</div>
<div class="matestack-page-wrapper">
<div><!--this div is necessary for conditonal switch to async template via v-if -->
<div class="matestack-page-root">
your page markup
</div>
</div>
</div>
</div>
</end>
and during async page request triggered via transition:
<main>
<div class="matestack-page-container loading">
<div class="loading-state-element-wrapper loading">
<span class="some-loading-spinner">
loading...
</span>
</div>
<div class="matestack-page-wrapper loading">
<div><!--this div is necessary for conditonal switch to async template via v-if -->
<div class="matestack-page-root">
your page markup
</div>
</div>
</div>
</div>
</end>
You can use the loading class and your loading state element to implement CSS based loading state effects. It may look like this (scss):