Skip to content

Commit

Permalink
Add Prefers Reduced Motion support for most components (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mysterious-Dev authored Nov 11, 2023
1 parent bf5d391 commit 66154b3
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/components/base/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ export default defineComponent({
height: 1rem;
width: 1rem;
transition: transform 0.25s ease-in-out;
@media (prefers-reduced-motion) {
transition: none !important;
}
}
&.checked {
Expand Down
4 changes: 4 additions & 0 deletions lib/components/base/CopyCode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export default {
transition: opacity 0.5s ease-in-out, filter 0.2s ease-in-out, transform 0.05s ease-in-out,
outline 0.2s ease-in-out;
@media (prefers-reduced-motion) {
transition: none !important;
}
span {
max-width: 10rem;
overflow: hidden;
Expand Down
4 changes: 4 additions & 0 deletions lib/components/base/DropArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,9 @@ onMounted(() => {
border-radius: 1rem;
border: 0.25rem dashed var(--color-button-bg);
}
@media (prefers-reduced-motion) {
transition: none !important;
}
}
</style>
4 changes: 4 additions & 0 deletions lib/components/base/Notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ function stopTimer(notif) {
.notifs-leave-active,
.notifs-move {
transition: all 0.5s;
@media (prefers-reduced-motion) {
transition: none !important;
}
}
.notifs-enter-from,
.notifs-leave-to {
Expand Down
4 changes: 4 additions & 0 deletions lib/components/base/Pagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ a {
transition: opacity 0.5s ease-in-out, filter 0.2s ease-in-out, transform 0.05s ease-in-out,
outline 0.2s ease-in-out;
@media (prefers-reduced-motion) {
transition: none !important;
}
&:hover {
color: inherit;
text-decoration: none;
Expand Down
4 changes: 4 additions & 0 deletions lib/components/base/PopoutMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ onBeforeUnmount(() => {
transition: bottom 0.125s ease-in-out, top 0.125s ease-in-out, left 0.125s ease-in-out,
right 0.125s ease-in-out, opacity 0.125s ease-in-out, scale 0.125s ease-in-out;
@media (prefers-reduced-motion) {
transition: none !important;
}
&.position-bottom-left {
top: calc(100% + var(--gap-sm) - 1rem);
right: -1rem;
Expand Down
14 changes: 10 additions & 4 deletions lib/components/base/Slider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ const onInput = (value: string) => {

<style lang="scss" scoped>
.root-container {
--transition-speed: 0.2s;
@media (prefers-reduced-motion) {
--transition-speed: 0s;
}
display: flex;
flex-direction: row;
align-items: center;
Expand Down Expand Up @@ -159,7 +165,7 @@ const onInput = (value: string) => {
background: var(--color-brand);
cursor: pointer;
border-radius: 50%;
transition: 0.2s;
transition: var(--transition-speed);
}
.slider-component .slide-container .slider::-moz-range-thumb {
Expand All @@ -169,19 +175,19 @@ const onInput = (value: string) => {
background: var(--color-brand);
cursor: pointer;
border-radius: 50%;
transition: 0.2s;
transition: var(--transition-speed);
}
.slider-component .slide-container .slider:hover::-webkit-slider-thumb:not(.disabled) {
width: 1rem;
height: 1rem;
transition: 0.2s;
transition: var(--transition-speed);
}
.slider-component .slide-container .slider:hover::-moz-range-thumb:not(.disabled) {
width: 1rem;
height: 1rem;
transition: 0.2s;
transition: var(--transition-speed);
}
.slider-component .slide-container .snap-points-wrapper {
Expand Down
8 changes: 8 additions & 0 deletions lib/components/modal/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ defineExpose({
z-index: 19;
transition: all 0.3s ease-in-out;
@media (prefers-reduced-motion) {
transition: none !important;
}
&.shown {
opacity: 1;
visibility: visible;
Expand Down Expand Up @@ -164,6 +168,10 @@ defineExpose({
opacity: 0;
transition: all 0.25s ease-in-out;
@media (prefers-reduced-motion) {
transition: none !important;
}
@media screen and (max-width: 650px) {
width: calc(100% - 2 * var(--gap-lg));
}
Expand Down
4 changes: 4 additions & 0 deletions lib/components/modal/ShareModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ defineExpose({
margin: var(--gap-sm);
transition: all 0.2s ease-in-out;
opacity: 0;
@media (prefers-reduced-motion) {
transition: none !important;
}
}
.resizable-textarea-wrapper {
Expand Down

0 comments on commit 66154b3

Please sign in to comment.