Skip to content
Closed
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
4 changes: 4 additions & 0 deletions docs/mobile/api/switch.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ toc: false
#### Switch Size

{{ size }}

#### Switch Shape

{{ shape }}
4 changes: 4 additions & 0 deletions docs/mobile/api/switch.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ toc: false
#### 开关尺寸

{{ size }}

#### 开关形状

{{ shape }}
6 changes: 6 additions & 0 deletions docs/web/api/switch.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ Switches for normal, loading and disabled are provided. Set the corresponding st
Large, medium (default) and small switches are provided.

{{ size }}

### Switches of Different Shapes

Three shapes are provided: circle, round and line.

{{ shape }}
6 changes: 6 additions & 0 deletions docs/web/api/switch.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ spline: form
提供 大、中(默认)、小 3种开关。

{{ size }}

### 不同形状的开关

提供 圆形、圆角、线性 3 种形状。

{{ shape }}
48 changes: 48 additions & 0 deletions style/mobile/components/switch/_index.less
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,54 @@
border-radius: @switch-small-radius;
}

&--round {
border-radius: @switch-round-radius;

.@{prefix}-switch__dot {
border-radius: @switch-round-dot-radius;
}
}

&--line {
background-color: transparent;

&::before {
content: '';
position: absolute;
top: 50%;
left: 0;
right: 0;
height: @switch-line-track-height;
border-radius: @switch-radius;
background-color: @switch-unchecked-color;
transform: translateY(-50%);
transition: all .3s ease;
}

&.@{prefix}-switch--checked::before {
background-color: @switch-checked-color;
}

&.@{prefix}-switch--disabled::before {
background-color: @switch-unchecked-disabled-color;
}

&.@{prefix}-switch--checked.@{prefix}-switch--disabled::before {
background-color: @switch-checked-disabled-color;
}

&.@{prefix}-switch--checked,
&.@{prefix}-switch--disabled,
&.@{prefix}-switch--checked.@{prefix}-switch--disabled {
background-color: transparent;
}

.@{prefix}-switch__label,
.@{prefix}-switch__dot {
z-index: 1;
}
}

&__label {
position: absolute;
top: 0;
Expand Down
4 changes: 4 additions & 0 deletions style/mobile/components/switch/_var.less
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@
@switch-icon-small-size: var(--td-switch-icon-small-size, 16px);

@switch-loading-color: var(--td-switch-loading-color, @brand-color);

@switch-round-radius: var(--td-switch-round-radius, 6px);
@switch-round-dot-radius: var(--td-switch-round-dot-radius, 3px);
@switch-line-track-height: var(--td-switch-line-track-height, 6px);
97 changes: 97 additions & 0 deletions style/web/components/switch/_index.less
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,100 @@
}
}
}

.@{prefix}-switch {
&--shape-round {
border-radius: @switch-round-track-border-radius;

.@{prefix}-switch__handle,
.@{prefix}-switch__handle::before {
border-radius: @switch-round-handle-border-radius;
}
}

&--shape-line {
background-color: transparent;

&::before {
content: '';
position: absolute;
top: 50%;
left: 0;
right: 0;
height: @switch-line-track-height;
border-radius: @border-radius-round;
background-color: @switch-unchecked-bg-color;
transform: translateY(-50%);
transition: @switch-transition;
}

&:hover {
background-color: transparent;

&::before {
background-color: @switch-unchecked-bg-color-hover;
}
}

.@{prefix}-switch__handle,
.@{prefix}-switch__content {
z-index: 1;
}

.@{prefix}-switch__handle {
left: 0;
}

&.@{prefix}-is-checked {
background-color: transparent;

&::before {
background-color: @switch-checked-bg-color;
}

&:hover {
background-color: transparent;

&::before {
background-color: @switch-checked-bg-color-hover;
}
}

.@{prefix}-switch__handle {
left: 100%;
}
}

&.@{prefix}-is-loading {
background-color: transparent;

&::before {
background-color: @switch-unchecked-bg-color-loading;
}

&.@{prefix}-is-checked {
background-color: transparent;

&::before {
background-color: @switch-checked-bg-color-loading;
}
}
}

&.@{prefix}-is-disabled {
background-color: transparent;

&::before {
background-color: @switch-unchecked-bg-color-disabled;
}

&.@{prefix}-is-checked {
background-color: transparent;

&::before {
background-color: @switch-checked-bg-color-disabled;
}
}
}
}
}
5 changes: 5 additions & 0 deletions style/web/components/switch/_var.less
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,8 @@
@switch-content-transition:
padding @anim-duration-base @anim-time-fn-easing,
opacity @anim-duration-base linear;

// 外观
@switch-round-track-border-radius: @border-radius-default;
@switch-round-handle-border-radius: @border-radius-small;
@switch-line-track-height: 6px;