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

feat(buttonGroup): add buttonGroup component #1590

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion docs/web/api/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Button 按钮
description: 按钮用于开启一个闭环的操作任务,如“删除”对象、“购买”商品等。
isComponent: true
usage: { title: '', description: '' }
usage: { title: "", description: "" }
spline: base
---

Expand Down Expand Up @@ -70,6 +70,12 @@ Block 按钮在宽度上充满其所在的父容器(无 padding 和 margin 值

{{ shape }}

### 按钮组

以按钮组的方式出现,可用在同级多项操作中。

{{ group }}

### 自定义渲染元素

支持自定义渲染元素,支持 `div/a/button`
Expand Down
9 changes: 7 additions & 2 deletions style/web/components/button/_docs.less
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
[class*="@{d-prefix}-demo-item--button"] {
.@{prefix}-button-group {
.@{prefix}-button + .@{prefix}-button {
margin-left: 0px;
}
}

.@{prefix}-button + .@{prefix}-button {
margin-left: 8px;
}

.@{prefix}-button.@{prefix}-size-full-width + .@{prefix}-button.@{prefix}-size-full-width {
.@{prefix}-button.@{prefix}-size-full-width
+ .@{prefix}-button.@{prefix}-size-full-width {
margin-left: 0;
margin-top: 8px;
}
}

.tdesign-demo-item--button-ghost {

.@{d-prefix}-demo-item__body {
background-color: #181818;
}
Expand Down
60 changes: 55 additions & 5 deletions style/web/components/button/_index.less
Original file line number Diff line number Diff line change
Expand Up @@ -369,22 +369,72 @@
--ripple-color: @btn-color-white-bg-active;
}

.@{prefix}-button--variant-base:not(.@{prefix}-is-disabled):not(.@{prefix}-button--ghost) {
.@{prefix}-button--variant-base:not(.@{prefix}-is-disabled):not(
.@{prefix}-button--ghost
) {
--ripple-color: @btn-color-gray-bg-active;
}

.@{prefix}-button--variant-base.@{prefix}-button--theme-primary:not(.@{prefix}-is-disabled):not(.@{prefix}-button--ghost) {
.@{prefix}-button--variant-base.@{prefix}-button--theme-primary:not(
.@{prefix}-is-disabled
):not(.@{prefix}-button--ghost) {
--ripple-color: @btn-color-primary-active;
}

.@{prefix}-button--variant-base.@{prefix}-button--theme-success:not(.@{prefix}-is-disabled):not(.@{prefix}-button--ghost) {
.@{prefix}-button--variant-base.@{prefix}-button--theme-success:not(
.@{prefix}-is-disabled
):not(.@{prefix}-button--ghost) {
--ripple-color: @btn-color-success-active;
}

.@{prefix}-button--variant-base.@{prefix}-button--theme-warning:not(.@{prefix}-is-disabled):not(.@{prefix}-button--ghost) {
.@{prefix}-button--variant-base.@{prefix}-button--theme-warning:not(
.@{prefix}-is-disabled
):not(.@{prefix}-button--ghost) {
--ripple-color: @btn-color-warning-active;
}

.@{prefix}-button--variant-base.@{prefix}-button--theme-danger:not(.@{prefix}-is-disabled):not(.@{prefix}-button--ghost) {
.@{prefix}-button--variant-base.@{prefix}-button--theme-danger:not(
.@{prefix}-is-disabled
):not(.@{prefix}-button--ghost) {
--ripple-color: @btn-color-danger-active;
}

.@{prefix}-button-group {
display: inline-flex;
align-items: center;
.@{prefix}-button {
&:first-child {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-right-color: @btn-group-border-color;
}

&:last-child {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-left-color: @btn-group-border-color;
}

&:not(:first-child):not(:last-child) {
border-radius: 0;
border-left-color: @btn-group-border-color;
border-right-color: @btn-group-border-color;
}

&:not(:last-child) {
margin-right: -1px;
}

&:first-child:last-child {
border-radius: @border-radius-default;

&.is-round {
border-radius: @border-radius-round;
}

&.is-circle {
border-radius: 50%;
}
}
}
}
3 changes: 2 additions & 1 deletion style/web/components/button/_var.less
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,5 @@
@btn-text-variant-base-color: @text-color-anti;

// 状态色 - disabled ghost
@btn-color-ghost-disabled: rgba(255, 255, 255, .22);
@btn-color-ghost-disabled: rgba(255, 255, 255, 22%);
@btn-group-border-color: rgba(255, 255, 255, 50%);