-
-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Marquee): add Marquee component (#2225)
* feat: 新建Marquee滚动字幕组件 * feat: 添加scss变量 * doc: 更新示例 * refactor: 移除css变量 * doc: 更新示例 * feat: 添加MarqueeDirecTion文本滚动方向枚举类型 * doc: 添加注释 * doc: update localizer * doc: update navmenu localizer * refactor: 重构css * doc: update demo * doc: 更新资源文件 * doc: 更新源码文档映射 * refactor: 更改文件名 * refactor: 更改类名称 * refactor: 脚本增加保护 * refactor: 更新代码 * doc: 更新示例 * feat: ColorPicker 适配 InputGroup 组件 * refactor: 精简代码 * chore: 更新样式 * doc: 更新注释 * test: 增加单元测试 * chore: 更新打包脚本 * doc: 增加注释文档 * refactor: 增加异步检查逻辑防止报错 * refactor: 增加逗号符合规范 * test: 更新单元测试 --------- Co-authored-by: Argo-AscioTech <[email protected]>
- Loading branch information
Showing
17 changed files
with
433 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@page "/marquee" | ||
@inject IStringLocalizer<Marquees> Localizer | ||
|
||
<h3>@Localizer["MarqueeDescription"]</h3> | ||
|
||
<DemoBlock Title="@Localizer["MarqueeTitle"]" Introduction="@Localizer["MarqueeIntro"]" Name="Normal"> | ||
<section ignore> | ||
<h4>Options</h4> | ||
<BootstrapInputGroup> | ||
<BootstrapInputGroupLabel class="label-width" DisplayText="Direction" /> | ||
<RadioList @bind-Value="@Direction" /> | ||
</BootstrapInputGroup> | ||
<BootstrapInputGroup> | ||
<BootstrapInputGroupLabel class="label-width" DisplayText="Duration" /> | ||
<span class="input-group-text" style="width:48px">@Duration</span> | ||
<Slider @bind-Value="@Duration" Step="1" Min="15" Max="30" /> | ||
</BootstrapInputGroup> | ||
<BootstrapInputGroup> | ||
<BootstrapInputGroupLabel class="label-width" DisplayText="FontSize" /> | ||
<span class="input-group-text" style="width:48px">@FontSize</span> | ||
<Slider @bind-Value="@FontSize" Step="1" Min="20" Max="72" /> | ||
</BootstrapInputGroup> | ||
<BootstrapInputGroup> | ||
<BootstrapInputGroupLabel class="label-width" DisplayText="Text" /> | ||
<BootstrapInput TValue="string" @bind-Value="@Text" /> | ||
</BootstrapInputGroup> | ||
<BootstrapInputGroup> | ||
<BootstrapInputGroupLabel class="label-width" DisplayText="TextColor" /> | ||
<ColorPicker @bind-Value="@TextColor" /> | ||
</BootstrapInputGroup> | ||
<BootstrapInputGroup> | ||
<BootstrapInputGroupLabel class="label-width" DisplayText="BackgroundColor" /> | ||
<ColorPicker @bind-Value="@BackgroundColor" /> | ||
</BootstrapInputGroup> | ||
</section> | ||
|
||
<Marquee Text="@Text" Color="@TextColor" BackgroundColor="@BackgroundColor" | ||
Duration="@Duration" DirecTion="@Direction" FontSize="@FontSize" /> | ||
</DemoBlock> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Argo Zhang ([email protected]). All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
// Website: https://www.blazor.zone or https://argozhang.github.io/ | ||
|
||
namespace BootstrapBlazor.Shared.Samples; | ||
|
||
/// <summary> | ||
/// Marquee 组件 | ||
/// </summary> | ||
public partial class Marquees | ||
{ | ||
private string BackgroundColor { get; set; } = "#000000"; | ||
|
||
private string TextColor { get; set; } = "#ff0000"; | ||
|
||
private string Text { get; set; } = "BootstrapBlazor 组件库,基于 Bootstrap 样式库精心打造,为您快速开发项目带来飞一般的感觉"; | ||
|
||
private int FontSize { get; set; } = 72; | ||
|
||
private int Duration { get; set; } = 20; | ||
|
||
private MarqueeDirection Direction { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
::deep .label-width { | ||
width: 150px; | ||
} | ||
|
||
::deep > .input-group { | ||
margin-bottom: .5rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@namespace BootstrapBlazor.Components | ||
@inherits BootstrapComponentBase | ||
|
||
<div @attributes="AdditionalAttributes" class="@ClassString" style="@StyleString"> | ||
<span class="@TextClassString" style="@TextStyleString">@Text</span> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright (c) Argo Zhang ([email protected]). All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
// Website: https://www.blazor.zone or https://argozhang.github.io/ | ||
|
||
namespace BootstrapBlazor.Components; | ||
|
||
/// <summary> | ||
/// Marquee 字幕滚动组件 | ||
/// </summary> | ||
public partial class Marquee | ||
{ | ||
/// <summary> | ||
/// 获得/设置 组件值 显示文本 默认 Empty | ||
/// </summary> | ||
[Parameter] | ||
public string? Text { get; set; } | ||
|
||
/// <summary> | ||
/// 获得/设置 组件值 文本颜色 默认 #000 | ||
/// <para>支持16进制和颜色名称</para> | ||
/// </summary> | ||
[Parameter] | ||
public string Color { get; set; } = "#000"; | ||
|
||
/// <summary> | ||
/// 获得/设置 组件值 背景颜色 默认 #fff | ||
/// <para>支持16进制和颜色名称</para> | ||
/// </summary> | ||
[Parameter] | ||
public string BackgroundColor { get; set; } = "#fff"; | ||
|
||
/// <summary> | ||
/// 获得/设置 组件值 文本大小 默认 72px | ||
/// </summary> | ||
[Parameter] | ||
public int FontSize { get; set; } = 72; | ||
|
||
/// <summary> | ||
/// 获得/设置 组件值 动画时间 默认 14s | ||
/// <para>值越小滚动越快</para> | ||
/// </summary> | ||
[Parameter] | ||
public int Duration { get; set; } = 14; | ||
|
||
/// <summary> | ||
/// 获得/设置 组件值 滚动方向 默认 LeftToRight | ||
/// </summary> | ||
[Parameter] | ||
public MarqueeDirection Direction { get; set; } | ||
|
||
private string? ClassString => CssBuilder.Default("marquee") | ||
.AddClass("marquee-vertical", Direction == MarqueeDirection.TopToBottom || Direction == MarqueeDirection.BottomToTop) | ||
.AddClassFromAttributes(AdditionalAttributes) | ||
.Build(); | ||
|
||
private string? StyleString => CssBuilder.Default() | ||
.AddClass($"background-color: {BackgroundColor};") | ||
.AddClass($"color: {Color};") | ||
.AddClass($"font-size: {FontSize}px;") | ||
.Build(); | ||
|
||
private string? TextClassString => CssBuilder.Default("marquee-text") | ||
.AddClass($"marquee-text-left", Direction == MarqueeDirection.LeftToRight || Direction == MarqueeDirection.RightToLeft) | ||
.AddClass($"marquee-text-top", Direction == MarqueeDirection.TopToBottom || Direction == MarqueeDirection.BottomToTop) | ||
.Build(); | ||
|
||
private string? TextStyleString => CssBuilder.Default() | ||
.AddClass($"animation-duration: {Duration}s;") | ||
.AddClass($"animation-name: {Direction.ToDescriptionString()};") | ||
.Build(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
.marquee { | ||
overflow: hidden; | ||
white-space: nowrap; | ||
position: relative; | ||
|
||
&.marquee-vertical { | ||
writing-mode: vertical-rl; | ||
text-orientation: upright; | ||
} | ||
|
||
.marquee-text { | ||
display: inline-block; | ||
animation-timing-function: linear; | ||
animation-iteration-count: infinite; | ||
|
||
&.marquee-text-left { | ||
padding-left: 100%; | ||
} | ||
|
||
&.marquee-text-top { | ||
padding-top: 100%; | ||
} | ||
} | ||
} | ||
|
||
@keyframes RightToLeft { | ||
from { | ||
transform: translateX(0); | ||
} | ||
|
||
to { | ||
transform: translateX(-100%); | ||
} | ||
} | ||
|
||
@keyframes LeftToRight { | ||
from { | ||
transform: translateX(-100%); | ||
} | ||
|
||
to { | ||
transform: translateX(0); | ||
} | ||
} | ||
|
||
@keyframes TopToBottom { | ||
from { | ||
transform: translateY(-100%); | ||
} | ||
|
||
to { | ||
transform: translateY(0); | ||
} | ||
} | ||
|
||
@keyframes BottomToTop { | ||
from { | ||
transform: translateY(0); | ||
} | ||
|
||
to { | ||
transform: translateY(-100%); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) Argo Zhang ([email protected]). All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
// Website: https://www.blazor.zone or https://argozhang.github.io/ | ||
|
||
using System.ComponentModel; | ||
|
||
namespace BootstrapBlazor.Components; | ||
|
||
/// <summary> | ||
/// Marquee组件,文本滚动方向枚举类型 | ||
/// <para>Marquee component, Text scrolling direction enumeration</para> | ||
/// </summary> | ||
public enum MarqueeDirection | ||
{ | ||
/// <summary> | ||
/// 文本从左向右滚动 | ||
/// scrolling text from left to right | ||
/// </summary> | ||
[Description("LeftToRight")] | ||
LeftToRight, | ||
|
||
/// <summary> | ||
/// 文本从右向左滚动 | ||
/// scrolling text from right to left | ||
/// </summary> | ||
[Description("RightToLeft")] | ||
RightToLeft, | ||
|
||
/// <summary> | ||
/// Marquee组件,从上到下滚动文本 | ||
/// scrolling text from top to bottom | ||
/// </summary> | ||
[Description("TopToBottom")] | ||
TopToBottom, | ||
|
||
/// <summary> | ||
/// 从下至上滚动文本> | ||
/// Scroll text from bottom to top | ||
/// </summary> | ||
[Description("BottomToTop")] | ||
BottomToTop | ||
} |
2 changes: 1 addition & 1 deletion
2
src/BootstrapBlazor/wwwroot/css/bootstrap.blazor.bundle.min.css
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.