Skip to content

Commit cf7e8b9

Browse files
committed
Merge branch 'main' into doc-assets
2 parents d01480c + 275043a commit cf7e8b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+987
-117
lines changed

src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@
4646
<PackageReference Include="BootstrapBlazor.Html2Pdf" Version="9.0.3" />
4747
<PackageReference Include="BootstrapBlazor.IconPark" Version="9.0.3" />
4848
<PackageReference Include="BootstrapBlazor.ImageCropper" Version="9.0.3" />
49-
<PackageReference Include="BootstrapBlazor.IP2Region" Version="9.0.1" />
49+
<PackageReference Include="BootstrapBlazor.IP2Region" Version="9.0.2" />
5050
<PackageReference Include="BootstrapBlazor.JitsiMeet" Version="9.0.0" />
5151
<PackageReference Include="BootstrapBlazor.JuHeIpLocatorProvider" Version="9.0.0" />
5252
<PackageReference Include="BootstrapBlazor.Live2DDisplay" Version="9.0.1" />
5353
<PackageReference Include="BootstrapBlazor.Markdown" Version="9.0.2" />
5454
<PackageReference Include="BootstrapBlazor.MaterialDesign" Version="9.0.1" />
55-
<PackageReference Include="BootstrapBlazor.MeiliSearch" Version="9.1.9" />
55+
<PackageReference Include="BootstrapBlazor.MeiliSearch" Version="9.1.10" />
5656
<PackageReference Include="BootstrapBlazor.Mermaid" Version="9.0.4" />
5757
<PackageReference Include="BootstrapBlazor.Middleware" Version="9.0.0" />
5858
<PackageReference Include="BootstrapBlazor.MindMap" Version="9.1.6" />
5959
<PackageReference Include="BootstrapBlazor.MouseFollower" Version="9.0.1" />
6060
<PackageReference Include="BootstrapBlazor.OctIcon" Version="9.0.4" />
6161
<PackageReference Include="BootstrapBlazor.OfficeViewer" Version="9.0.0" />
6262
<PackageReference Include="BootstrapBlazor.OnScreenKeyboard" Version="9.0.1" />
63-
<PackageReference Include="BootstrapBlazor.OpcDa" Version="9.0.1" />
63+
<PackageReference Include="BootstrapBlazor.OpcDa" Version="9.0.3" />
6464
<PackageReference Include="BootstrapBlazor.PdfReader" Version="9.0.1" />
6565
<PackageReference Include="BootstrapBlazor.PdfViewer" Version="9.0.6" />
6666
<PackageReference Include="BootstrapBlazor.Player" Version="9.0.1" />

src/BootstrapBlazor.Server/Components/Components/Pre.razor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { copy, getDescribedElement, addLink, removeLink, addScript, getHeight, getPreferredTheme, registerBootstrapBlazorModule } from "../../_content/BootstrapBlazor/modules/utility.js"
1+
import { copy, getDescribedElement, addLink, removeLink, addScript, getHeight, getTheme, registerBootstrapBlazorModule } from "../../_content/BootstrapBlazor/modules/utility.js"
22
import EventHandler from "../../_content/BootstrapBlazor/modules/event-handler.js"
33

