Skip to content

Commit

Permalink
fix(#4011): checkbox Moved padding values from js to custom css varia…
Browse files Browse the repository at this point in the history
…bles (#4013)

Co-authored-by: Maksim Nedoshev <[email protected]>
  • Loading branch information
Abhid1239 and m0ksem authored Nov 20, 2023
1 parent 40cb0b8 commit 505996c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
25 changes: 16 additions & 9 deletions packages/ui/src/components/va-checkbox/VaCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,25 @@ export default defineComponent({
'va-checkbox--on-keyboard-focus': hasKeyboardFocus.value,
}))
const getPaddingStyle = () => {
switch (true) {
case !props.label:
return ''
case props.vertical:
return 'var(--va-checkbox-vertical-padding)'
case Boolean(props.arrayValue):
return 'var(--va-checkbox-horizontal-padding)'
case props.leftLabel:
return 'var(--va-checkbox-right-padding)'
default:
return 'var(--va-checkbox-left-padding)'
}
}
const labelStyle = computed(() => {
return {
color: computedError.value ? getColor('danger') : (props.success ? getColor('success') : ''),
padding: !props.label
? ''
: props.vertical
? '0.3rem 0 0.3rem 0.5rem'
: props.arrayValue
? '0 0.5rem 0 0.5rem'
: props.leftLabel
? '0 0.5rem 0 0'
: '0 0 0 0.5rem',
padding: getPaddingStyle(),
}
})
Expand Down
8 changes: 8 additions & 0 deletions packages/ui/src/components/va-checkbox/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@
--va-checkbox-square-height: 1.25rem;
--va-checkbox-square-border: solid var(--va-form-element-border-width) var(--va-background-border);
--va-checkbox-square-border-radius: calc(var(--va-form-element-border-radius) / 2);

/* Padding */
--va-checkbox-horizontal-gap: 0.5em;
--va-checkbox-vertical-gap: 0.3em;
--va-checkbox-vertical-padding: var(--va-checkbox-vertical-gap) 0 var(--va-checkbox-vertical-gap) var(--va-checkbox-horizontal-gap);
--va-checkbox-horizontal-padding: 0 var(--va-checkbox-horizontal-gap);
--va-checkbox-right-padding: 0 var(--va-checkbox-horizontal-gap) 0 0;
--va-checkbox-left-padding: 0 0 0 var(--va-checkbox-horizontal-gap);
}

0 comments on commit 505996c

Please sign in to comment.