Skip to content

Commit

Permalink
fix: fix faq accordion spacing for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronchan32 committed Jun 2, 2024
1 parent 687c45a commit 576c6eb
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions src/app/components/MyAccordion/MyAccordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
$trigger-padding-desktop: calc($h3-size * 1.25);
$border-thickness: 1px;
// Used to reduce space between accordion trigger and content by ignoring trigger's padding-bottom
$content-top-offset: calc(0.75 * $trigger-padding-desktop);
$content-top-offset-desktop: calc(0.75 * $trigger-padding-desktop);
$content-top-offset-mobile: calc(0.5 * $trigger-padding-mobile);

height: 100%;
overflow-y: auto;
Expand Down Expand Up @@ -95,9 +96,15 @@

&[data-state='open'] {
animation: slideDown 300ms forwards;
@media (min-width: $mobile-breakpoint) {
animation: slideDownDesktop 300ms forwards;
}
}
&[data-state='closed'] {
animation: slideUp 300ms;
@media (min-width: $mobile-breakpoint) {
animation: slideUpDesktop 300ms forwards;
}
}

p {
Expand Down Expand Up @@ -132,18 +139,42 @@
}
to {
height: calc(
var(--radix-accordion-content-height) - $content-top-offset
var(--radix-accordion-content-height) - $content-top-offset-mobile
);
transform: translateY(calc(-1 * $content-top-offset-mobile));
}
}

@keyframes slideDownDesktop {
from {
height: 0;
}
to {
height: calc(
var(--radix-accordion-content-height) - $content-top-offset-desktop
);
transform: translateY(calc(-1 * $content-top-offset));
transform: translateY(calc(-1 * $content-top-offset-desktop));
}
}

@keyframes slideUp {
from {
height: calc(
var(--radix-accordion-content-height) - $content-top-offset
var(--radix-accordion-content-height) - $content-top-offset-mobile
);
transform: translateY(calc(-1 * $content-top-offset-mobile));
}
to {
height: 0;
}
}

@keyframes slideUpDesktop {
from {
height: calc(
var(--radix-accordion-content-height) - $content-top-offset-desktop
);
transform: translateY(calc(-1 * $content-top-offset));
transform: translateY(calc(-1 * $content-top-offset-desktop));
}
to {
height: 0;
Expand Down

0 comments on commit 576c6eb

Please sign in to comment.