Skip to content

Commit 1279c52

Browse files
melbahjajohnleider
authored andcommitted
fix(SelectionControls): fix dense styles (#9505)
fixes #9381 * add: dense to VCheckbox VIcon * add: dense prop to VRadio VIcon * add: dense vars * add: dense rules * add: dense rules * fix: lint * add(VRadioGroup): dense snap * add(VRadioGroup): dense snap test
1 parent 886c8a3 commit 1279c52

File tree

7 files changed

+106
-1
lines changed

7 files changed

+106
-1
lines changed

packages/vuetify/src/components/VCheckbox/VCheckbox.ts

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export default Selectable.extend({
9393
this.genRipple(this.setTextColor(this.validationState)),
9494
this.$createElement(VIcon, this.setTextColor(this.validationState, {
9595
props: {
96+
dense: this.dense,
9697
dark: this.dark,
9798
light: this.light,
9899
},

packages/vuetify/src/components/VRadioGroup/VRadio.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ export default baseMixins.extend<options>().extend({
145145
...this.attrs$,
146146
}),
147147
this.genRipple(this.setTextColor(this.validationState)),
148-
this.$createElement(VIcon, this.setTextColor(this.validationState, {}), this.computedIcon),
148+
this.$createElement(VIcon, this.setTextColor(this.validationState, {
149+
props: {
150+
dense: this.radioGroup && this.radioGroup.dense,
151+
},
152+
}), this.computedIcon),
149153
])
150154
},
151155
onFocus (e: Event) {

packages/vuetify/src/components/VRadioGroup/__tests__/VRadioGroup.spec.ts

+14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Components
2+
import VRadio from '../VRadio'
23
import VRadioGroup from '../VRadioGroup'
34

45
// Utilities
@@ -23,4 +24,17 @@ describe('VRadioGroup.ts', () => {
2324

2425
expect(wrapper.html()).toMatchSnapshot()
2526
})
27+
28+
it('should match dense snapshot', async () => {
29+
const wrapper = mountFunction({
30+
propsData: {
31+
dense: true,
32+
},
33+
slots: {
34+
default: [VRadio],
35+
},
36+
})
37+
38+
expect(wrapper.html()).toMatchSnapshot()
39+
})
2640
})

packages/vuetify/src/components/VRadioGroup/__tests__/__snapshots__/VRadioGroup.spec.ts.snap

+41
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,44 @@ exports[`VRadioGroup.ts should match snapshot 1`] = `
2222
</div>
2323
</div>
2424
`;
25+
26+
exports[`VRadioGroup.ts should match dense snapshot 1`] = `
27+
<div class="v-input v-input--dense theme--light v-input--selection-controls v-input--radio-group v-input--radio-group--column">
28+
<div class="v-input__control">
29+
<div class="v-input__slot"
30+
style="height: auto;"
31+
>
32+
<div role="radiogroup"
33+
aria-labelledby="input-5"
34+
class="v-input--radio-group__input"
35+
>
36+
<div class="v-radio theme--light">
37+
<div class="v-input--selection-controls__input">
38+
<input aria-checked="false"
39+
id="input-6"
40+
role="radio"
41+
type="radio"
42+
name="radio-5"
43+
value
44+
>
45+
<div class="v-input--selection-controls__ripple">
46+
</div>
47+
<i aria-hidden="true"
48+
class="v-icon notranslate v-icon--dense material-icons theme--light"
49+
>
50+
$radioOff
51+
</i>
52+
</div>
53+
</div>
54+
</div>
55+
</div>
56+
<div class="v-messages theme--light">
57+
<span name="message-transition"
58+
tag="div"
59+
class="v-messages__wrapper"
60+
>
61+
</span>
62+
</div>
63+
</div>
64+
</div>
65+
`;

packages/vuetify/src/components/VSwitch/VSwitch.sass

+27
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@
4949
.v-input--selection-controls__ripple
5050
top: $switch-ripple-top
5151

52+
&.v-input--dense
53+
.v-input--switch__thumb
54+
width: $switch-thumb-dense-width
55+
height: $switch-thumb-dense-height
56+
57+
.v-input--switch__track
58+
height: $switch-track-dense-height
59+
width: $switch-track-dense-width
60+
61+
&.v-input--switch--inset
62+
.v-input--switch__track
63+
height: 22px
64+
width: 44px
65+
top: $switch-track-dense-top
66+
left: -3px
67+
68+
.v-input--selection-controls__ripple
69+
top: $switch-ripple-dense-top
70+
5271
&.v-input--is-dirty
5372
&.v-input--is-disabled
5473
opacity: $switch-disabled-opacity
@@ -57,6 +76,10 @@
5776
.v-input--selection-controls__ripple
5877
left: $switch-ripple-x
5978

79+
&.v-input--dense
80+
.v-input--selection-controls__ripple
81+
left: $switch-ripple-dense-x
82+
6083
&.v-input--is-dirty
6184
.v-input--selection-controls__ripple,
6285
.v-input--switch__thumb
@@ -66,6 +89,10 @@
6689
.v-input--selection-controls__ripple
6790
right: $switch-ripple-x
6891

92+
&.v-input--dense
93+
.v-input--selection-controls__ripple
94+
right: $switch-ripple-dense-x
95+
6996
&.v-input--is-dirty
7097
.v-input--selection-controls__ripple,
7198
.v-input--switch__thumb

packages/vuetify/src/components/VSwitch/_variables.sass

+8
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@ $switch-thumb-height: 20px !default
1414
$switch-thumb-top: calc(50% - 10px) !default
1515
$switch-thumb-elevation: 4 !default
1616
$switch-dirty-offset-x: 20px !default
17+
18+
$switch-track-dense-top: calc(50% - 12px) !default
19+
$switch-track-dense-width: 32px !default
20+
$switch-track-dense-height: 12px !default
21+
$switch-thumb-dense-width: 18px !default
22+
$switch-thumb-dense-height: 18px !default
23+
$switch-ripple-dense-top: calc(50% - 22px) !default
24+
$switch-ripple-dense-x: -12px !default

packages/vuetify/src/styles/components/_selection-controls.sass

+10
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@
8282
.v-ripple__container
8383
transform: scale(1.2)
8484

85+
&.v-input--dense
86+
.v-input--selection-controls__ripple
87+
width: 28px
88+
height: 28px
89+
left: -11px
90+
91+
&:not(.v-input--switch)
92+
.v-input--selection-controls__ripple
93+
top: calc(50% - 21px)
94+
8595
&.v-input
8696
flex: 0 1 auto
8797

0 commit comments

Comments
 (0)