Skip to content
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

feat(split): support pane collapsible #4138

Merged
merged 44 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5d79993
feat(split): support pane collapsible
izanhzh Aug 24, 2024
0c57ea3
modify css
izanhzh Aug 24, 2024
2e69acc
modify css
izanhzh Aug 24, 2024
fb279e4
Merge branch 'main' into feat(split)-support-pane-collapsible
izanhzh Aug 25, 2024
66373b5
beautify and fix bugs
izanhzh Aug 26, 2024
550eacc
adjust parameter
izanhzh Aug 26, 2024
18ad13b
modify unit tests
izanhzh Aug 26, 2024
858d919
modify unit tests
izanhzh Aug 26, 2024
26cae06
coverage
izanhzh Aug 26, 2024
df7d827
modify css
izanhzh Aug 26, 2024
f81d948
Merge branch 'main' into feat(split)-support-pane-collapsible
ArgoZhang Aug 26, 2024
2df26c6
fix bugs
izanhzh Aug 27, 2024
00052af
Merge branch 'feat(split)-support-pane-collapsible' of https://github…
izanhzh Aug 27, 2024
f078604
Merge branch 'dotnetcore:main' into feat(split)-support-pane-collapsible
izanhzh Aug 27, 2024
a14cf04
wip: test modify PR
ArgoZhang Aug 27, 2024
2d55fdf
Merge branch 'main' into feat(split)-support-pane-collapsible
ArgoZhang Aug 27, 2024
6299652
add document
izanhzh Aug 27, 2024
870c374
Merge branch 'feat(split)-support-pane-collapsible' of https://github…
izanhzh Aug 27, 2024
ad1cea0
fix bugs
izanhzh Aug 27, 2024
f00a709
Merge branch 'main' into feat(split)-support-pane-collapsible
izanhzh Aug 27, 2024
295267f
modify some description
izanhzh Aug 27, 2024
18afe78
fix bugs
izanhzh Aug 27, 2024
50f1248
refactor: 调整 bar 样式
ArgoZhang Aug 27, 2024
42daec4
style: 调整垂直样式
ArgoZhang Aug 27, 2024
1688767
style: 增加垂直布局样式
ArgoZhang Aug 27, 2024
93440ad
style: 增加 handler 样式
ArgoZhang Aug 27, 2024
fc5be8b
style: 更新垂直布局样式
ArgoZhang Aug 27, 2024
3bce1c9
refactor: 增加 IsCollapsible 参数
ArgoZhang Aug 27, 2024
8450e10
refactor: 增加按钮支持
ArgoZhang Aug 27, 2024
652441e
style: 微调样式
ArgoZhang Aug 27, 2024
d53b825
doc: 精简 dom 结构
ArgoZhang Aug 27, 2024
547bbe1
style: 微调样式适配收起动画
ArgoZhang Aug 27, 2024
c08a02c
feat: 更新脚本实现收起展开动画特效
ArgoZhang Aug 27, 2024
6cd659c
style: 颜色变量化
ArgoZhang Aug 27, 2024
d01c042
style: 增加动画效果
ArgoZhang Aug 27, 2024
dc89a46
doc: 更新文档说明
ArgoZhang Aug 27, 2024
da0eceb
test: 更新单元测试
ArgoZhang Aug 27, 2024
5f24e28
feat: 增加 OnCollapsedAsync 回调方法
ArgoZhang Aug 27, 2024
25d8184
feat: 实现 OnCollapsedAsync 逻辑
ArgoZhang Aug 27, 2024
a674272
test: 增加单元测试
ArgoZhang Aug 27, 2024
86c483e
doc: 移除不需要的本地化设置
ArgoZhang Aug 27, 2024
d38bd16
chore: bump version 8.8.5-beta03
ArgoZhang Aug 27, 2024
d5d3851
style: 增加暗黑主题颜色
ArgoZhang Aug 27, 2024
39756e9
style: 更正暗黑主题变量
ArgoZhang Aug 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 85 additions & 65 deletions src/BootstrapBlazor.Server/Components/Samples/Splits.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,93 @@

<h3>@Localizer["SplitsTitle"]</h3>

<div>
<DemoBlock Title="@Localizer["SplitsNormalTitle"]"
Introduction="@Localizer["SplitsNormalIntro"]"
Name="Normal">
<div class="border split-demo split-demo-horizontal">
<Split>
<FirstPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100"></div>
</FirstPaneTemplate>
<SecondPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel2"]</div>
</SecondPaneTemplate>
</Split>
</div>
</DemoBlock>
<DemoBlock Title="@Localizer["SplitsNormalTitle"]"
Introduction="@Localizer["SplitsNormalIntro"]"
Name="Normal">
<div class="border split-demo split-demo-horizontal">
<Split>
<FirstPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel1"]</div>
</FirstPaneTemplate>
<SecondPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel2"]</div>
</SecondPaneTemplate>
</Split>
</div>
</DemoBlock>

