-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: out of band example using SectionContent and SectionOutlet comp…
…oents
- Loading branch information
Showing
6 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@inherits LayoutComponentBase | ||
<main class="container-fluid p-3"> | ||
<main class="container p-3"> | ||
@Body | ||
</main> |
37 changes: 37 additions & 0 deletions
37
samples/HtmxorExamples/Components/Pages/Examples/OutOfBandOutlets/Index.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@inherits ConditionalComponentBase | ||
@attribute [HtmxLayout(typeof(OutOfBandHtmxLayout), Priority = 1)] | ||
@layout OutOfBandMainLayout | ||
@page "/examples/out-of-band-outlets" | ||
@code { | ||
[SupplyParameterFromForm] | ||
private int CurrentCount { get; set; } = 0; | ||
|
||
private void IncrementCount(HtmxEventArgs args) | ||
{ | ||
CurrentCount++; | ||
} | ||
} | ||
<PageTitle>Htmxor - Examples - Out of Band Outlets</PageTitle> | ||
|
||
<p>This is an example of a counter updating and a element in the header also updating out of bounds.</p> | ||
|
||
<div id="counter" class="border p-3 d-inline-block text-center"> | ||
<HtmxPartial> | ||
<SectionContent SectionName="toast"> | ||
<span id="toasts" hx-swap-oob=@SwapStyles.OuterHTML class="text-warning"> | ||
The count is @(CurrentCount % 2 == 0 ? "even" : "odd")! | ||
</span> | ||
</SectionContent> | ||
|
||
<p role="status"> | ||
Current count: @CurrentCount | ||
</p> | ||
<button class="btn btn-primary" | ||
hx-put="/examples/out-of-band-outlets" | ||
hx-vals='{ "CurrentCount": @(CurrentCount) }' | ||
hx-target="#counter" | ||
@onput="IncrementCount"> | ||
Click me | ||
</button> | ||
</HtmxPartial> | ||
</div> |
3 changes: 3 additions & 0 deletions
3
samples/HtmxorExamples/Components/Pages/Examples/OutOfBandOutlets/OutOfBandHtmxLayout.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@inherits HtmxLayoutComponentBase | ||
<SectionOutlet SectionName="toast" /> | ||
@Body |
8 changes: 8 additions & 0 deletions
8
samples/HtmxorExamples/Components/Pages/Examples/OutOfBandOutlets/OutOfBandMainLayout.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@inherits LayoutComponentBase | ||
<header class="container p-3 bg-secondary text-white shadow"> | ||
This header contains content that can be updated out of bounds: | ||
<SectionOutlet SectionName="toast" /> | ||
</header> | ||
<main class="container p-3"> | ||
@Body | ||
</main> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters