Skip to content

Commit d967b41

Browse files
ArgoZhangYSMC-W
andauthored
feat(Compact): add DevUI compact style file (#4919)
* refactor: 改造主题选择器 * refactor: 更新样式 * chore: 更新依赖 * style: 样式参数变量化 * style: 更新样式 * style: 更新组件样式变量 * style: 调整组件样式变量 * chore: 更新依赖包 * style: 更新 Display 组件样式 * style: 调整组件样式 * style: 增加日历组件样式 * style: 更新多选下拉框样式 * style: 更新 radio-list 样式 * refactor: 重构脚本 * chore: 更新配置文件 Co-Authored-By: YSMC <[email protected]> --------- Co-authored-by: YSMC <[email protected]>
1 parent b99def5 commit d967b41

File tree

11 files changed

+198
-48
lines changed

11 files changed

+198
-48
lines changed

src/BootstrapBlazor.Server/Components/Components/DemoBlock.razor.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@
8585
font-weight: var(--bb-font-weight);
8686
color: var(--bs-body-color);
8787
font-size: var(--bb-sub-font-size);
88-
margin-top: 1rem;
89-
margin-bottom: .5rem;
88+
margin-top: var(--bb-demo-block-margin-top);
89+
margin-bottom: var(--bb-demo-block-margin-bottom);
9090
}
9191

9292
::deep .table-cell .progress {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99

1010
.pre-code:not(:last-child) {
11-
margin-bottom: 1rem;
11+
margin-bottom: var(--bb-pre-margin-bottom);
1212
}
1313

1414
.pre-code .loading {
@@ -30,7 +30,7 @@
3030
}
3131

3232
code {
33-
line-height: 1.8;
33+
line-height: var(--bb-code-line-height);
3434
font-size: 0.75rem;
3535
padding: 10px 65px 10px 16px;
3636
display: block;

src/BootstrapBlazor.Server/Components/Components/ThemeChooser.razor

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
@attribute [JSModuleAutoLoader("Components/ThemeChooser.razor.js")]
33
@inject IOptionsMonitor<WebsiteOptions> WebsiteOption
44

5+
<HeadContent>
6+
@foreach (var css in _currentTheme)
7+
{
8+
<link rel="stylesheet" href="@css" />
9+
}
10+
</HeadContent>
11+
512
<div id="@Id" class="theme">
613
<PulseButton class="btn-fade btn-theme" Color="Color.None" ImageUrl="@WebsiteOption.CurrentValue.GetAssetUrl("images/m.svg")" TooltipText="@Title" TooltipPlacement="Placement.Left" />
714
<div class="theme-list">

src/BootstrapBlazor.Server/Components/Components/ThemeChooser.razor.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public partial class ThemeChooser
2323
[NotNull]
2424
private IStringLocalizer<ThemeChooser>? Localizer { get; set; }
2525

26+
private readonly List<string> _currentTheme = [];
27+
2628
/// <summary>
2729
/// OnInitialized 方法
2830
/// </summary>
@@ -36,13 +38,14 @@ protected override void OnInitialized()
3638
WebsiteOption.CurrentValue.CurrentTheme = "bootstrap";
3739
}
3840

39-
private async Task OnClickTheme(SelectedItem item)
41+
private void OnClickTheme(SelectedItem item)
4042
{
43+
_currentTheme.Clear();
4144
WebsiteOption.CurrentValue.CurrentTheme = item.Value;
4245
var theme = WebsiteOption.CurrentValue.Themes.Find(i => i.Key == item.Value);
43-
if (theme != null)
46+
if (theme is { Files: not null })
4447
{
45-
await InvokeVoidAsync("updateTheme", [theme.Files]);
48+
_currentTheme.AddRange(theme.Files);
4649
}
4750
}
4851

src/BootstrapBlazor.Server/Components/Components/ThemeChooser.razor.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@
6464
}
6565

6666
::deep .btn-theme img {
67-
width: 20px;
67+
width: 100%;
6868
}

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

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,18 @@ export function init(id) {
99
}
1010
const themeList = el.querySelector('.theme-list')
1111

12-
const chooser = { el, themeList }
13-
Data.set(id, chooser);
12+
Data.set(id, { el });
1413

1514
EventHandler.on(el, 'click', () => {
1615
themeList.classList.toggle('is-open')
1716
})
1817
}
1918

