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

Add Color and Size parameters to BitCompoundButton (#5978) #5979

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace Bit.BlazorUI;

public partial class BitCompoundButton
{
private BitButtonSize? size;
private BitButtonColor? color;
private BitButtonStyle buttonStyle = BitButtonStyle.Primary;

private int? _tabIndex;
Expand Down Expand Up @@ -60,6 +62,22 @@ public BitButtonStyle ButtonStyle
/// </summary>
[Parameter] public BitCompoundButtonClassStyles? Classes { get; set; }

/// <summary>
/// The color of button
/// </summary>
[Parameter]
public BitButtonColor? Color
{
get => color;
set
{
if (color == value) return;

color = value;
ClassBuilder.Reset();
}
}

/// <summary>
/// The value of the href attribute of the link rendered by the BitCompoundButton. If provided, the component will be rendered as an anchor.
/// </summary>
Expand All @@ -85,6 +103,22 @@ public BitButtonStyle ButtonStyle
/// </summary>
[Parameter] public RenderFragment? SecondaryTemplate { get; set; }

/// <summary>
/// The size of button, Possible values: Small | Medium | Large
/// </summary>
[Parameter]
public BitButtonSize? Size
{
get => size;
set
{
if (size == value) return;

size = value;
ClassBuilder.Reset();
}
}

/// <summary>
/// Custom CSS styles for different parts of the BitCompoundButton.
/// </summary>
Expand All @@ -107,9 +141,31 @@ protected override void RegisterCssClasses()
{
ClassBuilder.Register(() => Classes?.Root);

ClassBuilder.Register(() => ButtonStyle == BitButtonStyle.Primary
? $"{RootElementClass}-pri"
: $"{RootElementClass}-std");
ClassBuilder.Register(() => ButtonStyle switch
{
BitButtonStyle.Primary => "bit-cmb-pri",
BitButtonStyle.Standard => "bit-cmb-std",
BitButtonStyle.Text => "bit-cmb-txt",
_ => "bit-cmb-pri"
});

ClassBuilder.Register(() => Color switch
{
BitButtonColor.Info => "bit-cmb-inf",
BitButtonColor.Success => "bit-cmb-suc",
BitButtonColor.Warning => "bit-cmb-wrn",
BitButtonColor.SevereWarning => "bit-cmb-swr",
BitButtonColor.Error => "bit-cmb-err",
_ => string.Empty
});

ClassBuilder.Register(() => Size switch
{
BitButtonSize.Small => "bit-cmb-sm",
BitButtonSize.Medium => "bit-cmb-md",
BitButtonSize.Large => "bit-cmb-lg",
_ => string.Empty
});
}

protected override void RegisterCssStyles()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,81 @@

&.bit-dis {
cursor: default;
user-select: none;
pointer-events: none;
-webkit-user-select: none;
color: $color-foreground-disabled;
border-color: $color-border-disabled;
background-color: $color-background-disabled;
}
}

.bit-cmb-pri {
color: $color-primary-text;
border-color: $color-primary-main;
background-color: $color-primary-main;
color: var(--bit-cmb-pri-clr);
background-color: var(--bit-cmb-bg-clr);
border-color: var(--bit-cmb-pri-brd-clr);
--bit-cmb-bg-clr: #{$color-primary-main};
--bit-cmb-pri-clr: #{$color-primary-text};
--bit-cmb-pri-brd-clr: #{$color-primary-main};
--bit-cmb-pri-hover-bg-clr: #{$color-action-hover-primary};
--bit-cmb-pri-active-bg-clr: #{$color-action-active-primary};

@media (hover: hover) {
&:hover {
border-color: $color-action-hover-primary;
background-color: $color-action-hover-primary;
border-color: var(--bit-cmb-pri-hover-bg-clr);
background-color: var(--bit-cmb-pri-hover-bg-clr);
}
}

&:active {
border-color: $color-action-active-primary;
background-color: $color-action-active-primary;
border-color: var(--bit-cmb-pri-active-bg-clr);
background-color: var(--bit-cmb-pri-active-bg-clr);
}

&.bit-dis {
border-color: $color-border-disabled;
background-color: $color-background-disabled;
}
}

.bit-cmb-std {
color: $color-secondary-text;
border-color: $color-border-primary;
color: var(--bit-cmb-sec-clr);
background-color: $color-secondary-main;
border-color: var(--bit-cmb-sec-brd-clr);
--bit-cmb-sec-clr: #{$color-secondary-text};
--bit-cmb-sec-brd-clr: #{$color-secondary-text};
--bit-cmb-sec-hover-bg-clr: #{$color-action-hover-secondary};
--bit-cmb-sec-active-bg-clr: #{$color-action-active-secondary};

@media (hover: hover) {
&:hover {
background-color: var(--bit-cmb-sec-hover-bg-clr);
}
}

&:active {
background-color: var(--bit-cmb-sec-active-bg-clr);
}

&.bit-dis {
border-color: $color-border-disabled;
}
}

.bit-cmb-txt {
border-color: transparent;
color: var(--bit-cmb-sec-clr);
background-color: transparent;
--bit-cmb-sec-clr: #{$color-secondary-text};
--bit-cmb-sec-hover-bg-clr: #{$color-action-hover-secondary};
--bit-cmb-sec-active-bg-clr: #{$color-action-active-secondary};

@media (hover: hover) {
&:hover {
background-color: $color-action-hover-secondary;
background-color: var(--bit-cmb-sec-hover-bg-clr);
}
}

&:active {
background-color: $color-action-active-secondary;
background-color: var(--bit-cmb-sec-active-bg-clr);
}
}

Expand All @@ -73,3 +110,91 @@
font-weight: 400;
font-size: spacing(1.5);
}

