Skip to content

Commit a5d9cff

Browse files
committed
fix: fix checkbox/radio alignment when there is no label
1 parent 65fb1af commit a5d9cff

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

packages/veui-theme-dls/components/button.less

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@
344344
&[ui~="icon"] {
345345
&::after {
346346
.size(calc(@dls-icon-size-normal + @dls-button-padding-text * 2));
347+
.absolute(50%, auto, auto, 50%);
348+
transform: translate(-50%, -50%);
347349
}
348350
}
349351

packages/veui-theme-dls/components/checkbox.less

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,11 @@
123123
.@{veui-prefix}-checkbox-box {
124124
.size(@@s);
125125

126-
// Baseline is around 0.1414em above bottom line for macOS's system font
127-
// see https://jsbin.com/yimugoxina/edit?html,css,js,output
128-
top: dls-sum(@@s / 2, -@@fs / 2, 0.1414em);
126+
&-labelled {
127+
// Baseline is around 0.1414em above bottom line for macOS's system font
128+
// see https://jsbin.com/yimugoxina/edit?html,css,js,output
129+
top: dls-sum(@@s / 2, -@@fs / 2, 0.1414em);
130+
}
129131
}
130132
}
131133

packages/veui-theme-dls/components/radio.less

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,11 @@
127127
.@{veui-prefix}-radio-box {
128128
.size(@@s);
129129

130-
// Baseline is around 0.1414em above bottom line for macOS's system font
131-
// see https://jsbin.com/yimugoxina/edit?html,css,js,output
132-
top: dls-sum(@@s / 2, -@@fs / 2, 0.1414em);
130+
&-labelled {
131+
// Baseline is around 0.1414em above bottom line for macOS's system font
132+
// see https://jsbin.com/yimugoxina/edit?html,css,js,output
133+
top: dls-sum(@@s / 2, -@@fs / 2, 0.1414em);
134+
}
133135

134136
&::before {
135137
.size(@@ds);

packages/veui/src/components/Checkbox.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
@change="handleChange"
1818
@click.stop
1919
>
20-
<span :class="$c('checkbox-box')">
20+
<span
21+
:class="{
22+
[$c('checkbox-box')]: true,
23+
[$c('checkbox-box-labelled')]: !!$slots.default
24+
}"
25+
>
2126
<transition :name="$c('checkbox-icon')">
2227
<veui-icon
2328
v-if="indeterminate"

packages/veui/src/components/Radio.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
@veui:uncheck="handleUncheck"
1919
@click.stop
2020
>
21-
<span :class="$c('radio-box')"/>
21+
<span
22+
:class="{
23+
[$c('radio-box')]: true,
24+
[$c('radio-box-labelled')]: !!$slots.default
25+
}"
26+
/>
2227
<span
2328
v-if="$slots.default"
2429
:class="$c('radio-label')"
@@ -182,7 +187,7 @@ export default {
182187
let siblings = form
183188
? form.querySelectorAll(`input[name="${name}"][type="radio"]`)
184189
: orphans.get(name)
185-
;[...(siblings || [])].forEach(sibling => {
190+
;[...(siblings || [])].forEach((sibling) => {
186191
if (radio !== sibling) {
187192
triggerCustom(sibling, event)
188193
}

0 commit comments

Comments
 (0)