20-
export function updateTheme(args) {
21-
const links = document.querySelectorAll('link')
22-
if (links) {
23-
const link = [].slice.call(links).filter(function (item) {
24-
const href = item.getAttribute('href')
25-
return href.indexOf('css/site.css') > -1
26-
});
27-
const original = link[0];
28-
while (original.nextElementSibling && original.nextElementSibling.nodeName === 'LINK') {
29-
original.nextElementSibling.remove()
30-
}
31-
32-
args.forEach(function (c) {
33-
const link = document.createElement('link')
34-
link.setAttribute('rel', 'stylesheet')
35-
link.setAttribute('href', c)
36-
37-
insertAfter(original, link)
38-
});
39-
}
40-
}
41-
4219
export function dispose(id) {
43-
const chooser = Data.get(id)
20+
const theme = Data.get(id)
4421
Data.remove(id)
4522

46-
if (chooser) {
47-
EventHandler.off(chooser.el, 'click')
23+
if (theme) {
24+
EventHandler.off(theme.el, 'click')
4825
}
4926
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
::deep .btn-fade {
2-
--bb-button-circle-width: 40px;
3-
--bb-button-circle-height: 40px;
42
opacity: 0.7;
53
box-shadow: var(--bb-layout-button-shadow);
64
transition: opacity .3s linear;

src/BootstrapBlazor.Server/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
},
105105
{
106106
"key": "devui",
107-
"name": "DevUI (制作中)",
107+
"name": "DevUI",
108108
"files": [
109109
"./css/devui.css"
110110
]
Lines changed: 155 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,158 @@
11
:root {
2-
/* --bs-border-radius: 5px;
2+
--bs-border-radius: 4px;
33
--bb-font-size: .75rem;
4-
--bs-nav-link-font-size: .875rem;
5-
*/
4+
--bs-nav-link-font-size: .75rem;
5+
--bb-sub-font-size: .75rem;
6+
--bb-mb-3: .25rem;
7+
--bb-space: .25rem;
8+
--bb-row-control-padding: 4px;
9+
--bb-header-font-size: 0.875rem;
10+
--bb-padding: 0.1875rem 0.375rem;
11+
--bb-title-font-size: 0.875rem;
12+
--bb-pre-margin-bottom: .5rem;
13+
--bb-row-control-padding: 3px;
14+
--bb-height: 26px;
15+
}
16+
17+
p {
18+
margin-bottom: var(--bb-mb-3);
19+
}
20+
21+
code {
22+
--bb-code-line-height: 1.5;
23+
}
24+
25+
pre code.hljs {
26+
padding: var(--bb-space);
27+
}
28+
29+
.navbar-header {
30+
--bs-nav-link-font-size: var(--bb-header-font-size);
31+
--bb-font-size: var(--bb-header-font-size);
32+
}
33+
34+
.navbar-header .bb-g-search {
35+
--bb-global-search-padding: var(--bb-padding);
36+
}
37+
38+
.mb-3 {
39+
margin-bottom: var(--bb-mb-3) !important;
40+
}
41+
42+
.btn {
43+
font-size: var(--bb-font-size);
44+
--bs-btn-padding-x: 0.5rem;
45+
--bs-btn-padding-y: 0.1875rem;
46+
--bs-btn-xs-padding-x: 0.3125rem;
47+
--bs-btn-xs-padding-y: 0.0625rem;
48+
--bs-btn-xs-font-size: 0.75rem;
49+
--bs-btn-xl-padding-x: 1.25rem;
50+
--bs-btn-xl-padding-y: 0.8rem;
51+
--bs-btn-xl-font-size: 1.25rem;
52+
--bs-btn-xxl-padding-x: 1.25rem;
53+
--bs-btn-xxl-padding-y: 0.8rem;
54+
--bs-btn-xxl-font-size: 1.5rem;
55+
}
56+
57+
.btn-circle {
58+
--bb-button-circle-width: 35px;
59+
--bb-button-circle-height: 35px;
60+
}
61+
62+
.form-check {
63+
--bb-checkbox-label-padding-y: 3px;
64+
}
65+
66+
.form-control-color {
67+
height: 26px;
68+
}
69+
70+
.card {
71+
--bs-card-spacer-x: var(--bb-space);
72+
--bs-card-spacer-y: var(--bb-space);
73+
--bs-card-cap-padding-x: var(--bb-space);
74+
}
75+
76+
.col-form-label {
77+
padding: 4px 2px;
78+
}
79+
80+
.alert {
81+
--bs-alert-margin-bottom: var(--bb-mb-3);
82+
}
83+
84+
.datetime-picker {
85+
--bb-dt-picker-input-padding: 3px 33px 3px 12px;
86+
--bb-dt-picker-input-icon-padding: 3px 33px
87+
}
88+
89+
.demo-block {
90+
--bb-demo-block-margin-top: .5rem;
91+
--bb-demo-block-margin-bottom: .25rem;
92+
}
93+
94+
.my-3 {
95+
margin: .5rem !important;
96+
}
97+
98+
.g-3, .gy-3 {
99+
--bs-gutter-y: .25rem;
100+
}
101+
102+
.g-3, .gx-3 {
103+
--bs-gutter-x: .5rem;
104+
}
105+
106+
.groupbox {
107+
--bb-groupbox-padding: 1rem .5rem .5rem .5rem
108+
}
109+
110+
.form-control {
111+
--bb-form-control-padding: var(--bb-padding);
112+
}
113+
114+
.form-label {
115+
margin-bottom: .25rem;
116+
}
117+
118+
.input-group-text {
119+
padding: var(--bb-padding);
120+
}
121+
122+
.input-group > .switch {
123+
--bb-switch-padding: 2px .5rem;
124+
}
125+
126+
.popover {
127+
--bs-popover-font-size: var(--bb-font-size);
128+
}
129+
130+
.select {
131+
--bb-select-padding: var(--bb-padding);
132+
}
133+
134+
.switch {
135+
--bb-switch-padding: 3px 0;
136+
}
137+
138+
.multiselect {
139+
--bb-multi-select-item-margin-x: 1px;
140+
--bb-multi-select-item-margin-y: 1px;
141+
--bb-multi-select-item-padding: 1px 4px;
142+
--bb-multi-select-min-height: 26px;
143+
--bb-multi-select-max-height: 26px;
144+
}
145+
146+
.radio-list {
147+
--bb-radio-item-padding: 2px 0.75rem;
148+
}
149+
150+
.table-container {
151+
--bb-table-td-padding-x: .25rem;
152+
--bb-table-td-padding-y: .25rem;
153+
}
154+
155+
.tabs {
156+
--bb-tabs-item-height: 29px;
157+
--bb-tabs-body-padding: .5rem;
6158
}

src/BootstrapBlazor.Server/wwwroot/css/site.css

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
--bb-sidebar-body-hover-bg: rgba(175, 184, 193, 0.2);
3838
--bb-sidebar-body-drag-hover-bg: rgb(9, 105, 218);
3939
--bb-code-bg: #e9ecef;
40+
--bb-mb-3: 1rem;
41+
--bb-pre-margin-bottom: 1rem;
4042
--bb-header-select-width: 230px;
4143
--bb-header-search-margin-bottom: .5rem;
4244
}
@@ -56,7 +58,7 @@ html .search-dialog-mask {
5658
}
5759

5860
h3, h4, h5 {
59-
margin-bottom: 1rem;
61+
margin-bottom: var(--bb-mb-3);
6062
}
6163

6264
#blazor-error-ui {
@@ -224,11 +226,11 @@ code {
224226

225227
.code-label + img,
226228
.pre-code + img {
227-
margin-bottom: 1rem;
229+
margin-bottom: var(--bb-mb-3);
228230
}
229231

230232
.code-quest {
231-
margin-bottom: 1rem;
233+
margin-bottom: var(--bb-mb-3);
232234
font-weight: bold;
233235
}
234236

@@ -287,11 +289,11 @@ code {
287289
}
288290

289291
.card-body > section:not(:first-child) {
290-
margin-top: 1rem;
292+
margin-top: var(--bb-mb-3);
291293
}
292294

293295
.card-body > section:not(:last-child) {
294-
margin-bottom: 1rem;
296+
margin-bottom: var(--bb-mb-3);
295297
}
296298

297299
.custom-clock {
@@ -301,6 +303,15 @@ code {
301303
width: 320px;
302304
}
303305

306+
.demo-block {
307+
--bb-demo-block-margin-top: 1rem;
308+
--bb-demo-block-margin-bottom: .5rem;
309+
}
310+
311+
code {
312+
--bb-code-line-height: 1.6;
313+
}
314+
304315
@media (min-width: 768px) {
305316
:root {
306317
--bs-header-height: 50px;

0 commit comments

Comments
 (0)