44
export async function init(id, title, assetRoot) {
@@ -9,7 +9,7 @@ export async function init(id, title, assetRoot) {
99

1010
await addScript(`${assetRoot}lib/highlight/highlight.min.js`)
1111
await addScript(`${assetRoot}lib/highlight/cshtml-razor.min.js`)
12-
await switchTheme(getPreferredTheme(), assetRoot);
12+
await switchTheme(getTheme(), assetRoot);
1313

1414
const preElement = el.querySelector('pre')
1515
const code = el.querySelector('pre > code')

src/BootstrapBlazor.Server/Components/Layout/BaseLayout.razor

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
@inherits LayoutComponentBase
22

33
<BootstrapBlazorRoot>
4-
<Header></Header>
5-
<main>
6-
@Body
7-
</main>
4+
@if (_init)
5+
{
6+
<Header></Header>
7+
<main>
8+
@Body
9+
</main>
10+
}
811
</BootstrapBlazorRoot>
912

1013
<div id="blazor-error-ui">

src/BootstrapBlazor.Server/Components/Layout/BaseLayout.razor.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

6+
using BootstrapBlazor.Server.Data;
7+
using Microsoft.Extensions.Options;
8+
using Microsoft.JSInterop;
9+
610
namespace BootstrapBlazor.Server.Components.Layout;
711

812
/// <summary>
913
/// 母版页基类
1014
/// </summary>
1115
public partial class BaseLayout : IDisposable
1216
{
17+
[Inject]
18+
[NotNull]
19+
private IJSRuntime? JSRuntime { get; set; }
20+
1321
[Inject]
1422
[NotNull]
1523
private IStringLocalizer<BaseLayout>? Localizer { get; set; }
@@ -26,6 +34,10 @@ public partial class BaseLayout : IDisposable
2634
[NotNull]
2735
private IDispatchService<bool>? RebootDispatchService { get; set; }
2836

37+
[Inject]
38+
[NotNull]
39+
private IOptions<WebsiteOptions>? WebsiteOption { get; set; }
40+
2941
[NotNull]
3042
private string? FlowText { get; set; }
3143

@@ -38,6 +50,8 @@ public partial class BaseLayout : IDisposable
3850
[NotNull]
3951
private string? CancelText { get; set; }
4052

53+
private bool _init = false;
54+
4155
/// <summary>
4256
/// <inheritdoc/>
4357
/// </summary>
@@ -54,6 +68,19 @@ protected override void OnInitialized()
5468
RebootDispatchService.Subscribe(NotifyReboot);
5569
}
5670

71+
/// <summary>
72+
/// <inheritdoc/>
73+
/// </summary>
74+
/// <returns></returns>
75+
protected override async Task OnInitializedAsync()
76+
{
77+
await base.OnInitializedAsync();
78+
79+
var module = await JSRuntime.LoadModule($"{WebsiteOption.Value.JSModuleRootPath}Layout/BaseLayout.razor.js");
80+
await module.InvokeVoidAsync("initTheme");
81+
_init = true;
82+
}
83+
5784
private async Task NotifyCommit(DispatchEntry<GiteePostBody> payload)
5885
{
5986
if (payload.CanDispatch())
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { getTheme, setTheme } from "../../_content/BootstrapBlazor/modules/utility.js"
2+
3+
export function initTheme() {
4+
const currentTheme = getTheme();
5+
setTheme(currentTheme, false);
6+
}

src/BootstrapBlazor.Server/Components/Pages/Index.razor

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
@Localizer["Support"]
1313
</span>
1414
</a>
15-
<img src="./favicon.png" alt="bootstrap-blazor" class="bb-logo d-sm-block mx-auto my-5">
15+
<div class="bb-logo d-sm-block mx-auto my-5">
16+
<img src="./favicon.png" alt="bootstrap-blazor">
17+
</div>
1618
<h1 class="mb-3 fw-semibold">@Localizer["Title"]</h1>
1719
<p class="lead mb-4">
1820
@Localizer["SubTitle"]

src/BootstrapBlazor.Server/Components/Pages/Index.razor.css

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,53 @@
3030
}
3131

3232
.bd-masthead .bb-logo {
33+
--bb-btn-space: 4px;
3334
width: 200px;
3435
height: 200px;
36+
position: relative;
37+
overflow: hidden;
38+
border-radius: 30px;
3539
}
3640

41+
.bd-masthead .bb-logo img {
42+
width: calc(100% - 2 * var(--bb-btn-space));
43+
height: calc(100% - 2 * var(--bb-btn-space));
44+
position: absolute;
45+
left: var(--bb-btn-space);
46+
top: var(--bb-btn-space);
47+
}
48+
49+
.bb-logo:before {
50+
content: '';
51+
position: absolute;
52+
inset: 0;
53+
background-color: #5a23c8;
54+
z-index: -2;
55+
}
56+
57+
.bb-logo:after {
58+
content: '';
59+
position: absolute;
60+
left: 50%;
61+
top: 50%;
62+
width: 68%;
63+
height: 68%;
64+
background-image: linear-gradient(to bottom, #3f51b1 0%, #5a55ae 13%, #7b5fac 25%, #8f6aae 38%, #a86aa4 50%, #cc6b8e 62%, #f18271 75%, #f3a469 87%, #f7c978 100%);
65+
transform-origin: left top;
66+
animation: rotate 5s linear infinite;
67+
z-index: -1;
68+
}
69+
70+
@keyframes rotate {
71+
0% {
72+
transform: rotate(0deg);
73+
}
74+
75+
100% {
76+
transform: rotate(360deg);
77+
}
78+
}
79+
3780
.bd-gutter {
3881
--bs-gutter-x: 3rem;
3982
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
@page "/navbar"
2+
@inject IStringLocalizer<Navbars> Localizer
3+
4+
<h3>@Localizer["NavbarTitle"]</h3>
5+
6+
<h4>@Localizer["NavbarDescription"]</h4>
7+
8+
<DemoBlock Title="@Localizer["NormalTitle"]" Introduction="@Localizer["NormalIntro"]" Name="Normal">
9+
<Navbar>
10+
<NavbarBrand>
11+
<a>Navbar</a>
12+
</NavbarBrand>
13+
<NavbarToggleButton Target="#test"></NavbarToggleButton>
14+
<NavbarCollapse Id="test">
15+
<NavbarGroup IsScrolling="true">
16+
<NavbarLink>Home</NavbarLink>
17+
<NavbarLink Text="Link"></NavbarLink>
18+
<NavbarDropdown Text="Dropdown">
19+
<NavbarDropdownItem>
20+
<i class="fa-solid fa-fw fa-home"></i><span>Action</span>
21+
</NavbarDropdownItem>
22+
<NavbarDropdownItem>
23+
<i class="fa-solid fa-fw fa-flag"></i><span>Another action</span>
24+
</NavbarDropdownItem>
25+
<NavbarDropdownDivider></NavbarDropdownDivider>
26+
<NavbarDropdownItem>
27+
<i class="fa-solid fa-fw fa-home"></i><span>Something else here</span>
28+
</NavbarDropdownItem>
29+
</NavbarDropdown>
30+
<NavbarLink IsDisabled="true">Disabled</NavbarLink>
31+
<NavbarItem>
32+
<a class="nav-link">About</a>
33+
</NavbarItem>
34+
</NavbarGroup>
35+
<NavbarGroup>
36+
<ValidateForm class="d-flex" role="search" Model="_searchModel" OnValidSubmit="OnValidSubmit">
37+
<BootstrapInput class="me-2" placeholder="Search" @bind-Value="_searchModel.SearchText"
38+
ShowLabel="false" SkipValidate="true"></BootstrapInput>
39+
<Button Color="Color.Success" IsOutline="true" ButtonType="ButtonType.Submit">Search</Button>
40+
</ValidateForm>
41+
</NavbarGroup>
42+
</NavbarCollapse>
43+
</Navbar>
44+
<section ignore>
45+
<p class="code-label">Nav</p>
46+
<ul class="ul-demo mb-3">
47+
<li><code>Size</code>: 指定导航栏响应阈值,默认 <code>Size.Medium</code></li>
48+
<li><code>BackgroundColorCssClass</code>: 导航栏背景色样式,默认 null 未设置使用 <code>bg-body-tertiary</code></li>
49+
</ul>
50+
<p class="code-label">NavbarBrand</p>
51+
<p>渲染 <code>navbar-brand</code> 样式,导航栏 Brand 当屏幕宽度小于特定阈值时导航栏会响应式收起,<code>NavbarBrand</code> 的内容始终显示</p>
52+
<p class="code-label">NavbarToggleButton</p>
53+
<p>渲染 <code>navbar-toggler</code> 样式,导航栏中的折叠展开按钮,当屏幕宽度小于特定阈值时显示,通过设置参数 <code>Target</code> 值指定折叠展开组件 <code>NavbarCollapse</code></p>
54+
<p class="code-label">NavbarCollapse</p>
55+
<p>渲染 <code>collapse navbar-collapse</code> 样式,导航栏中的可折叠展开区域,通过设置参数 <code>Id</code> 值,与组件 <code>NavbarToggleButton</code> 联动</p>
56+
<p class="code-label">NavbarGroup</p>
57+
<p>渲染 <code>navbar-nav</code> 样式,导航栏中区域分组容器组件</p>
58+
<ul class="ul-demo">
59+
<li><code>IsScrolling</code>: 是否开启滚动条</li>
60+
<li><code>Height</code>: 组件高度,默认 <b>200px</b></li>
61+
</ul>
62+
<p class="code-label">NavbarItem</p>
63+
<p>渲染 <code>navbar-item</code> 样式,导航栏中单项容器组件,通过内置自定义组件或者 <code>Html</code> 实现导航项</p>
64+
<p class="code-label">NavbarLink</p>
65+
<p>渲染 <code>nav-link</code> 样式,导航栏中导航组件,内部渲染为 <code>a</code> 链接</p>
66+
<ul class="ul-demo">
67+
<li><code>Url</code>: 导航地址</li>
68+
<li><code>Target</code>: 导航目标</li>
69+
<li><code>ImageUrl</code>: 图片地址</li>
70+
<li><code>ImageCss</code>: 图片样式</li>
71+
</ul>
72+
<p class="code-label">NavbarDropdown</p>
73+
<p>渲染 <code>nav-item dropdown</code> 样式,导航栏中下拉菜单组件</p>
74+
<p class="code-label">NavbarDropdownItem</p>
75+
<p>渲染 <code>dropdown-item</code> 样式,导航栏中下拉菜单组件内项目</p>
76+
</section>
77+
</DemoBlock>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
using Microsoft.AspNetCore.Components.Forms;
7+
8+
namespace BootstrapBlazor.Server.Components.Samples;
9+
10+
/// <summary>
11+
/// Navbar 示例
12+
/// </summary>
13+
public partial class Navbars
14+
{
15+
private List<SelectedItem> _dropdownItems = [];
16+
private SearchModel _searchModel = new SearchModel();
17+
18+
/// <summary>
19+
/// <inheritdoc/>
20+
/// </summary>
21+
protected override void OnInitialized()
22+
{
23+
base.OnInitialized();
24+
25+
_dropdownItems.AddRange([
26+
new SelectedItem() { Text="Item1", Value="0"},
27+
new SelectedItem() { Text="Item2", Value="1"},
28+
new SelectedItem() { Text="Item3", Value="2"}
29+
]);
30+
}
31+
32+
private Task OnValidSubmit(EditContext context)
33+
{
34+
return Task.CompletedTask;
35+
}
36+
37+
class SearchModel
38+
{
39+
public string? SearchText { get; set; }
40+
}
41+
}

src/BootstrapBlazor.Server/Components/Samples/OpcDa.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@
5858
<div class="col-12 col-sm-6">
5959
<BootstrapInputGroup>
6060
<BootstrapInputGroupLabel DisplayText="转速"></BootstrapInputGroupLabel>
61-
<BootstrapInputGroupLabel DisplayText="@Tag3"></BootstrapInputGroupLabel>
61+
<BootstrapInputGroupLabel DisplayText="@Tag1"></BootstrapInputGroupLabel>
6262
<Display @bind-Value="@_tagValue3"></Display>
6363
</BootstrapInputGroup>
6464
</div>
6565
<div class="col-12 col-sm-6">
6666
<BootstrapInputGroup>
6767
<BootstrapInputGroupLabel DisplayText="流速"></BootstrapInputGroupLabel>
68-
<BootstrapInputGroupLabel DisplayText="@Tag4"></BootstrapInputGroupLabel>
68+
<BootstrapInputGroupLabel DisplayText="@Tag2"></BootstrapInputGroupLabel>
6969
<Display @bind-Value="@_tagValue4"></Display>
7070
</BootstrapInputGroup>
7171
</div>

0 commit comments

Comments
 (0)