优化单选和多选

master
yutent 2023-11-21 09:45:34 +08:00
parent 08e0089eea
commit 9241300b1c
3 changed files with 19 additions and 42 deletions

View File

@ -64,11 +64,7 @@ class Checkbox extends Component {
class CheckboxItem extends Component { class CheckboxItem extends Component {
static props = { static props = {
value: { value: 'str!',
type: String,
default: '',
attribute: false
},
checked: false, checked: false,
disabled: false, disabled: false,
readonly: false readonly: false
@ -79,22 +75,20 @@ class CheckboxItem extends Component {
:host { :host {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
font-size: 14px;
cursor: pointer; cursor: pointer;
label { label {
display: flex; display: flex;
justify-content: center;
align-items: center; align-items: center;
min-width: 32px;
padding-right: 16px; padding-right: 16px;
line-height: 1; line-height: 1;
-moz-user-select: none; font-size: 14px;
user-select: none;
white-space: nowrap; white-space: nowrap;
color: var(--color-dark-1);
cursor: inherit; cursor: inherit;
outline: none; outline: none;
color: var(--color-dark-1); -webkit-user-select: none;
user-select: none;
} }
.dot { .dot {
@ -134,36 +128,27 @@ class CheckboxItem extends Component {
css` css`
@use 'sass:map'; @use 'sass:map';
$sizes: ( $sizes: (
s: (
h: 20px,
f: 12px
),
m: ( m: (
w: 72px,
h: 24px, h: 24px,
f: 12px f: 12px
), ),
l: (
w: 108px,
h: 32px,
f: 14px
),
xl: ( xl: (
w: 132px,
h: 36px, h: 36px,
f: 14px f: 16px
),
xxl: (
w: 160px,
h: 44px,
f: 14px
) )
); );
@loop $s, $v in $sizes { @loop $s, $v in $sizes {
:host([size='#{$s}']) { :host([size='#{$s}']) {
height: map.get($v, 'h'); height: map.get($v, 'h');
font-size: map.get($v, 'f');
.dot { .dot {
width: #{map.get($v, 'f')}; width: map.get($v, 'f');
height: #{map.get($v, 'f')}; height: map.get($v, 'f');
} }
} }
} }
@ -175,9 +160,7 @@ class CheckboxItem extends Component {
info: 'blue', info: 'blue',
success: 'green', success: 'green',
warning: 'orange', warning: 'orange',
danger: 'red', danger: 'red'
secondary: 'dark',
help: 'grey'
); );
@loop $t, $c in $colors { @loop $t, $c in $colors {
@ -188,10 +171,6 @@ class CheckboxItem extends Component {
.dot { .dot {
border-color: var(--color-#{$c}-2); border-color: var(--color-#{$c}-2);
&::after {
background: var(--color-#{$c}-2);
}
} }
&:host(:focus-within) .dot { &:host(:focus-within) .dot {
@ -202,12 +181,12 @@ class CheckboxItem extends Component {
`, `,
// 状态 // 状态
css` css`
:host([readonly]),
:host([disabled]) { :host([disabled]) {
cursor: not-allowed;
opacity: 0.6; opacity: 0.6;
} }
:host([readonly]) { :host([disabled]) {
cursor: default; cursor: not-allowed;
} }
` `
] ]

View File

@ -22,8 +22,6 @@ class Link extends Component {
position: relative; position: relative;
display: inline-flex; display: inline-flex;
border-radius: 2px; border-radius: 2px;
user-select: none;
-moz-user-select: none;
font-size: inherit; font-size: inherit;
cursor: pointer; cursor: pointer;
transition: box-shadow 0.15s linear; transition: box-shadow 0.15s linear;
@ -42,6 +40,8 @@ class Link extends Component {
cursor: inherit; cursor: inherit;
text-decoration: none; text-decoration: none;
transition: color 0.15s linear; transition: color 0.15s linear;
-webkit-user-select: none;
user-select: none;
&::-moz-focus-inner { &::-moz-focus-inner {
border: none; border: none;

View File

@ -167,9 +167,7 @@ class RadioItem extends Component {
info: 'blue', info: 'blue',
success: 'green', success: 'green',
warning: 'orange', warning: 'orange',
danger: 'red', danger: 'red'
secondary: 'dark',
help: 'grey'
); );
@loop $t, $c in $colors { @loop $t, $c in $colors {