Skip to content

Commit 3631a47

Browse files
authored
docs(popup): Improve Overview examples (#2338)
1 parent 247ba7f commit 3631a47

File tree

1 file changed

+41
-16
lines changed

1 file changed

+41
-16
lines changed

components/popup/overview.md

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,32 @@ The <a href = "https://www.telerik.com/blazor-ui/popup" target="_blank">Blazor P
1515
## Creating Blazor Popup
1616

1717
1. Add the `<TelerikPopup>` tag to a Razor file.
18-
1. Obtain the component reference through `@ref`.
19-
1. Use the [Show](#popup-reference-and-methods) method to display the `<TelerikPopup>`.
18+
1. Set the `AnchorSelector` parameter to a CSS selector, which points to the HTML element that the Popup will align with.
19+
1. [Obtain the component reference to show and hide the Popover programmatically](#popup-reference-and-methods).
20+
1. (optional) Set the Popup `Width` and `Height`, or configure animations.
2021

2122
>caption Basic configuration of the Telerik Popup for Blazor
2223
2324
````CSHTML
24-
<TelerikPopup AnchorSelector=".popup-target" @ref="@PopupRef">
25-
I am a Telerik Popup.
25+
<TelerikPopup @ref="@PopupRef"
26+
AnchorSelector=".popup-target"
27+
AnimationType="@AnimationType.SlideDown"
28+
AnimationDuration="200"
29+
Width="200px"
30+
Height="100px">
31+
<div style="text-align: center;">
32+
<p>Telerik Popup for Blazor</p>
33+
<TelerikButton OnClick="@( () => PopupRef?.Hide() )"
34+
Icon="@SvgIcon.XCircle">Close</TelerikButton>
35+
</div>
36+
2637
</TelerikPopup>
2738
28-
<TelerikButton OnClick="@(() => PopupRef.Show())" Class="popup-target">Show the Popup</TelerikButton>
39+
<TelerikButton OnClick="@( () => PopupRef?.Show() )"
40+
Class="popup-target">Show Popup</TelerikButton>
2941
3042
@code {
31-
private TelerikPopup PopupRef { get; set; }
43+
private TelerikPopup? PopupRef { get; set; }
3244
}
3345
````
3446

@@ -68,31 +80,44 @@ The following parameters enable you to customize the appearance of the Blazor Po
6880
| --- | --- | --- |
6981
| `Class` | `string` | The custom CSS class to be rendered on the `<div>` element, which wraps the component `ChildContent`. Use for [styling customizations]({%slug themes-override%}). |
7082
| `Height` | `string` | The height of the Popup. |
71-
| `Width` | `string` | The width of the Popup. |
83+
| `Width` | `string` | The width of the Popup. If not set, the component width will match the anchor width. |
7284

7385
## Popup Reference and Methods
7486

7587
To execute Popup methods, obtain a reference to the component instance with `@ref`.
7688

7789
| Method | Description |
7890
|---------|-------------|
79-
| `Refresh` | Use this method to programmatically re-render the Popup. <br /> The Popup is rendered as a child of the `TelerikRootComponent`, instead of where it is declared. As a result, it doesn't automatically refresh when its content is updated. In such cases, the `Refresh` method comes in handy to ensure that the Popup content is up-to-date. |
80-
| `Show` | Use this method to display the Popup. |
81-
| `Hide` | Use this method to close the Popup. |
91+
| `Refresh` | Re-renders the Popup. <br /> The Popup renders as a child of the `TelerikRootComponent`, instead of where it is declared. As a result, it doesn't automatically refresh when its content is updated. In such cases, the `Refresh` method ensures that the Popup content is up-to-date. |
92+
| `Show` | Displays the Popup. |
93+
| `Hide` | Closes the Popup. |
8294

8395
````CSHTML
84-
<TelerikButton OnClick="@ShowPopup" Class="popup-target">Show the Popup</TelerikButton>
96+
<TelerikButton OnClick="@TogglePopup"
97+
Class="popup-target">Toggle Popup</TelerikButton>
8598
86-
<TelerikPopup AnchorSelector=".popup-target" @ref="@PopupRef">
87-
I am a Telerik Popup!
99+
<TelerikPopup @ref="@PopupRef"
100+
AnchorSelector=".popup-target">
101+
Telerik Popup for Blazor
88102
</TelerikPopup>
89103
90104
@code {
91-
private TelerikPopup PopupRef { get; set; }
105+
private TelerikPopup? PopupRef { get; set; }
106+
107+
private bool PopupVisible { get; set; }
92108
93-
private void ShowPopup()
109+
private void TogglePopup()
94110
{
95-
PopupRef.Show();
111+
if (!PopupVisible)
112+
{
113+
PopupVisible = true;
114+
PopupRef?.Show();
115+
}
116+
else
117+
{
118+
PopupVisible = false;
119+
PopupRef?.Hide();
120+
}
96121
}
97122
}
98123
````

0 commit comments

Comments
 (0)