Skip to content

Commit 2ec5810

Browse files
github-actions[bot]xristianstefanovdimodi
authored
Merge kb-modal-window-as-chat-popup-582 into production (#627)
* kb(window):added kb for chat popup * kb(grid):changed kb purpose * Update knowledge-base/window-modal-minimize-popup.md Co-authored-by: Dimo Dimov <[email protected]> * Update knowledge-base/window-modal-minimize-popup.md Co-authored-by: Dimo Dimov <[email protected]> * Update knowledge-base/window-modal-minimize-popup.md Co-authored-by: Dimo Dimov <[email protected]> * kb(window):changed example as per comment * kb(window):shortening the code snippet * kb(window):ternary operators changed position Co-authored-by: Hristian Stefanov <[email protected]> Co-authored-by: Hristian Stefanov <[email protected]> Co-authored-by: Dimo Dimov <[email protected]>
1 parent 509ebda commit 2ec5810

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed
346 KB
Loading
419 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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+
![](images/window-big-screen.gif)
37+
38+
>caption The result from the code snippet below on a small screen.
39+
40+
![](images/window-small-screen.gif)
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

Comments
 (0)