Skip to content

Commit ea53661

Browse files
ntachevadimodi
andauthored
docs(splitter):Revamp Overview, split content in dedicated articles (#1052)
* docs(splitter):Revamp Overview, split content in dedicated articles * Update components/splitter/size.md Co-authored-by: Dimo Dimov <[email protected]> * Update components/splitter/size.md Co-authored-by: Dimo Dimov <[email protected]> * Update components/splitter/overview.md Co-authored-by: Dimo Dimov <[email protected]> * Update components/splitter/size.md Co-authored-by: Dimo Dimov <[email protected]> * Update components/splitter/size.md Co-authored-by: Dimo Dimov <[email protected]> * docs(splitter):fixes * docs(splitter):address feedback Co-authored-by: Dimo Dimov <[email protected]>
1 parent 300c3b4 commit ea53661

File tree

4 files changed

+267
-101
lines changed

4 files changed

+267
-101
lines changed

components/splitter/orientation.md

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
title: Orientation
3+
page_title: Splitter Orientation
4+
description: Splitter Orientation
5+
slug: splitter-orientation
6+
tags: telerik,blazor,splitter,orientation,horizontal,vertical
7+
published: True
8+
position: 8
9+
---
10+
11+
# Splitter Orientation
12+
13+
You can customize the Splitter orientation through the its `Orientation` parameter. It takes a member of the `SplitterOrientation` enum:
14+
15+
* `Horizontal` (the default)
16+
* `Vertical`
17+
18+
>caption Splitter with vertical orientation
19+
20+
````CSHTML
21+
<p>
22+
Configure the Splitter Orientation:
23+
24+
<TelerikRadioGroup Data="@OrientationOptions" Layout="RadioGroupLayout.Horizontal"
25+
@bind-Value="@SelectedSplitterOrientation.Value" />
26+
</p>
27+
28+
<TelerikSplitter Orientation="@SelectedSplitterOrientation.Value"
29+
Width="400px" Height="200px">
30+
<SplitterPanes>
31+
<SplitterPane>
32+
<div>First Pane content</div>
33+
</SplitterPane>
34+
<SplitterPane>
35+
<div>Second Pane content</div>
36+
</SplitterPane>
37+
</SplitterPanes>
38+
</TelerikSplitter>
39+
40+
@code {
41+
public Orientation SelectedSplitterOrientation { get; set; }
42+
43+
protected override void OnInitialized()
44+
{
45+
SelectedSplitterOrientation = OrientationOptions[0];
46+
base.OnInitialized();
47+
}
48+
49+
public List<Orientation> OrientationOptions { get; set; } = new List<Orientation>()
50+
{
51+
new Orientation() { Text = "Horizontal", Value = SplitterOrientation.Horizontal },
52+
new Orientation() { Text = "Vertical", Value = SplitterOrientation.Vertical},
53+
};
54+
55+
public class Orientation
56+
{
57+
public string Text { get; set; }
58+
public SplitterOrientation Value { get; set; }
59+
}
60+
61+
}
62+
````
63+
64+
## Nested Splitters With Different Orientation
65+
66+
Sometimes you need to create a more complex layout that includes both horizontal and vertical panes. To do that, you can nest Telerik Splitter components inside the panes of other splitters. When you do that, set the `Class` parameter of the nested splitter to `k-pane-flex`.
67+
68+
>caption Nested splitters that create a complex layout with both horizontal and vertical panes
69+
70+
````CSHTML
71+
<div style="width: 500px; height: 300px; border: 2px solid red;">
72+
73+
<TelerikSplitter Width="100%" Height="100%">
74+
<SplitterPanes>
75+
<SplitterPane Size="100px">
76+
<div>left sidebar</div>
77+
</SplitterPane>
78+
<SplitterPane>
79+
80+
<TelerikSplitter Class="k-pane-flex"
81+
Width="100%" Height="100%"
82+
Orientation="@SplitterOrientation.Vertical">
83+
<SplitterPanes>
84+
<SplitterPane Size="20%">
85+
<div>TOP content</div>
86+
</SplitterPane>
87+
<SplitterPane>
88+
<div>Bottom content</div>
89+
</SplitterPane>
90+
</SplitterPanes>
91+
</TelerikSplitter>
92+
93+
</SplitterPane>
94+
</SplitterPanes>
95+
</TelerikSplitter>
96+
97+
</div>
98+
````
99+
100+
>caption The result from the code snippet above
101+
102+
![Nested splitters can create complex layout](images/nested-splitter-result.png)
103+
104+
## See Also
105+
106+
* [Live Demo: Splitter Orientation](https://demos.telerik.com/blazor-ui/splitter/orientation)

components/splitter/overview.md

+55-101
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,19 @@ position: 0
1212

1313
The <a href="https://www.telerik.com/blazor-ui/splitter" target="_blank">Blazor Splitter component</a> lets you divide a portion of the page into several pieces that the user can resize and collapse. This provides real estate management for the app and the end user so they can focus on the content that is important in their current task. You can also [save and load its state]({%slug splitter-state%}), and respond to [events]({%slug splitter-events%}).
1414

15-
#### In This Article
15+
## Creating Splitter for Blazor
1616

17+
1. Declare the `<TelerikSplitter>` tag
1718

18-
* [Basics](#basics)
19-
* [Features](#features)
20-
* [Splitter](#splitter)
21-
* [Pane](#pane)
22-
* [Splitter and Pane Size](#splitter-and-pane-size)
23-
* [Nested Splitters](#nested-splitters)
24-
25-
## Basics
26-
27-
#### To use a Telerik Splitter for Blazor
28-
29-
1. Declare the `<TelerikSplitter>` tag and set its `Width` and `Height` parameters to the desired values.
19+
1. Optionally, set the `Width` and `Height` parameters to the desired values. Otherwise, the component size will be controlled by the content and [size]({%slug splitter-size%}) of the panes.
3020

3121
* You can use values in percent (setting them to `100%` is very common) so that the splitter will take up the entire size of its container. See the [Dimensions]({%slug common-features/dimensions%}) article for more details on what units you can use and how dimensions in percent work.
3222

33-
1. Inside the `<SplitterPanes>` child tag, add the desired `<SplitterPane>` tags to create the sections of content.
23+
1. Inside the `<SplitterPanes>` child tag, add the desired [`<SplitterPane>`]({%slug splitter-panes%}) tags to create the sections of content.
3424

3525
1. Inside each `<SplitterPane>`, add the desired content - be that HTML or components.
3626

37-
1. Optionally, set the desired settings for the individual panes - such as initial, min and max size, whether the user can collapse and resize the pane.
27+
1. Optionally, set the desired settings for the individual Panes - such as initial, min and max size, whether the user can collapse and resize the pane.
3828

3929
>caption Splitter that takes 100% of its container and shows the main features of its panes
4030
@@ -69,118 +59,82 @@ This example shows how the splitter can fill up the entire container (marked wit
6959
![overview of the splitter functionality](images/splitter-overview.gif)
7060

7161

72-
>caption Component namespace and reference
73-
74-
````CSHTML
75-
<TelerikSplitter Width="400px" Height="200px" @ref="@SplitterRef">
76-
<SplitterPanes>
77-
<SplitterPane>
78-
<div>left sidebar</div>
79-
</SplitterPane>
80-
<SplitterPane>
81-
<div>right hand side pane - content.</div>
82-
</SplitterPane>
83-
</SplitterPanes>
84-
</TelerikSplitter>
85-
86-
@code {
87-
Telerik.Blazor.Components.TelerikSplitter SplitterRef { get; set; }
88-
}
89-
````
90-
91-
92-
## Features
93-
94-
The main container is the Splitter component and its tag defines the size and layout direction of the individual sections. Each Pane (section) controls its own behaviors such as the ability to change its size and collapse.
95-
96-
### Splitter
97-
98-
The main tag of the splitter offers the following core features of the component:
99-
100-
* `Class` - the CSS class that renders on the main wrapping element of the component.
62+
## Panes
10163

102-
* `Height` - takes a CSS unit that determines how tall the splitter is. See the [Dimensions]({%slug common-features/dimensions%}) article for more details on what units you can use and how dimensions in percent work.
64+
Тhe Panes are the building blocks of the Splitter. Each Pane controls its own behaviors such as the ability to change its size and collapse. [Read more about the Splitter Panes...]({%slug splitter-panes%})
10365

104-
* `Orientation` - whether the content will be split up (how the panes will stack) horizontally or vertically. Takes a member of the `SplitterOrientation` enum and defaults to `Horizontal`.
66+
## Size
10567

106-
* `Width`- takes a CSS unit that determines how wide the splitter is. See the [Dimensions]({%slug common-features/dimensions%}) article for more details on what units you can use and how dimensions in percent work.
68+
You can control the Splitter size through its `Width` and `Height` parameters. Additioanlly, the component allows you specify the desired size for each pane. [Read about for the Splitter sizing specifics...]({%slug splitter-size%})
10769

108-
* Several [events]({%slug splitter-events%}).
70+
## Orientation
10971

110-
### Pane
72+
The Splitter Panes can be stacked in horizontal or vertical direction. [Read more about how to configure the Splitter orientation...]({%slug splitter-orientation%})
11173

112-
Each individual splitter pane (section) offers the following features:
74+
## State
11375

114-
* `ChildContent` - the standard `RenderFragment` for Blazor that lets you define your content directly between the opening and closing tags of the pane.
76+
The Splitter allows you to save its state and programmatically control it. [Read more about the Splitter State...]({%slug splitter-state%})
11577

116-
* `Class` - the CSS class that renders on the top element of the pane. Lets you apply styling such as changing the `overflow` for the content.
78+
## Events
11779

118-
* `Collapsed` - whether the pane will be collapsed (not visible). Defaults to `false`. Supports two-way binding.
80+
The Splitter generates events that you can handle to further customize the component behavior and respond to the user actions. [Read more about the Blazor Menu events...]({%slug splitter-events%})
11981

120-
* `Collapsible` - whether the user can collapse (hide) the pane to provide more room for other panes. When enabled, the adjacent splitbar (the drag handle between the panes) will offer a collapse button for the pane. Defaults to `false`.
82+
## Splitter Parameters
12183

122-
* `Max` - the maximum size the pane can have in pixels or percentages. When it is reached, the user cannot expand its size further.
84+
The Blazor Splitter provides various parameters for its configuration. The following table lists Splitter parameters on component level. Explore the [Splitter Panes]({%slug splitter-panes%}) article for details on the individual Panes configuration.
12385

124-
* `Min` - the minimum size the pane can have in pixels or percentages. When it is reached, the user cannot reduce its size further.
86+
Check the [Splitter API Reference ](https://docs.telerik.com/blazor-ui/api/Telerik.Blazor.Components.TelerikSplitter) for a full list of properties, methods and events.
12587

126-
* `Resizable` - whether the user can resize the pane by dragging the resize handle (splitbar) between two panes. Resizing means that the adjacent pane will take up the difference in size. Defaults to `true`.
88+
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)
12789

128-
* `Size` - the size the pane in pixels or percentages. Must be between `Min` and `Max`. Supports two-way binding.
90+
| Attribute | Type and Default Value | Description |
91+
|----------|----------|----------|
92+
| `Class` | `string` | The CSS class that renders on the main wrapping element of the component.
93+
| `Height` | `string` | The height of the Splitter. See the [Dimensions]({%slug common-features/dimensions%}) article for more details on what units you can use and how dimensions in percent work.
94+
| `Orientation` | `SplitterOrientation` enum <br/> (`SplitterOrientation.Horizontal`) | Whether the content will be split up (how the panes will stack) horizontally or vertically.
95+
| `Width`| `string` | The width of the Splitter. See the [Dimensions]({%slug common-features/dimensions%}) article for more details on what units you can use and how dimensions in percent work.
12996

130-
## Splitter and Pane Size
97+
## Splitter Reference and Methods
13198

132-
The splitter respects the dimensions you set to its `Width` and `Height` parameters, and distributes the available space according to the `Size` set to individual panes inside.
99+
Add a reference to the component instance to use the [Splitter methods](https://docs.telerik.com/blazor-ui/api/Telerik.Blazor.Components.TelerikSplitter#methods).
133100

134-
If you set the `Width` and `Height` in percent, make sure that the parent element provides the desires dimensions and layout first.
101+
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)
135102

136-
The individual panes use the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis" target="_blank">CSS flex-basis</a> to set their dimensions and by default they have `flex: 1 1 auto` so they distribute the space evenly if there are no other settings.
137-
138-
If the `Size` of a pane is set to a value larger than the `Max`, the pane cannot be resized even if its `Resizable` parameter is set to `true`.
139-
140-
>tip You must leave at least one `SplitterPane` *without* a set `Size`. This pane will absorb size changes from other panes when the user resizes them and provides you with some flexibility when defining strict sizes for the other panes so that you don't have to keep track of all the pane sizes, their sum and the container size.
141-
142-
>tip You can find a sample of creating a 100% height layout with a splitter that also offers a header, footer and sidebar in the following sample project: <a href="https://github.com/telerik/blazor-ui/tree/master/splitter/use-100-percent-viewport" target="_blank">How to make Splitter take 100% height of the viewport</a>.
143-
144-
145-
## Nested Splitters
146-
147-
Sometimes you need to create a more complex layout that includes both horizontal and vertical panes. To do that, you can nest Telerik Splitter components inside the panes of other splitters. When you do that, set the `Class` parameter of the nested splitter to `k-pane-flex`.
148-
149-
>caption Nested splitters that create a complex layout with both horizontal and vertical panes
103+
| Method | Description |
104+
| --- | --- |
105+
| `GetState` | Gets the current [state]({%slug splitter-state%}) of the Splitter.
106+
| `SetState` | Sets the current [state]({%slug splitter-state%}) of the Splitter.
150107

151108
````CSHTML
152-
<div style="width: 500px; height: 300px; border: 2px solid red;">
109+
<TelerikButton OnClick="@GetSplitterState">Get Splitter State</TelerikButton>
153110
154-
<TelerikSplitter Width="100%" Height="100%">
155-
<SplitterPanes>
156-
<SplitterPane Size="100px">
157-
<div>left sidebar</div>
158-
</SplitterPane>
159-
<SplitterPane>
160-
161-
<TelerikSplitter Class="k-pane-flex"
162-
Width="100%" Height="100%"
163-
Orientation="@SplitterOrientation.Vertical">
164-
<SplitterPanes>
165-
<SplitterPane Size="20%">
166-
<div>TOP content</div>
167-
</SplitterPane>
168-
<SplitterPane>
169-
<div>Bottom content</div>
170-
</SplitterPane>
171-
</SplitterPanes>
172-
</TelerikSplitter>
111+
<TelerikSplitter @ref="@SplitterRef"
112+
Width="400px"
113+
Height="200px">
114+
<SplitterPanes>
115+
<SplitterPane>
116+
<div>left sidebar</div>
117+
</SplitterPane>
118+
<SplitterPane>
119+
<div>right hand side pane - content.</div>
120+
</SplitterPane>
121+
</SplitterPanes>
122+
</TelerikSplitter>
173123
174-
</SplitterPane>
175-
</SplitterPanes>
176-
</TelerikSplitter>
124+
@code {
125+
Telerik.Blazor.Components.TelerikSplitter SplitterRef { get; set; }
177126
178-
</div>
127+
void GetSplitterState()
128+
{
129+
var currState = SplitterRef.GetState();
130+
}
131+
}
179132
````
180133

181-
>caption The result from the code snippet above
134+
## Next Steps
182135

183-
![Nested splitters can create complex layout](images/nested-splitter-result.png)
136+
* [Explore the various Splitter Pane options]({%slug splitter-panes%})
137+
* [Configure the Splitter Size]({%slug splitter-size%})
184138

185139
## See Also
186140

components/splitter/panes.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: Panes
3+
page_title: Splitter Panes
4+
description: Overview of the Splitter Panes - size, orientation, collapsing, resizing of panes, state and events.
5+
slug: splitter-panes
6+
tags: telerik,blazor,splitter,panes
7+
published: True
8+
position: 3
9+
---
10+
11+
# Splitter Panes
12+
13+
The Splitter consists of individual sections called Panes. The Splitter Panes allow you to add any desired content - be that simple text, other components or HTML elements. Declare a `<SplitterPane>` instance inside the `<SplitterPanes>` child tag of the Splitter for each Pane you want to include in the component.
14+
15+
Each Splitter Pane (section) is individually configured and offers the following features:
16+
17+
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)
18+
19+
| Attribute | Type and Default Value | Description |
20+
|----------|----------|----------|
21+
| `ChildContent` | `RenderFragment` | The standard `RenderFragment` for Blazor that lets you define your content directly between the opening and closing tags of the pane.
22+
| `Class` | `string` | The CSS class that renders on the `<div class="k-pane">` element of the pane. Lets you apply styling such as changing the `overflow` for the content.
23+
| `Collapsed` | `bool` | Whether the pane will be collapsed (not visible). Supports two-way binding.
24+
| `Collapsible` | `bool` | Whether the user can collapse (hide) the pane to provide more room for other panes. When enabled, the adjacent splitbar (the drag handle between the panes) will offer a collapse button for the pane.
25+
| `Max` | `string` | The maximum size the pane can have in pixels or percentages. When it is reached, the user cannot expand its size further.
26+
| `Min` | `string` | The minimum size the pane can have in pixels or percentages. When it is reached, the user cannot reduce its size further.
27+
| `Resizable` | `bool` <br/> (`true`) | Whether the user can resize the pane by dragging the resize handle (splitbar) between two panes. Resizing means that the adjacent pane will take up the difference in size.
28+
| `Size` | `string` | The size the pane in pixels or percentages. Must be between `Min` and `Max`. Supports two-way binding.
29+
30+
````CSHTML
31+
@*Configure the Splitter Panes*@
32+
33+
<TelerikSplitter Width="600px" Height="400px">
34+
<SplitterPanes>
35+
36+
<SplitterPane Collapsible="true" Size="200px" Min="100px" Max="300px">
37+
<h4>Left Pane</h4>
38+
<div>Collapsible pane with initial size in px that can be resized between 100px and 200px.</div>
39+
</SplitterPane>
40+
41+
<SplitterPane Collapsible="true" Size="20%">
42+
<h4>Middle Pane</h4>
43+
<div>Collapsible pane with initial size in percent.</div>
44+
</SplitterPane>
45+
46+
<SplitterPane Collapsible="false" >
47+
<h4>Right Pane</h4>
48+
<span>Non-collapsible pane. No size set, it will take the remaining space of the component.</span>
49+
</SplitterPane>
50+
51+
</SplitterPanes>
52+
</TelerikSplitter>
53+
````
54+
55+
## See Also
56+
57+
* [Live Demo: Splitter](https://demos.telerik.com/blazor-ui/splitter/overview)
58+
* [Splitter and Panes Size]({%slug splitter-size%})

0 commit comments

Comments
 (0)