8 |
9 |
--------------------------------------------------------------------------------
/docs/src/templates/blazored/partials/toc.tmpl.partial:
--------------------------------------------------------------------------------
1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}}
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/docs/src/templates/blazored/partials/logo.tmpl.partial:
--------------------------------------------------------------------------------
1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}}
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/docs/src/templates/blazored/partials/_toc.liquid:
--------------------------------------------------------------------------------
1 | {% comment -%}Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.{% endcomment -%}
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/Blazored.Modal/ModalOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Blazored.Modal
2 | {
3 | public class ModalOptions
4 | {
5 | public ModalPosition? Position { get; set; }
6 | public string Class { get; set; }
7 | public bool? DisableBackgroundCancel { get; set; }
8 | public bool? HideHeader { get; set; }
9 | public bool? HideCloseButton { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/samples/BlazorServer/Shared/MainLayout.razor:
--------------------------------------------------------------------------------
1 | @inherits LayoutComponentBase
2 |
3 |
4 |
5 |
18 |
--------------------------------------------------------------------------------
/docs/src/templates/blazored/partials/scripts.tmpl.partial:
--------------------------------------------------------------------------------
1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}}
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/docs/src/templates/blazored/partials/searchResults.tmpl.partial:
--------------------------------------------------------------------------------
1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}}
2 |
3 |
21 |
22 |
23 |
24 | @code {
25 |
26 | void ShowModal() => Modal.Show("Welcome to Blazored Modal");
27 |
28 | }
--------------------------------------------------------------------------------
/docs/src/templates/blazored/partials/_navbar.liquid:
--------------------------------------------------------------------------------
1 | {% comment -%}Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.{% endcomment -%}
2 |
15 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: "[Feature Request]"
5 | labels: Feature Request, Triage
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/samples/BlazorServer/Shared/YesNoPrompt.razor:
--------------------------------------------------------------------------------
1 | @inject IModalService ModalService
2 |
3 |
9 | It is possible to show multiple modals at the same time. Each new modal needs to be shown from the currently active modal.
10 | In this example an initial confirmation modal is shown, if you select Yes then a second confirmation modal is shown.
11 | When you Close the second modal both modals will be closed. If you Cancel the second modal, only the second
12 | modal will be closed.
13 |
9 | It is possible to show multiple modals at the same time. Each new modal needs to be shown from the currently active modal.
10 | In this example an initial confirmation modal is shown, if you select Yes then a second confirmation modal is shown.
11 | When you Close the second modal both modals will be closed. If you Cancel the second modal, only the second
12 | modal will be closed.
13 |
14 |
15 |
16 |
17 | @code {
18 |
19 | void ShowModal() => Modal.Show("First Modal");
20 |
21 | }
--------------------------------------------------------------------------------
/samples/BlazorServer/Pages/_Host.cshtml:
--------------------------------------------------------------------------------
1 | @page "/"
2 | @namespace BlazorServer.Pages
3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4 |
5 |
6 |
7 |
8 |
9 |
10 | Blazored Modal (Server)
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | @(await Html.RenderComponentAsync(RenderMode.ServerPrerendered))
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Blazored.Modal/Services/ModalResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Blazored.Modal.Services
4 | {
5 | public class ModalResult
6 | {
7 | public object Data { get; }
8 | public Type DataType { get; }
9 | public bool Cancelled { get; }
10 |
11 | protected ModalResult(object data, Type resultType, bool cancelled)
12 | {
13 | Data = data;
14 | DataType = resultType;
15 | Cancelled = cancelled;
16 | }
17 |
18 | public static ModalResult Ok(T result) => Ok(result, default);
19 |
20 | public static ModalResult Ok(T result, Type modalType) => new ModalResult(result, modalType, false);
21 |
22 | public static ModalResult Cancel() => new ModalResult(default, typeof(object), true);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: "[Bug]"
5 | labels: Bug, Triage
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Hosting Model (is this issue happening with a certain hosting model?):**
27 | - Blazor Server
28 | - Blazor WebAssembly
29 | - etc...
30 |
31 | **Additional context**
32 | Add any other context about the problem here.
33 |
--------------------------------------------------------------------------------
/samples/BlazorServer/Shared/MessageForm.razor:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | @code {
13 |
14 | [CascadingParameter] BlazoredModalInstance BlazoredModal { get; set; }
15 |
16 | string Message { get; set; }
17 |
18 | protected override void OnInitialized() => BlazoredModal.SetTitle("Enter a Message");
19 |
20 | void SubmitForm() => BlazoredModal.Close(ModalResult.Ok(Message));
21 | void Cancel() => BlazoredModal.Cancel();
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/docs/src/usage/long-running-task.md:
--------------------------------------------------------------------------------
1 | # Long running task
2 | How to open a modal, execute a long-running task and close the modal after it.
3 |
4 | ---
5 |
6 | We can open a modal and using its `ModalReference` we can also close it from outside of the actual Modal itself.
7 |
8 | ```html
9 |
10 |
11 | @code {
12 |
13 | string _message;
14 |
15 | async Task ShowModal()
16 | {
17 | var loadingModal = Modal.Show();
18 |
19 | await Task.Delay(5000); //Do your long running task, here we just wait 5 seconds
20 |
21 | loadingModal.Close();
22 |
23 | var result = await loadingModal.Result;
24 | //Do something with the result.
25 | //In this case we won't as we just showed a loading dialog
26 | }
27 |
28 | }
29 | ```
--------------------------------------------------------------------------------
/samples/BlazorWebAssembly/Shared/MessageForm.razor:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | @code {
13 |
14 | [CascadingParameter] BlazoredModalInstance BlazoredModal { get; set; }
15 |
16 | string Message { get; set; }
17 |
18 | protected override void OnInitialized() => BlazoredModal.SetTitle("Enter a Message");
19 |
20 | void SubmitForm() => BlazoredModal.Close(ModalResult.Ok(Message));
21 | void Cancel() => BlazoredModal.Cancel();
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/tests/src/Blazored.Modal.Tests/Assets/MockNavigationManager.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Components;
2 |
3 | namespace Blazored.Modal.Tests.Assets
4 | {
5 | internal class MockNavigationManager : NavigationManager
6 | {
7 | public MockNavigationManager()
8 | {
9 | }
10 |
11 | public MockNavigationManager(string baseUri = null, string uri = null)
12 | {
13 | Initialize(baseUri ?? "http://example.com/", uri ?? baseUri ?? "http://example.com/welcome-page");
14 | }
15 |
16 | public new void Initialize(string baseUri, string uri)
17 | {
18 | base.Initialize(baseUri, uri);
19 | }
20 |
21 | protected override void NavigateToCore(string uri, bool forceLoad)
22 | {
23 | throw new System.NotImplementedException();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/tests/src/Blazored.Modal.Tests/Blazored.Modal.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/BlazorWebAssembly/BlazorWebAssembly.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.1
5 | 3.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/docs/src/usage/returning-data-from-modals.md:
--------------------------------------------------------------------------------
1 | # Returning Data From Modals
2 | How to return data from the component being displayed in the modal.
3 |
4 | ---
5 |
6 | Data can be returned from a modal by using the `ModalResult.Data` property. You can return simple strings as well as complex objects. In the example below, you can add a message in the modal that will be show here when you close the modal.
7 |
8 | ```html
9 |
10 |
11 | @if (!string.IsNullOrWhiteSpace(_message))
12 | {
13 |
Your message was:
14 |
@_message
15 | }
16 |
17 | @code {
18 |
19 | string _message;
20 |
21 | async Task ShowModal()
22 | {
23 | var messageForm = Modal.Show();
24 | var result = await messageForm.Result;
25 |
26 | if (!result.Cancelled)
27 | _message = result.Data.ToString();
28 | }
29 |
30 | }
31 | ```
--------------------------------------------------------------------------------
/docs/src/docfx.json:
--------------------------------------------------------------------------------
1 | {
2 | "build": {
3 | "content": [
4 | {
5 | "files": [
6 | "**/*.md",
7 | "**/*.yml"
8 | ],
9 | "exclude": [
10 | "obj/**",
11 | "_site/**"
12 | ],
13 | "src": "."
14 | }
15 | ],
16 | "resource": [
17 | {
18 | "files": [
19 | "images/**"
20 | ]
21 | }
22 | ],
23 | "dest": "_site",
24 | "globalMetadata": {
25 | "_gitContribute": {
26 | "repo": "https://github.com/blazored/modal.git",
27 | "branch": "master"
28 | }
29 | },
30 | "fileMetadataFiles": [],
31 | "template": [
32 | "default",
33 | "templates/blazored"
34 | ],
35 | "postProcessors": [],
36 | "markdownEngineName": "markdig",
37 | "noLangKeyword": false,
38 | "keepFileLink": false,
39 | "cleanupCacheHistory": false,
40 | "disableGitFeatures": false
41 | }
42 | }
--------------------------------------------------------------------------------
/docs/src/customisation-options/class.md:
--------------------------------------------------------------------------------
1 | # Class
2 | How to customise the look of modals.
3 |
4 | ---
5 |
6 | Blazored Modal comes with a default look and feel which is deliberately plain. If you want to customise how the modal looks to match the rest of your application you can set a top level class and then use CSS selectors to add custom styles.
7 |
8 | ## Setting Class Globally
9 |
10 | To set a global class for all modals in your application, you can set the `Class` parameter on the `BlazoredModal` component in your `MainLayout`.
11 |
12 | ```html
13 | @inherits LayoutComponentBase
14 |
15 |
16 |
17 |
18 | ```
19 |
20 | ## Setting Class Per Modal
21 |
22 | To set the class of a specific modal instance you can pass in a `ModalOptions` object when calling `Show`.
23 |
24 | ```csharp
25 | var options = new ModalOptions { Class = "my-custom-class" };
26 |
27 | _ = Modal.Show("My Modal", options);
28 | ```
29 |
30 |
--------------------------------------------------------------------------------
/docs/src/templates/blazored/partials/affix.tmpl.partial:
--------------------------------------------------------------------------------
1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}}
2 |
3 |
28 |
--------------------------------------------------------------------------------
/docs/src/templates/blazored/partials/_affix.liquid:
--------------------------------------------------------------------------------
1 | {% comment -%}Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.{% endcomment -%}
2 |
25 |
--------------------------------------------------------------------------------
/docs/src/customisation-options/hide-header.md:
--------------------------------------------------------------------------------
1 | # Hide Header
2 | How to control visibility of the modal header.
3 |
4 | ---
5 |
6 | By default, the modal has a header which displays the title you specify when you call `Show`. However, you can choose to hide this header to give the modal a more compact look. Just set the `HideHeader` option to `true`.
7 |
8 | ## Setting HideHeader Globally
9 |
10 | To control the visibility of the header globally for all modals in your application, you can set the `HideHeader` parameter on the `BlazoredModal` component in your `MainLayout`.
11 |
12 | ```html
13 | @inherits LayoutComponentBase
14 |
15 |
16 |
17 |
18 | ```
19 |
20 | ## Setting HideHeader Per Modal
21 |
22 | To set the visibility of the header for a specific modal instance you can pass in a `ModalOptions` object when calling `Show`.
23 |
24 | ```csharp
25 | var options = new ModalOptions { HideHeader = true };
26 |
27 | _ = Modal.Show("My Modal", options);
28 | ```
29 |
--------------------------------------------------------------------------------
/docs/src/customisation-options/disable-background-cancel.md:
--------------------------------------------------------------------------------
1 | # Disable Background Cancel
2 | How to control the background cancel feature.
3 |
4 | ---
5 |
6 | By default, a modal is cancelled if the user clicks anywhere outside the modal. This behaviour can be disabled by setting `DisableBackgroundCancel` to `true`.
7 |
8 | ## Setting DisableBackgroundCancel Globally
9 |
10 | To control background cancel globally for all modals in your application, you can set the `DisableBackgroundCancel` parameter on the `BlazoredModal` component in your `MainLayout`.
11 |
12 | ```html
13 | @inherits LayoutComponentBase
14 |
15 |
16 |
17 |
18 | ```
19 |
20 | ## Setting DisableBackgroundCancel Per Modal
21 |
22 | To set the background cancel of a specific modal instance you can pass in a `ModalOptions` object when calling `Show`.
23 |
24 | ```csharp
25 | var options = new ModalOptions { DisableBackgroundCancel = true };
26 |
27 | _ = Modal.Show("My Modal", options);
28 | ```
29 |
--------------------------------------------------------------------------------
/docs/src/customisation-options/hide-close-button.md:
--------------------------------------------------------------------------------
1 | # Hide Close Button
2 | How to control visibility of the close button.
3 |
4 | ---
5 |
6 | By default, a close button is shown in the top right of the modal. If you prefer, the button can be hidden and you can handle closing the modal yourself by setting `HideCloseButton` to `true`.
7 |
8 | ## Setting HideCloseButton Globally
9 |
10 | To control the visibility of the close button globally for all modals in your application, you can set the `HideCloseButton` parameter on the `BlazoredModal` component in your `MainLayout`.
11 |
12 | ```html
13 | @inherits LayoutComponentBase
14 |
15 |
16 |
17 |
18 | ```
19 |
20 | ## Setting HideCloseButton Per Modal
21 |
22 | To set the visibility of the close button for a specific modal instance you can pass in a `ModalOptions` object when calling `Show`.
23 |
24 | ```csharp
25 | var options = new ModalOptions { HideCloseButton = true };
26 |
27 | _ = Modal.Show("My Modal", options);
28 | ```
29 |
--------------------------------------------------------------------------------
/docs/src/usage/toc.yml:
--------------------------------------------------------------------------------
1 | - name: Home
2 | href: ../index.md
3 | - name: Getting Started
4 | items:
5 | - name: Installation
6 | href: ../getting-started/installation.md
7 | - name: Basic Usage
8 | href: ../getting-started/basic-usage.md
9 | - name: Usage Scenarios
10 | items:
11 | - name: Passing Data To Modals
12 | href: passing-data-to-modals.md
13 | - name: Returning Data From Modals
14 | href: returning-data-from-modals.md
15 | - name: Multiple Modals
16 | href: multiple-modals.md
17 | - name: Long-running Tasks
18 | href: long-running-task.md
19 | - name: Customisation Options
20 | items:
21 | - name: Position
22 | href: ../customisation-options/position.md
23 | - name: Class
24 | href: ../customisation-options/class.md
25 | - name: Disable Background Cancel
26 | href: ../customisation-options/disable-background-cancel.md
27 | - name: Hide Header
28 | href: ../customisation-options/hide-header.md
29 | - name: Hide Close Button
30 | href: ../customisation-options/hide-close-button.md
--------------------------------------------------------------------------------
/docs/src/getting-started/toc.yml:
--------------------------------------------------------------------------------
1 | - name: Home
2 | href: ../index.md
3 | - name: Getting Started
4 | items:
5 | - name: Installation
6 | href: installation.md
7 | - name: Basic Usage
8 | href: basic-usage.md
9 | - name: Usage Scenarios
10 | items:
11 | - name: Passing Data To Modals
12 | href: ../usage/passing-data-to-modals.md
13 | - name: Returning Data From Modals
14 | href: ../usage/returning-data-from-modals.md
15 | - name: Multiple Modals
16 | href: ../usage/multiple-modals.md
17 | - name: Long-running Tasks
18 | href: ../usage/long-running-task.md
19 | - name: Customisation Options
20 | items:
21 | - name: Position
22 | href: ../customisation-options/position.md
23 | - name: Class
24 | href: ../customisation-options/class.md
25 | - name: Disable Background Cancel
26 | href: ../customisation-options/disable-background-cancel.md
27 | - name: Hide Header
28 | href: ../customisation-options/hide-header.md
29 | - name: Hide Close Button
30 | href: ../customisation-options/hide-close-button.md
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Blazored
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/docs/src/customisation-options/position.md:
--------------------------------------------------------------------------------
1 | # Position
2 | How to customise where modals are displayed.
3 |
4 | ---
5 |
6 | By default, modals are shown in the center of the viewport. However, you can customise where modals are shown using the `ModalOptions.Position` setting. The available options are `Center`, `TopLeft`, `TopRight`, `BottomLeft` and `BottomRight`. You can define this setting both at a global level, to effect all modals, or on a modal by modal basis.
7 |
8 | ## Setting Position Globally
9 |
10 | To set a global default position for all modals in your application, you can set the `Position` parameter on the `BlazoredModal` component in your `MainLayout`.
11 |
12 | ```html
13 | @inherits LayoutComponentBase
14 |
15 |
16 |
17 |
18 | ```
19 |
20 | ## Setting Position Per Modal
21 |
22 | To set the position of a specific modal instance you can pass in a `ModalOptions` object when calling `Show`.
23 |
24 | ```csharp
25 | var options = new ModalOptions { Position = ModalPosition.TopRight };
26 |
27 | _ = Modal.Show("My Modal", options);
28 | ```
29 |
--------------------------------------------------------------------------------
/src/Blazored.Modal/ModalParameters.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Blazored.Modal
4 | {
5 | public class ModalParameters
6 | {
7 | internal Dictionary _parameters;
8 |
9 | public ModalParameters()
10 | {
11 | _parameters = new Dictionary();
12 | }
13 |
14 | public void Add(string parameterName, object value)
15 | {
16 | _parameters[parameterName] = value;
17 | }
18 |
19 | public T Get(string parameterName)
20 | {
21 | if (_parameters.TryGetValue(parameterName, out var value))
22 | {
23 | return (T)value;
24 | }
25 |
26 | throw new KeyNotFoundException($"{parameterName} does not exist in modal parameters");
27 | }
28 |
29 | public T TryGet(string parameterName)
30 | {
31 | if (_parameters.TryGetValue(parameterName, out var value))
32 | {
33 | return (T)value;
34 | }
35 |
36 | return default;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/samples/BlazorServer/wwwroot/css/open-iconic/ICON-LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Waybury
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/samples/BlazorWebAssembly/wwwroot/css/open-iconic/ICON-LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Waybury
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/samples/BlazorServer/Pages/CustomStyle.razor:
--------------------------------------------------------------------------------
1 | @page "/custom"
2 | @inject IModalService Modal
3 |
4 |
Custom Styling
5 |
6 |
7 |
8 |
9 | Custom CSS classes can be set globally or on a per modal basis to change the look of modals.
10 |
9 | Data can be returned from a modal by using the ModalResult.Data property. You can return simple strings as well as complex objects.
10 | In the example below, you can add a message in the modal that will be show here when you close the modal.
11 |
9 | Data can be returned from a modal by using the ModalResult.Data property. You can return simple strings as well as complex objects.
10 | In the example below, you can add a message in the modal that will be show here when you close the modal.
11 |
9 | Data can be passed to a modal by using the ModalParameters object. The items you add to this collection must match the parameters
10 | defined on the component being displayed in the modal. In the example below, you can type a message and see it displayed in the modal.
11 |
9 | Data can be passed to a modal by using the ModalParameters object. The items you add to this collection must match the parameters
10 | defined on the component being displayed in the modal. In the example below, you can type a message and see it displayed in the modal.
11 |
35 |
36 |
37 |
38 |
39 | @code {
40 |
41 | void CloseButtonShown()
42 | {
43 | Modal.Show("Showing Close Button (default)");
44 | }
45 |
46 | void CloseButtonHidden()
47 | {
48 | var options = new ModalOptions { HideCloseButton = true };
49 | Modal.Show("Hiding Close Button", options);
50 | }
51 | }
--------------------------------------------------------------------------------
/docs/src/templates/blazored/partials/_head.liquid:
--------------------------------------------------------------------------------
1 | {% comment -%}Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.{% endcomment -%}
2 |
3 |
4 |
5 | {%- if title and _appTitle -%}
6 | {{title}} | {{appTitle}}
7 |
8 | {%- else -%}
9 | {%- if title or _appTitle -%}
10 | {{title}}{{appTitle}}
11 |
12 | {%- endif -%}
13 | {%- endif -%}
14 |
15 |
16 | {%- if _description -%}
17 |
18 | {%- endif -%}
19 | {%- if _appFaviconPath -%}
20 |
21 | {%- else -%}
22 |
23 | {%- endif -%}
24 |
25 |
26 |
27 |
28 |
29 | {%- if _noindex -%}
30 |
31 | {%- endif -%}
32 | {%- if _enableSearch -%}
33 |
34 | {%- endif -%}
35 | {%- if _enableNewTab -%}
36 |
37 | {%- endif -%}
38 |
39 |
--------------------------------------------------------------------------------
/samples/BlazorServer/Pages/BackgroundCancel.razor:
--------------------------------------------------------------------------------
1 | @page "/backgroundcancel"
2 | @inject IModalService Modal
3 |
4 |
Background Click
5 |
6 |
7 |
8 |
9 | By default, a modal is cancelled if the user clicks anywhere outside the modal. This behavior can
10 | be disabled by setting DisableBackgroundCancel to true.
11 |
9 | By default, a modal is cancelled if the user clicks anywhere outside the modal. This behavior can
10 | be disabled by setting DisableBackgroundCancel to true.
11 |
50 | {{>partials/scripts}}
51 |
52 |
53 |
--------------------------------------------------------------------------------
/docs/src/usage/passing-data-to-modals.md:
--------------------------------------------------------------------------------
1 | # Passing Data To Modals
2 | How to pass data into the component being displayed in the modal.
3 |
4 | ---
5 |
6 | Data can be passed to a component displayed in a modal by using the `ModalParameters` class. Once you create an instance, you can add values to it via the `Add` method which takes two arguments, `parameterName` and `value`. The `parameterName` must match the name of a parameter on the component being displayed in the modal.
7 |
8 | Lets look at an example.
9 |
10 | If we wanted to display a modal containing the following `DisplayMessage` component.
11 |
12 | ```html
13 |
14 |
15 |
@Message
16 |
17 |
18 |
19 |
20 |
21 | @code {
22 |
23 | [CascadingParameter] BlazoredModalInstance BlazoredModal { get; set; }
24 |
25 | [Parameter] public string Message { get; set; }
26 |
27 | void SubmitForm() => BlazoredModal.Close();
28 | void Cancel() => BlazoredModal.Close();
29 |
30 | }
31 | ```
32 |
33 | We can pass a value for the `Message` parameter like this.
34 |
35 | ```html
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | @code {
44 |
45 | string _message;
46 |
47 | async Task ShowModal()
48 | {
49 | var parameters = new ModalParameters();
50 | parameters.Add(nameof(DisplayMessage.Message), _message);
51 |
52 | _ = Modal.Show("Passing Data", parameters);
53 | }
54 |
55 | }
56 | ```
57 |
58 | **Note:** The use of `nameof` is recommended, where possible, to give a bit of compile time help when referencing parameters on components.
--------------------------------------------------------------------------------
/docs/src/usage/multiple-modals.md:
--------------------------------------------------------------------------------
1 | # Multiple Modals
2 | How to show multiple modals at once.
3 |
4 | ---
5 |
6 | It is possible to show multiple modals at the same time. Each new modal needs to be shown from the currently active modal. In this example an inital confirmation modal is shown, if you select *Yes* then a second confirmation modal is shown. When you `Close` the second modal both modals will be closed. If you `Cancel` the second modal, only the second modal will be closed.
7 |
8 | ```html
9 |
10 |
11 | @code {
12 |
13 | void ShowModal() => Modal.Show("First Modal");
14 |
15 | }
16 | ```
17 |
18 | ```html
19 |
9 | By default, the modal is shown in the center of the viewport. The modal can be shown
10 | in a number of different positions by setting the Position option.
11 |
9 | By default, the modal is shown in the center of the viewport. The modal can be shown
10 | in a number of different positions by setting the Position option.
11 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | @code {
44 |
45 | void PositionCenter()
46 | {
47 | Modal.Show("Centered Modal (Default)");
48 | }
49 |
50 | void PositionCustom(ModalPosition position)
51 | {
52 | var options = new ModalOptions { Position = position };
53 |
54 | Modal.Show($"Position: {position}", options);
55 | }
56 | }
--------------------------------------------------------------------------------
/docs/src/templates/blazored/partials/navbar.tmpl.partial:
--------------------------------------------------------------------------------
1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}}
2 |
3 |
30 |
--------------------------------------------------------------------------------
/docs/src/getting-started/installation.md:
--------------------------------------------------------------------------------
1 | # Getting Started
2 | How to get up and running with Blazored Modal.
3 |
4 | ---
5 |
6 | ## 1. Installation
7 | You can install the package via the nuget package manager just search for *Blazored.Modal*. You can also install via powershell using the following command.
8 |
9 | ```powershell
10 | Install-Package Blazored.Modal
11 | ```
12 |
13 | Or via the dotnet CLI.
14 |
15 | ```bash
16 | dotnet add package Blazored.Modal
17 | ```
18 |
19 | ## 2. Register Services
20 |
21 | ### Blazor Server
22 | You will need to add the following using statement and add a call to register the Blazored Modal services in your applications `Startup.ConfigureServices` method.
23 |
24 | ```csharp
25 | using Blazored.Modal;
26 |
27 | public void ConfigureServices(IServiceCollection services)
28 | {
29 | services.AddBlazoredModal();
30 | }
31 | ```
32 |
33 | ### Blazor WebAssembly
34 | You will need to add the following using statement and add a call to register the Blazored Modal services in your applications `Program.Main` method.
35 |
36 | ```csharp
37 | using Blazored.Modal;
38 |
39 | public static async Task Main(string[] args)
40 | {
41 | var builder = WebAssemblyHostBuilder.CreateDefault(args);
42 | builder.RootComponents.Add("app");
43 |
44 | builder.Services.AddBlazoredModal();
45 |
46 | await builder.Build().RunAsync();
47 | }
48 | ```
49 |
50 | ## 3. Reference Stylesheet
51 |
52 | Add the following line to the `head` tag of your `_Host.cshtml` (Blazor Server) or `index.html` (Blazor WebAssembly).
53 |
54 | ```html
55 |
56 | ```
57 |
58 | ## 4. Add Component To Layout
59 |
60 | Add the `BlazoredModal` component to your applications `MainLayout.razor`.
61 |
62 | ```html
63 | @inherits LayoutComponentBase
64 |
65 |
66 |
67 |
68 | ```
69 |
70 | ## 5. Import Namespaces (optional)
71 |
72 | To make life a little easier you can add the following using statements to your root `_Imports.razor`. This save you having to reference the fully qualified name of Blazored Modal components and services in your components.
73 |
74 | ```razor
75 | @using Blazored
76 | @using Blazored.Modal
77 | @using Blazored.Modal.Services
78 | ```
--------------------------------------------------------------------------------
/samples/BlazorServer/Shared/NavMenu.razor:
--------------------------------------------------------------------------------
1 |