.bit-cmb-inf {
--bit-cmb-bg-clr: #{$color-state-info-bg};
--bit-cmb-pri-clr: #{$color-foreground-primary};
--bit-cmb-pri-brd-clr: #{$color-state-info-bg};
--bit-cmb-pri-hover-bg-clr: #{$color-action-hover-state-info-bg};
--bit-cmb-pri-active-bg-clr: #{$color-action-active-state-info-bg};
--bit-cmb-sec-clr: #{$color-state-info};
--bit-cmb-sec-brd-clr: #{$color-state-info};
--bit-cmb-sec-hover-bg-clr: #{$color-action-hover-state-info-bg};
--bit-cmb-sec-active-bg-clr: #{$color-action-active-state-info-bg};
}

.bit-cmb-suc {
--bit-cmb-bg-clr: #{$color-state-success-bg};
--bit-cmb-pri-clr: #{$color-foreground-primary};
--bit-cmb-pri-brd-clr: #{$color-state-success-bg};
--bit-cmb-pri-hover-bg-clr: #{$color-action-hover-state-success-bg};
--bit-cmb-pri-active-bg-clr: #{$color-action-active-state-success-bg};
--bit-cmb-sec-clr: #{$color-state-success};
--bit-cmb-sec-brd-clr: #{$color-state-success};
--bit-cmb-sec-hover-bg-clr: #{$color-action-hover-state-success-bg};
--bit-cmb-sec-active-bg-clr: #{$color-action-active-state-success-bg};
}

.bit-cmb-wrn {
--bit-cmb-bg-clr: #{$color-state-warning-bg};
--bit-cmb-pri-clr: #{$color-foreground-primary};
--bit-cmb-pri-brd-clr: #{$color-state-warning-bg};
--bit-cmb-pri-hover-bg-clr: #{$color-action-hover-state-warning-bg};
--bit-cmb-pri-active-bg-clr: #{$color-action-active-state-warning-bg};
--bit-cmb-sec-clr: #{$color-state-warning};
--bit-cmb-sec-brd-clr: #{$color-state-warning};
--bit-cmb-sec-hover-bg-clr: #{$color-action-hover-state-warning-bg};
--bit-cmb-sec-active-bg-clr: #{$color-action-active-state-warning-bg};
}

.bit-cmb-swr {
--bit-cmb-bg-clr: #{$color-state-severe-warning-bg};
--bit-cmb-pri-clr: #{$color-foreground-primary};
--bit-cmb-pri-brd-clr: #{$color-state-severe-warning-bg};
--bit-cmb-pri-hover-bg-clr: #{$color-action-hover-state-severe-warning-bg};
--bit-cmb-pri-active-bg-clr: #{$color-action-active-state-severe-warning-bg};
--bit-cmb-sec-clr: #{$color-state-severe-warning};
--bit-cmb-sec-brd-clr: #{$color-state-severe-warning};
--bit-cmb-sec-hover-bg-clr: #{$color-action-hover-state-severe-warning-bg};
--bit-cmb-sec-active-bg-clr: #{$color-action-active-state-severe-warning-bg};
}

.bit-cmb-err {
--bit-cmb-bg-clr: #{$color-state-error-bg};
--bit-cmb-pri-clr: #{$color-foreground-primary};
--bit-cmb-pri-brd-clr: #{$color-state-error-bg};
--bit-cmb-pri-hover-bg-clr: #{$color-action-hover-state-error-bg};
--bit-cmb-pri-active-bg-clr: #{$color-action-active-state-error-bg};
--bit-cmb-sec-clr: #{$color-state-error};
--bit-cmb-sec-brd-clr: #{$color-state-error};
--bit-cmb-sec-hover-bg-clr: #{$color-action-hover-state-error-bg};
--bit-cmb-sec-active-bg-clr: #{$color-action-active-state-error-bg};
}

.bit-cmb-sm {
min-width: spacing(6);
min-height: spacing(3);
padding: spacing(1.75) spacing(1.25);

.bit-cmb-prt {
font-size: spacing(1.5);
}

.bit-cmb-sct {
font-size: spacing(1.25);
}
}

.bit-cmb-lg {
min-width: spacing(10);
min-height: spacing(5);
padding: spacing(2.25) spacing(1.75);

.bit-cmb-prt {
font-size: spacing(2.5);
}

.bit-cmb-sct {
font-size: spacing(2);
}
}
Loading
Loading