-
Notifications
You must be signed in to change notification settings - Fork 80
kb(drawer):add kb for expand/collapse drawer handle #406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3f653fe
kb(drawer):add kb for expand/collapse drawer handle
ntacheva 191f8a9
Update knowledge-base/drawer-add-expand-collapse-handle.md
ntacheva b2d1c29
Update knowledge-base/drawer-add-expand-collapse-handle.md
ntacheva 796ff7f
Update knowledge-base/drawer-add-expand-collapse-handle.md
ntacheva c68e1e1
Update knowledge-base/drawer-add-expand-collapse-handle.md
ntacheva d65ac69
Update knowledge-base/drawer-add-expand-collapse-handle.md
ntacheva 142b046
Update knowledge-base/drawer-add-expand-collapse-handle.md
ntacheva 16d8aa3
Update knowledge-base/drawer-add-expand-collapse-handle.md
ntacheva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| --- | ||
| title: Add Expand/Collapse Handle to Toggle the Drawer | ||
| description: This demo shows how to add expand/collapse handle to toggle the Telerik Blazor Drawer. | ||
| type: how-to | ||
| page_title: Add Expand/Collapse Handle to Toggle the Drawer | ||
| slug: drawer-kb-add-expand-collapse-handle | ||
| position: | ||
| tags: telerik, blazor, drawer, expand, collapse, handle | ||
| ticketid: 1527830 | ||
| res_type: kb | ||
| --- | ||
|
|
||
| ## Environment | ||
| <table> | ||
| <tbody> | ||
| <tr> | ||
| <td>Product</td> | ||
| <td>Drawer for Blazor</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
|
|
||
| ## Description | ||
|
|
||
| How to add a handle feature within the rendered Drawer component that would expand and collapse the component? | ||
|
|
||
| ## Solution | ||
|
|
||
| To achieve the desired result you can try the following: | ||
|
|
||
| * Add a Telerik Button | ||
| * Toggle the Drawer on click of that button | ||
| * Use custom CSS to adjust the button's appearance, position, transition etc. | ||
|
|
||
| The example below demonstrates the described approach: | ||
|
|
||
| ````CSHTML | ||
| @* Add Expand/Collapse handle to toggle the Drawer *@ | ||
|
|
||
| <style> | ||
| .my-toggle-button { | ||
| border-radius: 50%; | ||
| transform: translateY(50%); | ||
| border: 1px solid rgba(0, 0, 0, 0.08); | ||
| z-index: 1; | ||
| background-color: #fff; | ||
| transition-duration:0.3s; /* match the Drawer's animation duration */ | ||
| } | ||
|
|
||
| .my-toggle-button.collapsed { | ||
| top: 20px; | ||
| left: 34px; | ||
| } | ||
|
|
||
| .my-toggle-button.expanded { | ||
| top: 20px; | ||
| left: 225px; | ||
| } | ||
| </style> | ||
|
|
||
| <TelerikButton Class="@(ExpandedDrawer ? "my-toggle-button expanded" : "my-toggle-button collapsed")" Icon="@(ExpandedDrawer ? "chevron-left" : "chevron-right")" OnClick="@(() => DrawerRef.ToggleAsync())"></TelerikButton> | ||
|
|
||
| <TelerikDrawer Data="@Data" | ||
| Class="my-drawer" | ||
| MiniMode="true" | ||
| Mode="DrawerMode.Push" | ||
| @ref="@DrawerRef" | ||
| @bind-SelectedItem="@SelectedItem" | ||
| @bind-Expanded="@ExpandedDrawer"> | ||
| <Content> | ||
| @* Place your contents here - it can be as simple as text, it can be conditional components or components that take the selected item as a parameter, or even the @Body tag for navigation if you place the drawer high enough in the project layout hierarchy *@ | ||
| <div class="m-5"> | ||
| Selected Item: @SelectedItem?.Text | ||
| </div> | ||
| </Content> | ||
| </TelerikDrawer> | ||
|
|
||
|
|
||
| @code { | ||
| public bool ExpandedDrawer { get; set; } | ||
|
|
||
| TelerikDrawer<DrawerItem> DrawerRef { get; set; } | ||
|
|
||
| DrawerItem SelectedItem { get; set; } | ||
|
|
||
| IEnumerable<DrawerItem> Data { get; set; } = | ||
| new List<DrawerItem> | ||
| { | ||
| new DrawerItem { Text = "Counter", Icon = "plus"}, | ||
| new DrawerItem { Text = "FetchData", Icon = "grid-layout"} | ||
| }; | ||
|
|
||
| public class DrawerItem | ||
| { | ||
| public string Text { get; set; } | ||
| public string Icon { get; set; } | ||
| } | ||
| } | ||
| ```` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.