|
| 1 | +--- |
| 2 | +title: How to minimize a popup window to the bottom of the page? |
| 3 | +description: |
| 4 | +type: how-to |
| 5 | +page_title: How to minimize a popup window to the bottom of the page? |
| 6 | +slug: window-modal-minimize-popup |
| 7 | +position: |
| 8 | +tags: window,modal,popup,collapse,minimize |
| 9 | +ticketid: 1542823 |
| 10 | +res_type: kb |
| 11 | +--- |
| 12 | + |
| 13 | +## Environment |
| 14 | +<table> |
| 15 | + <tbody> |
| 16 | + <tr> |
| 17 | + <td>Product</td> |
| 18 | + <td>Window for Blazor</td> |
| 19 | + </tr> |
| 20 | + </tbody> |
| 21 | +</table> |
| 22 | + |
| 23 | + |
| 24 | +## Description |
| 25 | +Is there any way to collapse a window to the bottom of a page? How to create a responsive modal that can be minimized? How to minimize Modal Window as a chat for messages? |
| 26 | + |
| 27 | +## Solution |
| 28 | +To implement a responsible popup that can be minimized to the bottom of the page: |
| 29 | + |
| 30 | +1. Set the `Top` and `Left` parameters to control the position of the modal. |
| 31 | +2. Use boolean flags to show and hide the popup. |
| 32 | +3. Use the [MediaQuery](https://docs.telerik.com/blazor-ui/components/mediaquery/overview) component to make the modal window responsive. |
| 33 | + |
| 34 | +>caption The result from the code snippet below on a big screen. |
| 35 | +
|
| 36 | + |
| 37 | + |
| 38 | +>caption The result from the code snippet below on a small screen. |
| 39 | +
|
| 40 | + |
| 41 | + |
| 42 | +````Razor |
| 43 | +@*Responsive minimizable popup.*@ |
| 44 | +
|
| 45 | +<TelerikMediaQuery Media="(max-width: 960px)" OnChange="((changed) => Small = changed)"></TelerikMediaQuery> |
| 46 | +
|
| 47 | +<TelerikWindow Class="@myClass" Modal="@isModal" |
| 48 | + Top="@TopPosition" |
| 49 | + Left="@LeftPosition" |
| 50 | + @bind-Visible="@isModalVisible"> |
| 51 | + <WindowTitle> |
| 52 | + <strong>@Title</strong> |
| 53 | + </WindowTitle> |
| 54 | + <WindowContent> |
| 55 | + @if (isModal) |
| 56 | + { |
| 57 | + @Content |
| 58 | + } |
| 59 | + </WindowContent> |
| 60 | + <WindowActions> |
| 61 | + <WindowAction Name="MyMinimizer" Hidden="@(!isModal)" Icon="window-minimize" OnClick="@MyCustomMinimize" /> |
| 62 | + <WindowAction Name="MyExpander" Hidden="@isModal" Icon="window" OnClick="@MyCustomExpand" /> |
| 63 | + </WindowActions> |
| 64 | +</TelerikWindow> |
| 65 | +
|
| 66 | +@code { |
| 67 | + bool isModalVisible { get; set; } = true; |
| 68 | + bool isModal { get; set; } = true; |
| 69 | + private bool Small { get; set; } |
| 70 | +
|
| 71 | + string Title => Small == true && !isModal ? "M" : "My Responsive Popup"; |
| 72 | + string Content = "---------- Welcome to our Minimized/Collapsed popup! ----------"; |
| 73 | + string TopPosition => Small == true && !isModal ? "100px" : Top; |
| 74 | + string LeftPosition => Small == true && !isModal ? "300px" : Left; |
| 75 | + string Top = "40%"; |
| 76 | + string Left = "40%"; |
| 77 | +
|
| 78 | + string myClass => Small == true && !isModal ? "minimized" : ""; |
| 79 | +
|
| 80 | + public void MyCustomMinimize() |
| 81 | + { |
| 82 | + Top = "90%"; |
| 83 | + Left = "15%"; |
| 84 | + isModal = false; |
| 85 | + StateHasChanged(); |
| 86 | + } |
| 87 | +
|
| 88 | + public void MyCustomExpand() |
| 89 | + { |
| 90 | + Top = "40%"; |
| 91 | + Left = "40%"; |
| 92 | + isModal = true; |
| 93 | + StateHasChanged(); |
| 94 | + } |
| 95 | +} |
| 96 | +
|
| 97 | +@if (!isModal) |
| 98 | +{ |
| 99 | + <style> |
| 100 | + .k-window-content:last-child { |
| 101 | + display: none; |
| 102 | + } |
| 103 | +
|
| 104 | + .k-window-titlebar { |
| 105 | + border-style: none; |
| 106 | + } |
| 107 | +
|
| 108 | + .minimized { |
| 109 | + background-color: #ff6358; |
| 110 | + color: white; |
| 111 | + display: inline; |
| 112 | + padding: 14px; |
| 113 | + border-bottom-left-radius: 65%; |
| 114 | + border-bottom-right-radius: 65%; |
| 115 | + border-top-left-radius: 65%; |
| 116 | + border-top-right-radius: 65%; |
| 117 | + } |
| 118 | + </style> |
| 119 | +} |
| 120 | +```` |
0 commit comments