Skip to content

Commit

Permalink
Add size parameter for animated link (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz authored and wachterjohannes committed May 15, 2019
1 parent 2f2a502 commit 79e6e5f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 2.0.0

- FEATURE: Add size parameter for animated link. #51
- BUGFIX: Fix corejs options overwrite between components. #50
- ENHANCEMENT: Rename to @sulu/web and restructure repository. #49
- ENHANCEMENT: Add possibility to extend container link attributes. #48
Expand Down
45 changes: 30 additions & 15 deletions packages/scss/tools/animation-link/_animation-link.scss
Original file line number Diff line number Diff line change
@@ -1,40 +1,55 @@
$animatedLinkColor: currentColor !default;
$animatedLinkSize: 0.1em !default;
$animatedLinkSpeed: 0.25s !default;
$animatedLinkExistKeyframes: ();

@mixin animatedLink($color: $animatedLinkColor) {
@function animatedKeyFrameName($size) {
@return linkHover#{$size * 10000};
}

@mixin animatedLinkKeyFrames($size) {
@if not map-has-key($animatedLinkExistKeyframes, $size) {
@keyframes #{animatedKeyFrameName($size)} {
0% {
background-size: 0 $size;
}

100% {
background-size: 100% $size;
}
}
}

$animatedLinkExistKeyframes: map-merge($animatedLinkExistKeyframes, ($size: $size)) !global;
}

@mixin animatedLink($color: $animatedLinkColor, $size: $animatedLinkSize) {
background-image: linear-gradient($color, $color);
background-position: left bottom;
background-repeat: no-repeat;
background-size: 100% $animatedLinkSize;
background-size: 100% $size;

&:hover,
&:focus {
animation-duration: $animatedLinkSpeed;
animation-name: linkHover;
animation-name: animatedKeyFrameName($size);
}

@include animatedLinkKeyFrames($size);
}

@mixin animatedLinkHover($color: $animatedLinkColor) {
@mixin animatedLinkHover($color: $animatedLinkColor, $size: $animatedLinkSize) {
background: none;

&:hover,
&:focus {
animation-duration: $animatedLinkSpeed;
animation-name: linkHover;
animation-name: animatedKeyFrameName($size);
background-image: linear-gradient($color, $color);
background-position: left bottom;
background-repeat: no-repeat;
background-size: 100% $animatedLinkSize;
}
}

@keyframes linkHover {
0% {
background-size: 0 $animatedLinkSize;
background-size: 100% $size;
}

100% {
background-size: 100% $animatedLinkSize;
}
@include animatedLinkKeyFrames($size);
}

0 comments on commit 79e6e5f

Please sign in to comment.