Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VaSwitch): Remove horizontal scrollbar behavior #4317

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions packages/ui/src/components/va-switch/VaSwitch.demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,31 @@
label="large"
/>
</VbCard>
<VbCard title="Sizes with inner label slot">
<va-switch
v-model="value"
size="small"
>
<template #innerLabel>
Small with Inner
</template>
</va-switch>
<va-switch
v-model="value"
>
<template #innerLabel>
Inner
</template>
</va-switch>
<va-switch
v-model="value"
size="large"
>
<template #innerLabel>
Large with Inner
</template>
</va-switch>
</VbCard>
<VbCard title="Label Position" style="width: 300px;">
<div>
<va-switch
Expand Down Expand Up @@ -205,6 +230,22 @@
indeterminate
/>
</VbCard>
<VbCard title="Sizes with indeterminate">
<va-switch
v-model="valueIndeterminate"
indeterminate
size="small"
/>
<va-switch
v-model="valueIndeterminate"
indeterminate
/>
<va-switch
v-model="valueIndeterminate"
indeterminate
size="large"
/>
</VbCard>
<VbCard title="Indeterminate with custom indeterminate value">
<div>
{{ valueIndeterminateCustom }}
Expand Down
112 changes: 88 additions & 24 deletions packages/ui/src/components/va-switch/VaSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -334,32 +334,11 @@ defineExpose({
}
}

&--indeterminate {
.va-switch {
&__checker {
margin: auto 0;
transform: translateX(-50%);
}

&__checker-wrapper {
transform: translateX(50%);
}
}
}

&--checked {
.va-switch {
&__checker {
transform: translateX(calc(-100% - 0.3rem));
}

&__checker-circle {
background-color: var(--va-switch-checker-active-background-color);
}

&__checker-wrapper {
transform: translateX(100%);
}
}
}

Expand Down Expand Up @@ -435,7 +414,7 @@ defineExpose({
}
}

&__checker {
#{&}__checker {
position: absolute;
top: 0;
bottom: 0;
Expand All @@ -444,8 +423,94 @@ defineExpose({
box-shadow: var(--va-switch-checker-box-shadow);
transition: var(--va-switch-checker-transition);
display: flex;
justify-content: center;
align-items: center;
width: 100%;

@at-root {
.va-switch--indeterminate#{&} {
margin: auto 0;
transform:
translateX(
calc(
calc(
var(--va-switch-checker-wrapper-width)
- var(--va-switch-checker-width)
)
/ 2
)
);
}

.va-switch--checked#{&} {
transform:
translateX(
calc(
var(--va-switch-checker-wrapper-width)
- var(--va-switch-checker-width)
- 0.3rem
)
);
}

.va-switch--small#{&} {
@at-root {
.va-switch--indeterminate#{&} {
transform:
translateX(
calc(
calc(
var(--va-switch-checker-wrapper-width)
- var(--va-switch-checker-width)
+ 0.4rem
)
/ 2
)
);
}

.va-switch--checked#{&} {
transform:
translateX(
calc(
var(--va-switch-checker-wrapper-width)
- var(--va-switch-checker-width)
- 0.3rem
+ 0.4rem
)
);
}
}
}
.va-switch--large#{&} {
@at-root {
.va-switch--indeterminate#{&} {
transform:
translateX(
calc(
calc(
var(--va-switch-checker-wrapper-width)
- var(--va-switch-checker-width)
- 0.3rem
)
/ 2
)
);
}

.va-switch--checked#{&} {
transform:
translateX(
calc(
var(--va-switch-checker-wrapper-width)
- var(--va-switch-checker-width)
- 0.3rem
- 0.3rem
)
);
}
}
}
}
}

&__checker-circle {
Expand All @@ -461,7 +526,6 @@ defineExpose({
&__checker-wrapper {
position: absolute;
margin: auto;
transform: var(--va-switch-checker-wrapper-transform);
top: var(--va-switch-checker-wrapper-top);
left: var(--va-switch-checker-wrapper-left);
bottom: var(--va-switch-checker-wrapper-bottom);
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/components/va-switch/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
--va-switch-checker-transition: all 0.2s ease;

/* Checker Wrapper */
--va-switch-checker-wrapper-transform: translateX(0);
--va-switch-checker-wrapper-top: 0;
--va-switch-checker-wrapper-left: 0;
--va-switch-checker-wrapper-bottom: 0;
Expand Down
Loading