<DemoBlock Title="@Localizer["SplitsPercentTitle"]"
Introduction="@Localizer["SplitsPercentIntro"]"
Name="Basis">
<div class="border split-demo split-demo-horizontal">
<Split Basis="40%">
<FirstPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel1"]</div>
</FirstPaneTemplate>
<SecondPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel2"]</div>
</SecondPaneTemplate>
</Split>
</div>
</DemoBlock>
<DemoBlock Title="@Localizer["SplitsPercentTitle"]"
Introduction="@Localizer["SplitsPercentIntro"]"
Name="Basis">
<div class="border split-demo split-demo-horizontal">
<Split Basis="40%">
<FirstPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel1"]</div>
</FirstPaneTemplate>
<SecondPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel2"]</div>
</SecondPaneTemplate>
</Split>
</div>
</DemoBlock>

<DemoBlock Title="@Localizer["SplitsVerticalTitle"]"
Introduction="@Localizer["SplitsVerticalIntro"]"
Name="IsVertical">
<div class="border split-demo">
<Split IsVertical="true">
<FirstPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel3"]</div>
</FirstPaneTemplate>
<SecondPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel4"]</div>
</SecondPaneTemplate>
</Split>
</div>
</DemoBlock>
<DemoBlock Title="@Localizer["SplitsVerticalTitle"]"
Introduction="@Localizer["SplitsVerticalIntro"]"
Name="IsVertical">
<div class="border split-demo">
<Split IsVertical="true">
<FirstPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel3"]</div>
</FirstPaneTemplate>
<SecondPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel4"]</div>
</SecondPaneTemplate>
</Split>
</div>
</DemoBlock>

<DemoBlock Title="@Localizer["SplitsNestedTitle"]"
Introduction="@Localizer["SplitsNestedIntro"]"
Name="Nested">
<div class="border split-demo">
<Split>
<FirstPaneTemplate>
<Split IsVertical="true">
<FirstPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel5"]</div>
</FirstPaneTemplate>
<SecondPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel6"]</div>
</SecondPaneTemplate>
</Split>
</FirstPaneTemplate>
<SecondPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel7"]</div>
</SecondPaneTemplate>
</Split>
</div>
</DemoBlock>
</div>
<DemoBlock Title="@Localizer["SplitsNestedTitle"]"
Introduction="@Localizer["SplitsNestedIntro"]"
Name="Nested">
<div class="border split-demo">
<Split>
<FirstPaneTemplate>
<Split IsVertical="true">
<FirstPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel5"]</div>
</FirstPaneTemplate>
<SecondPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel6"]</div>
</SecondPaneTemplate>
</Split>
</FirstPaneTemplate>
<SecondPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel7"]</div>
</SecondPaneTemplate>
</Split>
</div>
</DemoBlock>

<DemoBlock Title="@Localizer["SplitsCollapsibleTitle"]"
Introduction="@Localizer["SplitsCollapsibleIntro"]"
Name="Collapsible">
<div class="border split-demo">
<Split IsCollapsible="true">
<FirstPaneTemplate>
<Split IsVertical="true" IsCollapsible="true">
<FirstPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel8"]</div>
</FirstPaneTemplate>
<SecondPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel9"]</div>
</SecondPaneTemplate>
</Split>
</FirstPaneTemplate>
<SecondPaneTemplate>
<div class="d-flex justify-content-center align-items-center h-100">@Localizer["SplitsPanel10"]</div>
</SecondPaneTemplate>
</Split>
</div>
</DemoBlock>

