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

Update accordion vf-transition syntax #4548

Merged
Merged
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
24 changes: 3 additions & 21 deletions scss/_layouts_application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,7 @@ $application-layout--side-nav-width-expanded: 15rem !default;
// Navigation panel/drawer
// -------------------------
.l-navigation {
@include vf-transition(
$property: (
transform,
box-shadow,
),
$duration: fast
);
@include vf-transition($property: #{transform, box-shadow}, $duration: fast);

bottom: 0;
box-shadow: $panel-drop-shadow;
Expand Down Expand Up @@ -117,13 +111,7 @@ $application-layout--side-nav-width-expanded: 15rem !default;
}

.l-navigation {
@include vf-transition(
$property: (
width,
box-shadow,
),
$duration: fast
);
@include vf-transition($property: #{width, box-shadow}, $duration: fast);

box-shadow: $panel-drop-shadow-transparent;
overflow: hidden;
Expand Down Expand Up @@ -246,13 +234,7 @@ $application-layout--side-nav-width-expanded: 15rem !default;
}

.l-aside {
@include vf-transition(
$property: (
transform,
box-shadow,
),
$duration: snap
);
@include vf-transition($property: #{transform, box-shadow}, $duration: snap);

box-shadow: $panel-drop-shadow;
grid-area: main;
Expand Down
6 changes: 3 additions & 3 deletions scss/_patterns_accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@
&:hover {
background-color: $colors--light-theme--background-hover;
}
@include vf-animation(#{background-color, border-color});
@include vf-transition(#{background-color, border-color});
}

&[aria-expanded='false'] {
&::before {
transform: rotate(-90deg);
}

@include vf-animation(#{background-color, border-color});
@include vf-transition(#{background-color, border-color});
}
}

Expand Down Expand Up @@ -92,7 +92,7 @@
overflow: auto; // include child margins into its height
padding-left: $sph--large + $icon-size + $sph--large * 2;

@include vf-animation('transform, opacity', fast);
@include vf-transition(#{transform, opacity}, fast);
// Hides panel content
&[aria-hidden='true'] {
height: 0;
Expand Down
5 changes: 4 additions & 1 deletion scss/_settings_animations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ $animation-easing: (
);

@mixin vf-transition($property: all, $duration: brisk, $easing: out) {
@if (type-of($property) != string) {
@error "vf-transition $property must be a string";
}
transition-duration: map-get($animation-duration, $duration);
transition-property: $property;
transition-property: unquote($property);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you pass quoted strings or list to vf-transition as $property it'll result in an invalid CSS (and scss does not complain).

As an example, passing either $property: ('width', 'box-shadow') or 'width, box-shadow' will have a result similar to the following:
image

@bartaz In cases such as this, would you prefer if we formatted the string (e.g. by using unquote) or simply threw an error and disallow passing incorrectly formatted strings in the first place?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting the string seems better.
I guess in most cases anyone trying to use it would search for examples of use and copy those. But I agree it is a little bit unclear how to pass multiple prop to animate at once.

transition-timing-function: map-get($animation-easing, $easing);
}

Expand Down