Skip to content

Commit 73f7f9e

Browse files
committed
style: update checkbox
1 parent 5bc17f0 commit 73f7f9e

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

components/checkbox/Checkbox.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import VcCheckbox from '../vc-checkbox/Checkbox';
44
import { flattenChildren } from '../_util/props-util';
55
import warning from '../_util/warning';
66
import type { EventHandler } from '../_util/EventInterface';
7-
import { useInjectFormItemContext } from '../form/FormItemContext';
7+
import { FormItemInputContext, useInjectFormItemContext } from '../form/FormItemContext';
88
import useConfigInject from '../_util/hooks/useConfigInject';
99

1010
import type { CheckboxChangeEvent, CheckboxProps } from './interface';
@@ -18,6 +18,7 @@ export default defineComponent({
1818
// emits: ['change', 'update:checked'],
1919
setup(props, { emit, attrs, slots, expose }) {
2020
const formItemContext = useInjectFormItemContext();
21+
const formItemInputContext = FormItemInputContext.useInject();
2122
const { prefixCls, direction } = useConfigInject('checkbox', props);
2223
const checkboxGroup = inject(CheckboxGroupContextKey, undefined);
2324
const uniId = Symbol('checkboxUniId');
@@ -84,20 +85,27 @@ export default defineComponent({
8485
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
8586
[`${prefixCls.value}-wrapper-checked`]: checkboxProps.checked,
8687
[`${prefixCls.value}-wrapper-disabled`]: checkboxProps.disabled,
88+
[`${prefixCls.value}-wrapper-in-form-item`]: formItemInputContext.isFormItemInput,
8789
},
8890
className,
8991
);
9092
const checkboxClass = classNames({
9193
[`${prefixCls.value}-indeterminate`]: indeterminate,
9294
});
95+
const ariaChecked = indeterminate ? 'mixed' : undefined;
9396
return (
9497
<label
9598
class={classString}
9699
style={style}
97100
onMouseenter={onMouseenter as EventHandler}
98101
onMouseleave={onMouseleave as EventHandler}
99102
>
100-
<VcCheckbox {...checkboxProps} class={checkboxClass} ref={checkboxRef} />
103+
<VcCheckbox
104+
aria-checked={ariaChecked}
105+
{...checkboxProps}
106+
class={checkboxClass}
107+
ref={checkboxRef}
108+
/>
101109
{children.length ? <span>{children}</span> : null}
102110
</label>
103111
);

components/checkbox/style/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import '../../style/index.less';
22
import './index.less';
3+
// deps-lint-skip: form

components/checkbox/style/mixin.less

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@
169169
& + & {
170170
margin-left: 8px;
171171
}
172+
173+
&&-in-form-item {
174+
input[type='checkbox'] {
175+
width: 14px;
176+
height: 14px;
177+
}
178+
}
172179
}
173180

174181
.@{checkbox-prefix-cls} + span {

components/collapse/style/index.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@
120120
border-radius: 0;
121121
}
122122

123+
// hide the last border-bottom in borderless mode
124+
&-borderless > &-item:last-child {
125+
border-bottom: 0;
126+
}
127+
123128
&-borderless > &-item > &-content {
124129
background-color: transparent;
125130
border-top: 0;

0 commit comments

Comments
 (0)