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

doc(Theme): add dark theme for web site #2630

Merged
merged 50 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
12cc47f
refactor: 更新标签颜色
ArgoZhang Dec 19, 2023
a4a06a0
refactor: 更新 main 最小高度
ArgoZhang Dec 19, 2023
ee1fb7a
doc: 移除侧边栏背景色
ArgoZhang Dec 19, 2023
ccf5031
doc: 更新代码高亮背景色
ArgoZhang Dec 19, 2023
8a54682
doc: 去除权重关键字
ArgoZhang Dec 19, 2023
e492802
refactor: 更新 Select 组件背景色
ArgoZhang Dec 20, 2023
af08a49
refactor: 增加 primary 颜色样式
ArgoZhang Dec 20, 2023
43acba2
refactor: 增加 icon-summary 样式
ArgoZhang Dec 20, 2023
57f294b
refactor: 增加 badge-menu 样式
ArgoZhang Dec 20, 2023
e433ced
refactor: 更新 archor-link 颜色
ArgoZhang Dec 20, 2023
6458fd6
refactor: 更新 dropdown-item menu-item 颜色样式
ArgoZhang Dec 20, 2023
ad6ee0d
refactor: 更新 GlobalSearch 样式
ArgoZhang Dec 20, 2023
d7108a3
refactor: 调整边框颜色
ArgoZhang Dec 20, 2023
1fe5bef
refactor: 调整 Tab 样式
ArgoZhang Dec 20, 2023
24b09b8
refactor: 调整 Divider 样式
ArgoZhang Dec 20, 2023
c00a0fe
refactor: 更新 tab header 背景色
ArgoZhang Dec 20, 2023
fceaf93
refactor: 更新当前标签页颜色
ArgoZhang Dec 20, 2023
a4b5f50
feat: 增加暗黑主题
ArgoZhang Dec 20, 2023
adfcdf1
refactor: 更新主题切换逻辑
ArgoZhang Dec 20, 2023
82bf46b
refactor: 增加 hover 样式
ArgoZhang Dec 20, 2023
7a3615f
refactor: 增加黑色主题样式支持
ArgoZhang Dec 20, 2023
fa67c3f
refactor: 增加 navbar-version 样式
ArgoZhang Dec 20, 2023
c7e4663
refactor: 更新右侧边框样式
ArgoZhang Dec 20, 2023
7770aaa
refactor: 自定义菜单项前景色
ArgoZhang Dec 20, 2023
6297286
refactor: 微调 tips 样式
ArgoZhang Dec 20, 2023
de9eb91
refactor: 更新圆角
ArgoZhang Dec 21, 2023
390c566
feat: 客户端存储主题
ArgoZhang Dec 21, 2023
b410e42
feat: 增加主题脚本
ArgoZhang Dec 21, 2023
39e269c
refactor: 复用设置主题代码
ArgoZhang Dec 21, 2023
aff645b
chore: 更新 sasscompiler 配置
ArgoZhang Dec 21, 2023
4b83e80
refactor: 移除 motronic 样式
ArgoZhang Dec 21, 2023
a25d9be
doc: 更新文档
ArgoZhang Dec 21, 2023
49770a9
chore: 更新配置文件
ArgoZhang Dec 21, 2023
140838d
refactor: 精简 Table 样式
ArgoZhang Dec 21, 2023
ffe8066
refactor: 更新分页组件暗黑样式
ArgoZhang Dec 21, 2023
63c9d89
refactor: 更新 code 样式
ArgoZhang Dec 21, 2023
304ad05
refactor: 调整 Card 样式
ArgoZhang Dec 21, 2023
84fab86
refactor: 调整 Table 暗黑样式
ArgoZhang Dec 21, 2023
b922fda
refactor: 调整 btn-copy 按钮样式
ArgoZhang Dec 22, 2023
d8a3b9f
refactor: 调整 ConsoleLogger 样式
ArgoZhang Dec 22, 2023
0ae67dd
refactor: 调整侧边栏边框
ArgoZhang Dec 22, 2023
2debf69
doc: 微调间隙
ArgoZhang Dec 22, 2023
874445d
refactor: 调整全局搜索样式
ArgoZhang Dec 22, 2023
2ec34fd
refactor: 更新 Select 组件样式
ArgoZhang Dec 22, 2023
92ac561
refactor: 更新文化组件样式
ArgoZhang Dec 22, 2023
a5152e3
refactor: 统一 border 颜色
ArgoZhang Dec 22, 2023
51f31f6
refactor: 调整重连组件样式
ArgoZhang Dec 22, 2023
5e849cc
refactor: 微调 Header 样式
ArgoZhang Dec 22, 2023
27b9675
refactor: 适配全局搜索暗黑样式
ArgoZhang Dec 22, 2023
2213f80
refactor: 适配主题样式
ArgoZhang Dec 22, 2023
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,4 @@ src/**/wwwroot/**/uploader
# sass
**/BootstrapBlazor/wwwroot/scss/theme/*.css
**/BootstrapBlazor/wwwroot/scss/theme/*.css.map
**/BootstrapBlazor/wwwroot/css/bootstrap.blazor.bundle.min.css
**/BootstrapBlazor/wwwroot/css/*.css
4 changes: 2 additions & 2 deletions src/BootstrapBlazor.Server/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@inject IStringLocalizer<App> Localizer

<!DOCTYPE html>
<html lang="en">
<html lang="en" data-bs-theme='light'>

<head>
<meta charset="utf-8" />
Expand All @@ -22,9 +22,9 @@
<link rel="stylesheet" href="_content/BootstrapBlazor/css/motronic.min.css">
<link rel="stylesheet" href="BootstrapBlazor.Server.styles.css">
<link rel="stylesheet" href="css/site.css">
<link rel="stylesheet" href="css/motronic.css">
<title>@Localizer["Title"]</title>
<HeadOutlet @rendermode="new InteractiveServerRenderMode(false)" />
<script src="lib/theme.js" type="module"></script>
</head>

<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
width: 42px;
height: auto;
border-radius: var(--bs-border-radius);
background-color: var(--bs-info);
background-color: var(--bb-primary-color);
border: solid 1px #fff;
margin-right: 1rem;
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
.culture-selector {
--bs-border-color: rgba(255,255,255,.2);
--bb-border-hover-color: rgba(255,255,255,.8);
--bb-select-color: rgba(255,255,255,.85);
display: flex;
align-items: center;
color: var(--bb-select-color);
}

.culture-selector span {
margin: 0;
color: var(--bs-navbar-color);
opacity: 0.85;
}

.culture-selector ::deep .select {
width: 210px;
}

.culture-selector ::deep .dropdown-menu {
--bs-dropdown-link-active-bg: #7532f9;
}
::deep .form-control {
transition: border-color .3s linear;
}

::deep .dropdown-toggle {
--bs-body-bg: transparent;
}


::deep .form-select {
color: var(--bb-select-color);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
opacity: 1;
}

[data-bs-theme='dark'] .card:hover {
box-shadow: none;
}

.card-footer {
background-color: transparent;
Expand Down Expand Up @@ -81,7 +84,7 @@

.demo-block > ::deep .anchor-link {
font-weight: var(--bb-font-weight);
color: var(--bb-title-color);
color: var(--bs-body-color);
font-size: var(--bb-sub-font-size);
margin-top: 1rem;
margin-bottom: .5rem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="d-none d-xl-flex flex-xl-fill justify-content-xl-end px-3">
<Search PlaceHolder="@Localizer["Search"]" IsSelectAllTextOnEnter="true" IsSelectAllTextOnFocus="true" IsLikeMatch="true" Items="@ComponentItems" SearchButtonText="" OnSearch="OnSearch" OnSelectedItemChanged="OnSelectedItemChanged" SearchButtonColor="Color.None" class="btn-search" />
<Search PlaceHolder="@Localizer["Search"]" IsSelectAllTextOnEnter="true" IsSelectAllTextOnFocus="true" IsLikeMatch="true" Items="@ComponentItems" SearchButtonText="" OnSearch="OnSearch" OnSelectedItemChanged="OnSelectedItemChanged" SearchButtonColor="Color.None" />
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

::deep .auto-complete {
--bb-complete-border-color: rgba(255,255,255,.2);
--bs-border-width: 0;
--bb-complete-color: rgba(255,255,255,.85);
border: 1px solid var(--bb-complete-border-color);
border-radius: var(--bs-border-radius);
transition: border-color .3s linear;
}

::deep .form-control {
background-color: transparent;
color: var(--bb-complete-color);
}

::deep .form-control::placeholder {
color: rgba(255,255,255,.4);
}

::deep .auto-complete:hover {
--bb-complete-border-color: rgba(255,255,255,.8);
}

::deep .btn {
color: var(--bb-complete-color);
}
5 changes: 5 additions & 0 deletions src/BootstrapBlazor.Server/Components/Components/Header.razor
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@
</li>
</ul>
<a class="btn btn-bd-download d-none d-lg-inline-block mb-3 mb-md-0 ms-md-3" target="_blank" href="@DownloadUrl">@DownloadText</a>
<div class="navbar-version ms-2">v8.0.6-beta01</div>
<div class="ms-2 icon-theme">
<img src="./images/theme-light.svg" class="icon-light" />
<img src="./images/theme-night.svg" class="icon-dark" />
</div>
</header>

45 changes: 26 additions & 19 deletions src/BootstrapBlazor.Server/Components/Components/Header.razor.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
header {
--bb-violet-rgb: 112.520718,44.062154,249.437846;
background-color: transparent;
background-image: linear-gradient(to bottom, rgba(var(--bb-violet-rgb), 1), rgba(var(--bb-violet-rgb), 0.95));
background-image: linear-gradient(to right, rgba(var(--bb-violet-rgb), 1), rgba(var(--bb-violet-rgb), 0.9));
box-shadow: 0 0.5rem 1rem rgba(0,0,0,.05), inset 0 -1px 0 rgba(0,0,0,.1);
font-size: 1rem;
transition: transform .3s ease;
Expand All @@ -14,24 +14,6 @@
margin-right: 0;
}

::deep .btn-search .btn {
--bs-btn-bg: #8759ff;
--bs-btn-color: #fff;
--bs-btn-hover-bg: #7d53eb;
--bs-btn-hover-color: var(--bs-btn-color);
--bs-btn-hover-border-color: var(--bs-btn-hover-bg);
--bs-btn-active-bg: var(--bs-btn-hover-bg);
--bs-btn-active-color: var(--bs-btn-hover-color);
--bs-btn-active-border-color: var(--bs-btn-hover-border-color);
}

::deep .btn-search .form-control {
--bs-border-color: #fff;
--bb-border-focus-color: var(--bs-border-color);
--bb-border-hover-color: var(--bs-border-color);
z-index: 6;
}

::deep .btn-fs {
margin-top: 2px;
}
Expand All @@ -54,6 +36,31 @@
width: auto;
}

.navbar-version {
color: var(--bs-navbar-color);
}

.icon-theme {
border-left: 1px solid #dddddd40;
padding-left: 0.5rem;
}

.icon-theme img {
cursor: pointer;
}

.icon-theme .icon-dark {
display: none;
}

[data-bs-theme='dark'] .icon-dark {
display: block;
}

[data-bs-theme='dark'] .icon-light {
display: none;
}

@media (min-width: 768px) {
.navbar-header {
position: sticky;
Expand Down
17 changes: 16 additions & 1 deletion src/BootstrapBlazor.Server/Components/Components/Header.razor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import EventHandler from "../../_content/BootstrapBlazor/modules/event-handler.js?v=$version"
import { getPreferredTheme, setTheme } from "../../_content/BootstrapBlazor/modules/theme.js?v=$version"
import EventHandler from "../../_content/BootstrapBlazor/modules/event-handler.js?v=$version"

export function init() {
const scrollTop = () => (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop
Expand All @@ -13,6 +14,20 @@ export function init() {
}
prevScrollTop = currentScrollTop
})

const themeElement = document.querySelector('.icon-theme');
if (themeElement) {
EventHandler.on(themeElement, 'click', e => {
let theme = getPreferredTheme();
if (theme === 'dark') {
theme = 'light';
}
else {
theme = 'dark';
}
setTheme(theme);
});
}
}

export function dispose() {
Expand Down
11 changes: 0 additions & 11 deletions src/BootstrapBlazor.Server/Components/Components/Pre.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@
display: none;
}

::deep .btn-primary {
position: absolute;
top: .65rem;
right: 1.5rem;
font-size: 65%;
--bs-btn-color: var(--bs-primary);
--bs-btn-bg: #fff;
--bs-btn-padding-y: .25rem;
--bs-btn-padding-x: .5rem;
}

::deep .btn-group {
position: absolute;
top: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
@if (Count > 0)
{
<Badge Color="Color.Info" IsPill="true">
<Badge Color="Color.None" IsPill="true" class="badge-menu">
@Count
</Badge>
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
</Alert>

@code {

/// <summary>
/// 获得/设置 图标
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@
margin-bottom: 0;
max-height: 260px;
}

main {
min-height: calc(100vh - var(--bs-header-height));
}
14 changes: 2 additions & 12 deletions src/BootstrapBlazor.Server/Components/Layout/MainLayout.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,9 @@
margin-bottom: 0;
}

::deep p code,
::deep li code {
display: inline-block;
padding: 0px 8px;
background-color: #e9ecef;
margin: 0;
border-radius: var(--bs-border-radius);
}

::deep .code-label {
font-weight: bold;
color: #333;
color: var(--bs-body-color);
margin-bottom: 8px;
}

Expand Down Expand Up @@ -84,8 +75,7 @@
height: calc(100vh);
position: sticky;
top: 0;
border-right: solid 1px #c0c4cc;
background-color: #f0f0f0;
border-right: solid 1px var(--bs-border-color);
margin-top: calc(var(--bs-header-height)*-1);
}

Expand Down
12 changes: 10 additions & 2 deletions src/BootstrapBlazor.Server/Components/Layout/NavMenu.razor.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.sidebar-switch {
display: flex;
border-bottom: solid 1px #c0c4cc;
border-bottom: solid 1px var(--bs-border-color);
justify-content: center;
align-items: center;
}
Expand Down Expand Up @@ -31,7 +31,7 @@
top: 0;
right: 0;
bottom: 0;
background-color: rgb(208, 215, 222);
background-color: var(--bs-border-color);
}

.sidebar-bar .sidebar-body {
Expand All @@ -50,6 +50,14 @@
background-color: rgb(9, 105, 218);
}

::deep .badge-menu {
background-color: var(--bb-primary-color);
}

::deep .icon-summary {
color: var(--bb-primary-color);
}

@media (min-width: 768px) {
.sidebar-content {
height: calc(100vh - var(--bs-header-height));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
height: 50px;
align-items: center;
padding: 1rem;
border-bottom: solid 1px #c0c4cc;
border-bottom: solid 1px var(--bs-border-color);
display: none;
}

Expand Down Expand Up @@ -57,9 +57,8 @@
height: calc(100vh);
position: sticky;
top: 0;
border-right: solid 1px #c0c4cc;
background-color: #f0f0f0;
margin-top: calc(var(--bs-header-height)*-1);
border-right: solid 1px var(--bs-border-color);
margin-top: calc(var(--bs-header-height) * -1);
}

.main {
Expand Down
6 changes: 5 additions & 1 deletion src/BootstrapBlazor.Server/Components/Pages/Coms.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

.coms-search .row {
padding: 1rem 0;
background: #fff;
background: var(--bs-body-bg);
}

.coms-search-filter {
Expand All @@ -15,6 +15,10 @@
background: linear-gradient(rgba(255,255,255,1),rgba(255,255,255,0.8),rgba(255,255,255,0));
}

[data-bs-theme='dark'] .coms-search-filter {
background: linear-gradient(rgba(33,37,41,1),rgba(33,37,41,0.8),rgba(33,37,41,0));
}

@media (min-width: 768px) {
.coms-search {
top: 3rem;
Expand Down
Loading