<AttributeTable Items="@GetAttributes()" />
8 changes: 8 additions & 0 deletions src/BootstrapBlazor.Server/Components/Samples/Splits.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ private AttributeItem[] GetAttributes() =>
Type = "RenderFragment",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "IsCollapsible",
Description = Localizer["SplitsIsCollapsible"],
Type = "bool",
ValueList = "true|false",
DefaultValue = "false"
}
];
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
::deep.split-demo {
split-demo {
height: 200px;
width: 240px;
border-color: rgba(0,0,0,.125);
Expand All @@ -10,12 +10,12 @@
}

@media (min-width: 568px) {
::deep .split-demo {
.split-demo {
height: 200px;
width: 480px;
}

::deep.split-demo-horizontal {
split-demo-horizontal {
height: 100px;
}
}
10 changes: 8 additions & 2 deletions src/BootstrapBlazor.Server/Locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1761,10 +1761,16 @@
"SplitsPanel5": "Upper",
"SplitsPanel6": "Lower",
"SplitsPanel7": "Right",
"SplitsIsVertical": "style",
"SplitsCollapsibleTitle": "Collapse/Expand",
"SplitsCollapsibleIntro": "Set whether the panels can be collapsed by configuring the <code>FirstPaneCollapsible</code> and <code>SecondPaneCollapsible</code> properties",
"SplitsPanel8": "Upper",
"SplitsPanel9": "Lower",
"SplitsPanel10": "Right",
"SplitsIsVertical": "Vertical",
"SplitsBasis": "Percentage of first pane position",
"SplitsFirstPanelTemplate": "First pane template",
"SplitsSecondPanelTemplate": "Second pane template"
"SplitsSecondPanelTemplate": "Second pane template",
"SplitsIsCollapsible": "Whether to expand or collapse the split view"
},
"BootstrapBlazor.Server.Components.Samples.Dropdowns": {
"Title": "Dropdown",
Expand Down
10 changes: 8 additions & 2 deletions src/BootstrapBlazor.Server/Locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1761,10 +1761,16 @@
"SplitsPanel5": "上边面板",
"SplitsPanel6": "下边面板",
"SplitsPanel7": "右边面板",
"SplitsIsVertical": "样式",
"SplitsCollapsibleTitle": "折叠/展开",
"SplitsCollapsibleIntro": "通过设置 <code>IsCollapsible</code> 属性来设置是否可以折叠面板",
"SplitsPanel8": "上边面板",
"SplitsPanel9": "下边面板",
"SplitsPanel10": "右边面板",
"SplitsIsVertical": "垂直分割",
"SplitsBasis": "第一个窗格位置占比",
"SplitsFirstPanelTemplate": "第一个窗格模板",
"SplitsSecondPanelTemplate": "第二个窗格模板"
"SplitsSecondPanelTemplate": "第二个窗格模板",
"SplitsIsCollapsible": "是否可以展开收起面板"
},
"BootstrapBlazor.Server.Components.Samples.Dropdowns": {
"Title": "Dropdown 下拉菜单",
Expand Down
38 changes: 19 additions & 19 deletions src/BootstrapBlazor/Components/Split/Split.razor
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
@namespace BootstrapBlazor.Components
@inherits BootstrapModuleComponentBase
@attribute [BootstrapModuleAutoLoader]
@attribute [BootstrapModuleAutoLoader(JSObjectReference = true)]

<div @attributes="@AdditionalAttributes" id="@Id" class="@ClassString" role="group">
<div class="@WrapperClassString">
<div class="split-pane split-left" style="@StyleString">
@FirstPaneTemplate
</div>
<div class="split-pane split-bar">
<div class="split-trigger">
<i class="split-trigger-bar"></i>
<i class="split-trigger-bar"></i>
<i class="split-trigger-bar"></i>
<i class="split-trigger-bar"></i>
<i class="split-trigger-bar"></i>
<i class="split-trigger-bar"></i>
<i class="split-trigger-bar"></i>
<i class="split-trigger-bar"></i>
</div>
</div>
<div class="split-pane split-right" style="flex: 1;">
@SecondPaneTemplate
<div class="split-pane split-left" style="@StyleString">
@FirstPaneTemplate
</div>
<div class="split-pane split-right">
@SecondPaneTemplate
</div>
<div class="split-pane split-bar">
@if (IsCollapsible)
{
<button tabindex="-1" type="button" class="split-bar-arrow split-bar-arrow-left"></button>
}
<div class="split-bar-handler">
<div></div>
<div></div>
</div>
@if (IsCollapsible)
{
<button tabindex="-1" type="button" class="split-bar-arrow split-bar-arrow-right"></button>
}
</div>
</div>
42 changes: 34 additions & 8 deletions src/BootstrapBlazor/Components/Split/Split.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@
namespace BootstrapBlazor.Components;

/// <summary>
///
/// Split 组件
/// </summary>
public sealed partial class Split
{
/// <summary>
/// 获得 组件样式
/// </summary>
private string? ClassString => CssBuilder.Default("split")
.AddClass("is-vertical", IsVertical)
.AddClassFromAttributes(AdditionalAttributes)
.Build();

/// <summary>
/// 获得 组件 Wrapper 样式
/// </summary>
private string? WrapperClassString => CssBuilder.Default("split-wrapper")
.AddClass("is-horizontal", !IsVertical)
.Build();

/// <summary>
/// 获得 第一个窗格 Style
/// </summary>
private string? StyleString => CssBuilder.Default()
.AddClass($"flex-basis: {Basis.ConvertToPercentString()};")
.Build();

/// <summary>
/// 获取 是否开启折叠功能 默认 false
/// </summary>
[Parameter]
public bool IsCollapsible { get; set; }

/// <summary>
/// 获得/设置 是否垂直分割
/// </summary>
Expand All @@ -53,4 +53,30 @@ public sealed partial class Split
/// </summary>
[Parameter]
public RenderFragment? SecondPaneTemplate { get; set; }

/// <summary>
/// 获得/设置 窗格折叠时回调方法 参数 bool 值为 true 是表示已折叠 值为 false 表示第二个已折叠
/// </summary>
[Parameter]
public Func<bool, Task>? OnCollapsedAsync { get; set; }

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <returns></returns>
protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, nameof(TriggerOnCollapsed));

/// <summary>
/// 窗格折叠时回调方法 由 JavaScript 调用
/// </summary>
/// <param name="collapsed"></param>
/// <returns></returns>
[JSInvokable]
public async Task TriggerOnCollapsed(bool collapsed)
{
if (OnCollapsedAsync != null)
{
await OnCollapsedAsync(collapsed);
}
}
}
Loading