($"Size: {size}", options);
+ }
+}
\ No newline at end of file
diff --git a/samples/BlazorServer/Pages/_Layout.cshtml b/samples/BlazorServer/Pages/_Layout.cshtml
index 450625c6..304ad947 100644
--- a/samples/BlazorServer/Pages/_Layout.cshtml
+++ b/samples/BlazorServer/Pages/_Layout.cshtml
@@ -9,7 +9,6 @@
-
diff --git a/samples/BlazorServer/Shared/NavMenu.razor b/samples/BlazorServer/Shared/NavMenu.razor
index 80434503..50212a83 100644
--- a/samples/BlazorServer/Shared/NavMenu.razor
+++ b/samples/BlazorServer/Shared/NavMenu.razor
@@ -14,6 +14,11 @@
Home
+
+
+ Size
+
+
Styling
@@ -64,11 +69,6 @@
Custom Layout
-
-
- Scrollable Content
-
-
Custom Overlay
diff --git a/samples/BlazorServer/Shared/YesNoPromptAnimation.razor b/samples/BlazorServer/Shared/YesNoPromptAnimation.razor
index f12c799d..0e4c0ba6 100644
--- a/samples/BlazorServer/Shared/YesNoPromptAnimation.razor
+++ b/samples/BlazorServer/Shared/YesNoPromptAnimation.razor
@@ -13,7 +13,7 @@
async Task Yes()
{
- var options = new ModalOptions { Animation = new ModalAnimation(ModalAnimationType.FadeInOut, 5) };
+ var options = new ModalOptions { AnimationType = ModalAnimationType.FadeInOut };
var confirmationModal = ModalService.Show("Second Modal", options);
var result = await confirmationModal.Result;
diff --git a/samples/BlazorServer/wwwroot/css/site.css b/samples/BlazorServer/wwwroot/css/site.css
index dc4c68b3..69ea2189 100644
--- a/samples/BlazorServer/wwwroot/css/site.css
+++ b/samples/BlazorServer/wwwroot/css/site.css
@@ -34,6 +34,18 @@ a, .btn-link {
color: red;
}
+.my-custom-position .blazored-modal {
+ position: absolute;
+ top: 20%;
+ left: 10%;
+}
+
+.my-custom-size {
+ width: 88%;
+ margin-left: auto;
+ margin-right: auto;
+}
+
#blazor-error-ui {
background: lightyellow;
bottom: 0;
diff --git a/samples/BlazorWebAssembly/Pages/Animation.razor b/samples/BlazorWebAssembly/Pages/Animation.razor
index c317406a..ae99bdd8 100644
--- a/samples/BlazorWebAssembly/Pages/Animation.razor
+++ b/samples/BlazorWebAssembly/Pages/Animation.razor
@@ -5,7 +5,7 @@
- By default, the modal is shown without animation. The modal can be set to no animation, Fade in, Fade out or both.
+ By default, the modal is shown with a subtle fade in out animation. However, this can be disabled so the modal shows and hides immediately.
@@ -13,9 +13,9 @@
- @("var options = new ModalOptions() { Animation = ModalAnimation.FadeIn(2) };")
+ @("var options = new ModalOptions() { AnimationType = ModalAnimation.None };")
- @("Modal.Show(\"Animation: Fade-In\", options);")
+ @("Modal.Show(\"Animation Type: None\", options);")
@@ -26,48 +26,41 @@
-
-
- AnimationCustom(ModalAnimation.FadeIn(_duration)))" class="btn btn-secondary">Fade-In
- AnimationCustom(ModalAnimation.FadeOut(_duration)))" class="btn btn-secondary">Fade-Out
-Globally set value (default no animation)
- AnimationCustom(ModalAnimation.FadeInOut(_duration)))" class="btn btn-secondary">Fade-in Fade-Out
+Fade-in Fade-Out (Default)
+None
- It is also possible to have multiple modals (like in the Multiple Modals example) with different animations. With the below modal, the first modal will only fade-in with a duration of 2 seconds. The second modal will fade-in and fade-out in 5.0 seconds.
+ It is also possible to have multiple modals (like in the Multiple Modals example) with different animations. With the below modal, the first modal will appear without an animation. The second modal will fade-in and fade-out.
Multiple Modals
@code {
-
[CascadingParameter] public IModalService Modal { get; set; } = default!;
- private double _duration = 1.0;
-
void AnimationDefault()
{
Modal.Show("Default Animation");
}
- void AnimationCustom(ModalAnimation animation)
+ void NoAnimation()
{
- var options = new ModalOptions { Animation = animation };
+ var options = new ModalOptions { AnimationType = ModalAnimationType.None };
- Modal.Show($"Animation: {animation.Type}", options);
+ Modal.Show("Animation Type: None", options);
}
void MultipleModals()
{
var options = new ModalOptions
{
- Animation = ModalAnimation.FadeIn(2)
+ AnimationType = ModalAnimationType.None
};
Modal.Show("Multiple Modals", options);
diff --git a/samples/BlazorWebAssembly/Pages/Index.razor b/samples/BlazorWebAssembly/Pages/Index.razor
index 2b33472e..e976a76c 100644
--- a/samples/BlazorWebAssembly/Pages/Index.razor
+++ b/samples/BlazorWebAssembly/Pages/Index.razor
@@ -13,9 +13,7 @@
-
- @("Modal.Show(\"Welcome to Blazored Modal\", options);")
-
+ @("Modal.Show(\"Welcome to Blazored Modal\", options);")
diff --git a/samples/BlazorWebAssembly/Pages/Position.razor b/samples/BlazorWebAssembly/Pages/Position.razor
index c0bdb1e7..1e5c7efb 100644
--- a/samples/BlazorWebAssembly/Pages/Position.razor
+++ b/samples/BlazorWebAssembly/Pages/Position.razor
@@ -35,7 +35,8 @@
PositionCustom(ModalPosition.TopLeft))" class="btn btn-secondary">Top left
PositionCustom(ModalPosition.TopRight))" class="btn btn-secondary">Top right
-Center
+Top Center (Default)
+ PositionCustom(ModalPosition.Middle))" class="btn btn-secondary">Middle
PositionCustom(ModalPosition.BottomLeft))" class="btn btn-secondary">Bottom left
PositionCustom(ModalPosition.BottomRight))" class="btn btn-secondary">Bottom right
PositionCustom(ModalPosition.Custom))" class="btn btn-secondary">Custom
@@ -46,7 +47,7 @@
void PositionCenter()
{
- Modal.Show("Centered Modal (Default)");
+ Modal.Show("Top Center Modal (Default)");
}
void PositionCustom(ModalPosition position)
diff --git a/samples/BlazorWebAssembly/Pages/ScrollableContent.razor b/samples/BlazorWebAssembly/Pages/ScrollableContent.razor
deleted file mode 100644
index c54c75a3..00000000
--- a/samples/BlazorWebAssembly/Pages/ScrollableContent.razor
+++ /dev/null
@@ -1,52 +0,0 @@
-@page "/scrollablecontent"
-
-Scrollable Content
-
-
-
-
- By default, a modals content will not scroll if the contents height is greater than the viewports height.
- By setting ContentScrollable
to true
the Modal will include scroll bars allowing a user to scroll all the content.
-
-
-
-
-
-
-
- @("var options = new ModalOptions() { ContentScrollable = true };")
-
-
-
-
-
-
-
-ContentScrollable Enabled
-ContentScrollable Default
-
-@code {
-
- [CascadingParameter] public IModalService Modal { get; set; } = default!;
-
- void ContentScrollableEnabled()
- {
- var options = new ModalOptions { ContentScrollable = true };
-
- Modal.Show("Content Scrollable", options);
- }
-
- void ContentScrollableDefault()
- {
- Modal.Show("Default Setting");
- }
-}
\ No newline at end of file
diff --git a/samples/BlazorWebAssembly/Pages/Size.razor b/samples/BlazorWebAssembly/Pages/Size.razor
new file mode 100644
index 00000000..cc70de43
--- /dev/null
+++ b/samples/BlazorWebAssembly/Pages/Size.razor
@@ -0,0 +1,69 @@
+@page "/size"
+
+Sizing the modal
+
+
+
+
+ The modal has a default width. However, this can be changed by setting the Size
option.
+
+
+ There are 5 different sizes available:
+
+ Small - 300px
+ Medium - 500px (default)
+ Large - 800px
+ Extra Large - 1140px
+ Custom - Provide your own class, via the SizeCustomClass
parameter, which sets the width
+
+
+
+
+
+
+
+
+ @("var options = new ModalOptions() { Size = ModalSize.Large };")
+
+ @("Modal.Show(\"Size: Large\", options);")
+
+
+
+
+
+
+
+ SetSize(ModalSize.Small))" class="btn btn-secondary">Small
+Medium (default)
+ SetSize(ModalSize.Large))" class="btn btn-secondary">Large
+ SetSize(ModalSize.ExtraLarge))" class="btn btn-secondary">Extra Large
+ SetSize(ModalSize.Custom))" class="btn btn-secondary">Custom
+
+@code {
+
+ [CascadingParameter] public IModalService Modal { get; set; } = default!;
+
+ void DefaultSize()
+ {
+ Modal.Show("Size: Medium (Default)");
+ }
+
+ void SetSize(ModalSize size)
+ {
+ var options = new ModalOptions { Size = size };
+
+ if (size == ModalSize.Custom)
+ options.SizeCustomClass = "my-custom-size";
+
+ Modal.Show($"Size: {size}", options);
+ }
+}
\ No newline at end of file
diff --git a/samples/BlazorWebAssembly/Shared/CodeBlock.razor b/samples/BlazorWebAssembly/Shared/CodeBlock.razor
new file mode 100644
index 00000000..87b935e3
--- /dev/null
+++ b/samples/BlazorWebAssembly/Shared/CodeBlock.razor
@@ -0,0 +1,30 @@
+@inject IJSRuntime JsRuntime
+@implements IAsyncDisposable
+
+@ChildContent
+
+@code {
+ private IJSObjectReference? _codeBlockJs;
+ private ElementReference _codeBlock;
+
+ [Parameter, EditorRequired] public RenderFragment ChildContent { get; set; } = default!;
+ [Parameter] public string Language { get; set; } = "razor";
+
+ protected override async Task OnAfterRenderAsync(bool firstRender)
+ {
+ if (firstRender)
+ {
+ _codeBlockJs = await JsRuntime.InvokeAsync("import", "./Shared/CodeBlock.razor.js");
+ }
+
+ await _codeBlockJs!.InvokeVoidAsync("highlightCode", _codeBlock);
+ }
+
+ async ValueTask IAsyncDisposable.DisposeAsync()
+ {
+ if (_codeBlockJs is not null)
+ {
+ await _codeBlockJs.DisposeAsync();
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/BlazorWebAssembly/Shared/CodeBlock.razor.js b/samples/BlazorWebAssembly/Shared/CodeBlock.razor.js
new file mode 100644
index 00000000..99261f43
--- /dev/null
+++ b/samples/BlazorWebAssembly/Shared/CodeBlock.razor.js
@@ -0,0 +1,3 @@
+export function highlightCode(element) {
+ hljs.highlightElement(element);
+}
\ No newline at end of file
diff --git a/samples/BlazorWebAssembly/Shared/NavMenu.razor b/samples/BlazorWebAssembly/Shared/NavMenu.razor
index 77c03a08..ca296535 100644
--- a/samples/BlazorWebAssembly/Shared/NavMenu.razor
+++ b/samples/BlazorWebAssembly/Shared/NavMenu.razor
@@ -14,6 +14,11 @@
Home
+
+
+ Size
+
+
Styling
@@ -64,11 +69,6 @@
Custom Layout
-
-
- Scrollable Content
-
-
Custom Overlay
diff --git a/samples/BlazorWebAssembly/Shared/YesNoPromptAnimation.razor b/samples/BlazorWebAssembly/Shared/YesNoPromptAnimation.razor
index f12c799d..0e4c0ba6 100644
--- a/samples/BlazorWebAssembly/Shared/YesNoPromptAnimation.razor
+++ b/samples/BlazorWebAssembly/Shared/YesNoPromptAnimation.razor
@@ -13,7 +13,7 @@
async Task Yes()
{
- var options = new ModalOptions { Animation = new ModalAnimation(ModalAnimationType.FadeInOut, 5) };
+ var options = new ModalOptions { AnimationType = ModalAnimationType.FadeInOut };
var confirmationModal = ModalService.Show("Second Modal", options);
var result = await confirmationModal.Result;
diff --git a/samples/BlazorWebAssembly/wwwroot/css/app.css b/samples/BlazorWebAssembly/wwwroot/css/app.css
index 7157ee8f..ae1d2c17 100644
--- a/samples/BlazorWebAssembly/wwwroot/css/app.css
+++ b/samples/BlazorWebAssembly/wwwroot/css/app.css
@@ -34,6 +34,18 @@ a, .btn-link {
color: red;
}
+.my-custom-position .blazored-modal {
+ position: absolute;
+ top: 20%;
+ left: 10%;
+}
+
+.my-custom-size {
+ width: 88%;
+ margin-left: auto;
+ margin-right: auto;
+}
+
#blazor-error-ui {
background: lightyellow;
bottom: 0;
diff --git a/samples/BlazorWebAssembly/wwwroot/css/github.min.css b/samples/BlazorWebAssembly/wwwroot/css/github.min.css
new file mode 100644
index 00000000..275239a7
--- /dev/null
+++ b/samples/BlazorWebAssembly/wwwroot/css/github.min.css
@@ -0,0 +1,10 @@
+pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
+ Theme: GitHub
+ Description: Light theme as seen on github.com
+ Author: github.com
+ Maintainer: @Hirse
+ Updated: 2021-05-15
+
+ Outdated base version: https://github.com/primer/github-syntax-light
+ Current colors taken from GitHub's CSS
+*/.hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0}
\ No newline at end of file
diff --git a/samples/BlazorWebAssembly/wwwroot/index.html b/samples/BlazorWebAssembly/wwwroot/index.html
index 1cde15aa..b257b477 100644
--- a/samples/BlazorWebAssembly/wwwroot/index.html
+++ b/samples/BlazorWebAssembly/wwwroot/index.html
@@ -7,9 +7,9 @@
-
+
+
+