diff --git a/packages/components/checkbox/README.en-US.md b/packages/components/checkbox/README.en-US.md index 06f9258332..5aeb0d00a4 100644 --- a/packages/components/checkbox/README.en-US.md +++ b/packages/components/checkbox/README.en-US.md @@ -86,12 +86,12 @@ The component provides the following CSS variables, which can be used to customi Name | Default Value | Description -- | -- | -- --td-checkbox-bg-color | @bg-color-container | - ---td-checkbox-border-color | @component-stroke | - +--td-checkbox-border-color | @component-border | - --td-checkbox-description-color | @text-color-secondary | - --td-checkbox-description-disabled-color | @text-color-disabled | - --td-checkbox-description-font | @font-body-medium | - --td-checkbox-icon-checked-color | @brand-color | - ---td-checkbox-icon-color | @component-border | - +--td-checkbox-icon-color | @text-color-anti | - --td-checkbox-icon-disabled-bg-color | @bg-color-component-disabled | - --td-checkbox-icon-disabled-color | @brand-color-disabled | - --td-checkbox-icon-size | 48rpx | - diff --git a/packages/components/checkbox/README.md b/packages/components/checkbox/README.md index 1dfb86e493..38e883a4c3 100644 --- a/packages/components/checkbox/README.md +++ b/packages/components/checkbox/README.md @@ -154,12 +154,12 @@ change | `(value: CheckboxGroupValue, context: { value: boolean\|number\|string, 名称 | 默认值 | 描述 -- | -- | -- --td-checkbox-bg-color | @bg-color-container | - ---td-checkbox-border-color | @component-stroke | - +--td-checkbox-border-color | @component-border | - --td-checkbox-description-color | @text-color-secondary | - --td-checkbox-description-disabled-color | @text-color-disabled | - --td-checkbox-description-font | @font-body-medium | - --td-checkbox-icon-checked-color | @brand-color | - ---td-checkbox-icon-color | @component-border | - +--td-checkbox-icon-color | @text-color-anti | - --td-checkbox-icon-disabled-bg-color | @bg-color-component-disabled | - --td-checkbox-icon-disabled-color | @brand-color-disabled | - --td-checkbox-icon-size | 48rpx | - diff --git a/packages/components/checkbox/_example/special/index.wxss b/packages/components/checkbox/_example/special/index.wxss index f7b213304f..9586a43aa1 100644 --- a/packages/components/checkbox/_example/special/index.wxss +++ b/packages/components/checkbox/_example/special/index.wxss @@ -33,6 +33,7 @@ left: 1.5px; top: 1.5px; z-index: 1; + font-size: 28rpx; } /* 横向布局 */ diff --git a/packages/components/checkbox/checkbox.less b/packages/components/checkbox/checkbox.less index b1df3ddb85..68626c7bbb 100644 --- a/packages/components/checkbox/checkbox.less +++ b/packages/components/checkbox/checkbox.less @@ -9,12 +9,12 @@ @checkbox-description-font: var(--td-checkbox-description-font, @font-body-medium); @checkbox-vertical-padding: var(--td-checkbox-vertical-padding, @spacer-2); @checkbox-bg-color: var(--td-checkbox-bg-color, @bg-color-container); -@checkbox-border-color: var(--td-checkbox-border-color, @component-stroke); +@checkbox-border-color: var(--td-checkbox-border-color, @component-border); @checkbox-title-color: var(--td-checkbox-title-color, @text-color-primary); @checkbox-title-disabled-color: var(--td-checkbox-title-disabled-color, @text-color-disabled); @checkbox-description-color: var(--td-checkbox-description-color, @text-color-secondary); @checkbox-description-disabled-color: var(--td-checkbox-description-disabled-color, @text-color-disabled); -@checkbox-icon-color: var(--td-checkbox-icon-color, @component-border); +@checkbox-icon-color: var(--td-checkbox-icon-color, @text-color-anti); @checkbox-icon-disabled-color: var(--td-checkbox-icon-disabled-color, @brand-color-disabled); @checkbox-icon-disabled-bg-color: var(--td-checkbox-icon-disabled-bg-color, @bg-color-component-disabled); @checkbox-icon-checked-color: var(--td-checkbox-icon-checked-color, @brand-color); @@ -57,6 +57,10 @@ transform: translateY(-50%); } + &__icon-wrapper { + display: block; + } + &__icon-left { margin-right: 20rpx; width: 40rpx; @@ -76,12 +80,11 @@ &__icon { position: relative; - display: block; + display: flex; + align-items: center; + justify-content: center; width: @checkbox-icon-size; height: @checkbox-icon-size; - color: @checkbox-icon-color; - font-size: @checkbox-icon-size; - margin-top: calc((@checkbox-title-line-height - @checkbox-icon-size) / 2); &:empty { display: none; @@ -100,68 +103,55 @@ margin-right: @spacer; } - &-circle { - width: calc((@checkbox-icon-size - @checkbox-border-width) * 2); - height: calc((@checkbox-icon-size - @checkbox-border-width) * 2); - border: calc(@checkbox-border-width * 2) solid @checkbox-icon-color; - border-radius: @radius-circle; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%) scale(0.5); + &-circle, + &-rectangle { + display: flex; + align-items: center; + justify-content: center; + width: @checkbox-icon-size; + height: @checkbox-icon-size; + color: @checkbox-icon-color; + font-size: calc(@checkbox-icon-size - 16rpx); + border: @checkbox-border-width solid @checkbox-border-color; box-sizing: border-box; - &--disabled { - background: @checkbox-icon-disabled-bg-color; + &--checked { + background: @checkbox-icon-checked-color; + border-color: @checkbox-icon-checked-color; } - } - - &-rectangle { - width: calc((@checkbox-icon-size - @checkbox-border-width * 2) * 2); - height: calc((@checkbox-icon-size - @checkbox-border-width * 2) * 2); - border: calc(@checkbox-border-width * 2) solid @checkbox-icon-color; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%) scale(0.5); - box-sizing: border-box; &--disabled { background: @checkbox-icon-disabled-bg-color; } - } - &-line { - &::before, - &::after { - content: ''; - display: block; - position: absolute; - width: 5rpx; - border-radius: 2rpx; - background: @checkbox-icon-checked-color; - transform-origin: top center; + &--checked&--disabled { + background: @checkbox-icon-disabled-color; + border-color: @checkbox-icon-disabled-color; } + } - &::before { - height: 16rpx; - left: 8rpx; - top: 22rpx; - transform: rotate(-45deg); - } + &-circle { + width: calc(@checkbox-icon-size - 4rpx); + height: calc(@checkbox-icon-size - 4rpx); + border-radius: @radius-circle; + } - &::after { - height: 26rpx; - right: 8rpx; - top: 14rpx; - transform: rotate(45deg); - } + &-rectangle { + width: calc(@checkbox-icon-size - 8rpx); + height: calc(@checkbox-icon-size - 8rpx); + } + + &-line { + display: flex; + align-items: center; + justify-content: center; + width: @checkbox-icon-size; + height: @checkbox-icon-size; + color: @checkbox-icon-checked-color; + font-size: @checkbox-icon-size; &--disabled { - &::before, - &::after { - background: @checkbox-icon-disabled-color; - } + color: @checkbox-icon-disabled-color; } } } @@ -200,14 +190,14 @@ &__border { position: absolute; bottom: 0; - left: 96rpx; + left: @spacer-5; right: 0; height: 1px; background: @checkbox-border-color; transform: scaleY(0.5); &--right { - left: 32rpx; + left: @spacer-2; } } diff --git a/packages/components/checkbox/checkbox.wxml b/packages/components/checkbox/checkbox.wxml index 639125b515..bcca35ff87 100644 --- a/packages/components/checkbox/checkbox.wxml +++ b/packages/components/checkbox/checkbox.wxml @@ -15,29 +15,21 @@ class="{{_.cls(classPrefix + '__icon', [placement, ['checked', checked], ['disabled', _disabled]])}} {{prefix}}-class-icon" > - + - - - - - - + + + + + + - - - - - + + + + + + - - - - - - - + + + + + + + + + diff --git a/packages/uniapp-components/checkbox/README.en-US.md b/packages/uniapp-components/checkbox/README.en-US.md index 54332ddd30..83f7be4eca 100644 --- a/packages/uniapp-components/checkbox/README.en-US.md +++ b/packages/uniapp-components/checkbox/README.en-US.md @@ -85,12 +85,12 @@ The component provides the following CSS variables, which can be used to customi Name | Default Value | Description -- | -- | -- --td-checkbox-bg-color | @bg-color-container | - ---td-checkbox-border-color | @component-stroke | - +--td-checkbox-border-color | @component-border | - --td-checkbox-description-color | @text-color-secondary | - --td-checkbox-description-disabled-color | @text-color-disabled | - --td-checkbox-description-font | @font-body-medium | - --td-checkbox-icon-checked-color | @brand-color | - ---td-checkbox-icon-color | @component-border | - +--td-checkbox-icon-color | @text-color-anti | - --td-checkbox-icon-disabled-bg-color | @bg-color-component-disabled | - --td-checkbox-icon-disabled-color | @brand-color-disabled | - --td-checkbox-icon-size | 48rpx | - diff --git a/packages/uniapp-components/checkbox/README.md b/packages/uniapp-components/checkbox/README.md index 430df2c6dc..5293456dab 100644 --- a/packages/uniapp-components/checkbox/README.md +++ b/packages/uniapp-components/checkbox/README.md @@ -142,12 +142,12 @@ change | `(context: { value: CheckboxGroupValue, context: { value: boolean\|numb 名称 | 默认值 | 描述 -- | -- | -- --td-checkbox-bg-color | @bg-color-container | - ---td-checkbox-border-color | @component-stroke | - +--td-checkbox-border-color | @component-border | - --td-checkbox-description-color | @text-color-secondary | - --td-checkbox-description-disabled-color | @text-color-disabled | - --td-checkbox-description-font | @font-body-medium | - --td-checkbox-icon-checked-color | @brand-color | - ---td-checkbox-icon-color | @component-border | - +--td-checkbox-icon-color | @text-color-anti | - --td-checkbox-icon-disabled-bg-color | @bg-color-component-disabled | - --td-checkbox-icon-disabled-color | @brand-color-disabled | - --td-checkbox-icon-size | 48rpx | - diff --git a/packages/uniapp-components/checkbox/_example/special/index.vue b/packages/uniapp-components/checkbox/_example/special/index.vue index 17070b868d..d9dddda25b 100644 --- a/packages/uniapp-components/checkbox/_example/special/index.vue +++ b/packages/uniapp-components/checkbox/_example/special/index.vue @@ -147,7 +147,7 @@ export default { left: 1.5px; top: 1.5px; z-index: 1; - font-size: 16px; + font-size: 14px; } /* 横向布局 */ diff --git a/packages/uniapp-components/checkbox/checkbox.less b/packages/uniapp-components/checkbox/checkbox.less index 1d63309ce3..acc016c7ff 100644 --- a/packages/uniapp-components/checkbox/checkbox.less +++ b/packages/uniapp-components/checkbox/checkbox.less @@ -9,12 +9,12 @@ @checkbox-description-font: var(--td-checkbox-description-font, @font-body-medium); @checkbox-vertical-padding: var(--td-checkbox-vertical-padding, @spacer-2); @checkbox-bg-color: var(--td-checkbox-bg-color, @bg-color-container); -@checkbox-border-color: var(--td-checkbox-border-color, @component-stroke); +@checkbox-border-color: var(--td-checkbox-border-color, @component-border); @checkbox-title-color: var(--td-checkbox-title-color, @text-color-primary); @checkbox-title-disabled-color: var(--td-checkbox-title-disabled-color, @text-color-disabled); @checkbox-description-color: var(--td-checkbox-description-color, @text-color-secondary); @checkbox-description-disabled-color: var(--td-checkbox-description-disabled-color, @text-color-disabled); -@checkbox-icon-color: var(--td-checkbox-icon-color, @component-border); +@checkbox-icon-color: var(--td-checkbox-icon-color, @text-color-anti); @checkbox-icon-disabled-color: var(--td-checkbox-icon-disabled-color, @brand-color-disabled); @checkbox-icon-disabled-bg-color: var(--td-checkbox-icon-disabled-bg-color, @bg-color-component-disabled); @checkbox-icon-checked-color: var(--td-checkbox-icon-checked-color, @brand-color); @@ -52,6 +52,10 @@ transform: translateY(-50%); } + &__icon-wrapper { + display: block; + } + &__icon-left { margin-right: 20rpx; width: 40rpx; @@ -71,12 +75,11 @@ &__icon { position: relative; - display: block; + display: flex; + align-items: center; + justify-content: center; width: @checkbox-icon-size; height: @checkbox-icon-size; - color: @checkbox-icon-color; - font-size: @checkbox-icon-size; - margin-top: calc((@checkbox-title-line-height - @checkbox-icon-size) / 2); &:empty { display: none; @@ -92,71 +95,58 @@ } &--left { - margin-right: 16rpx; + margin-right: @spacer; } - &-circle { - width: calc((@checkbox-icon-size - @checkbox-border-width) * 2); - height: calc((@checkbox-icon-size - @checkbox-border-width) * 2); - border: calc(@checkbox-border-width * 2) solid @checkbox-icon-color; - border-radius: 50%; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%) scale(0.5); + &-circle, + &-rectangle { + display: flex; + align-items: center; + justify-content: center; + width: @checkbox-icon-size; + height: @checkbox-icon-size; + color: @checkbox-icon-color; + font-size: calc(@checkbox-icon-size - 16rpx); + border: @checkbox-border-width solid @checkbox-border-color; box-sizing: border-box; - &--disabled { - background: @checkbox-icon-disabled-bg-color; + &--checked { + background: @checkbox-icon-checked-color; + border-color: @checkbox-icon-checked-color; } - } - - &-rectangle { - width: calc((@checkbox-icon-size - @checkbox-border-width * 2) * 2); - height: calc((@checkbox-icon-size - @checkbox-border-width * 2) * 2); - border: calc(@checkbox-border-width * 2) solid @checkbox-icon-color; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%) scale(0.5); - box-sizing: border-box; &--disabled { background: @checkbox-icon-disabled-bg-color; } - } - &-line { - &::before, - &::after { - content: ''; - display: block; - position: absolute; - width: 5rpx; - border-radius: 2rpx; - background: @checkbox-icon-checked-color; - transform-origin: top center; + &--checked&--disabled { + background: @checkbox-icon-disabled-color; + border-color: @checkbox-icon-disabled-color; } + } - &::before { - height: 16rpx; - left: 8rpx; - top: 22rpx; - transform: rotate(-45deg); - } + &-circle { + width: calc(@checkbox-icon-size - 4rpx); + height: calc(@checkbox-icon-size - 4rpx); + border-radius: @radius-circle; + } - &::after { - height: 26rpx; - right: 8rpx; - top: 14rpx; - transform: rotate(45deg); - } + &-rectangle { + width: calc(@checkbox-icon-size - 8rpx); + height: calc(@checkbox-icon-size - 8rpx); + } + + &-line { + display: flex; + align-items: center; + justify-content: center; + width: @checkbox-icon-size; + height: @checkbox-icon-size; + color: @checkbox-icon-checked-color; + font-size: @checkbox-icon-size; &--disabled { - &::before, - &::after { - background: @checkbox-icon-disabled-color; - } + color: @checkbox-icon-disabled-color; } } } diff --git a/packages/uniapp-components/checkbox/checkbox.vue b/packages/uniapp-components/checkbox/checkbox.vue index c501c445dc..12fbec1e0e 100644 --- a/packages/uniapp-components/checkbox/checkbox.vue +++ b/packages/uniapp-components/checkbox/checkbox.vue @@ -23,29 +23,27 @@ " > - + - - - - - - + + + + + + - - - - - - + + + + + + + + +