2
2
@use ' sass:list' ;
3
3
@use ' src/variables' as vars ;
4
4
5
+ /// Gets the min/max css function to constrain the size within a min and max size in px.
6
+ /// @param {number} $sizePercentage - The size of the bubble as a percentage of the button size.
7
+ @function sizeCalc ($sizePercentage ) {
8
+ @return min (max (#{$minBubbleSize } , #{$sizePercentage } ), #{$maxBubbleSize } );
9
+ }
10
+
11
+ $minBubbleSize : 30px ;
12
+ $maxBubbleSize : 50px ;
5
13
$bubbleColor : vars .$blueMedium ;
6
14
$animationDuration : 0.7s ;
7
15
@@ -18,23 +26,23 @@ $bubbleTypes: (
18
26
// prettier-ignore
19
27
$bubbles : (
20
28
// Top bubbles
21
- (location : ' top' , type : 1 , size :( 10 % 10% ) , pos0 :( 5% 90% ), pos50 :( 0% 80% ), pos100 :( 0% 70% )),
22
- (location : ' top' , type : 2 , size :( 20 % 20% ) , pos0 :(10% 90% ), pos50 :( 0% 20% ), pos100 :( 0% 10% )),
23
- (location : ' top' , type : 1 , size :( 15 % 15% ) , pos0 :(10% 90% ), pos50 :(10% 40% ), pos100 :(10% 30% )),
24
- (location : ' top' , type : 1 , size :( 20 % 20% ) , pos0 :(15% 90% ), pos50 :(20% 0% ), pos100 :(20% -10% )),
25
- (location : ' top' , type : 3 , size :( 18 % 18% ) , pos0 :(25% 90% ), pos50 :(30% 30% ), pos100 :(30% 20% )),
26
- (location : ' top' , type : 1 , size :( 10 % 10% ) , pos0 :(25% 90% ), pos50 :(22% 50% ), pos100 :(22% 40% )),
27
- (location : ' top' , type : 1 , size :( 15 % 15% ) , pos0 :(40% 90% ), pos50 :(50% 50% ), pos100 :(50% 40% )),
28
- (location : ' top' , type : 1 , size :( 10 % 10% ) , pos0 :(55% 90% ), pos50 :(65% 20% ), pos100 :(65% 10% )),
29
- (location : ' top' , type : 1 , size :( 18 % 18% ) , pos0 :(70% 90% ), pos50 :(90% 30% ), pos100 :(90% 20% )),
29
+ (location : ' top' , type : 1 , size : 10% , pos0 : ( 5% 90% ), pos50 : ( 0% 80% ), pos100 : ( 0% 70% )),
30
+ (location : ' top' , type : 2 , size : 20% , pos0 : (10% 90% ), pos50 : ( 0% 20% ), pos100 : ( 0% 10% )),
31
+ (location : ' top' , type : 1 , size : 15% , pos0 : (10% 90% ), pos50 : (10% 40% ), pos100 : (10% 30% )),
32
+ (location : ' top' , type : 1 , size : 20% , pos0 : (15% 90% ), pos50 : (20% 0% ), pos100 : (20% -10% )),
33
+ (location : ' top' , type : 3 , size : 18% , pos0 : (25% 90% ), pos50 : (30% 30% ), pos100 : (30% 20% )),
34
+ (location : ' top' , type : 1 , size : 10% , pos0 : (25% 90% ), pos50 : (22% 50% ), pos100 : (22% 40% )),
35
+ (location : ' top' , type : 1 , size : 15% , pos0 : (40% 90% ), pos50 : (50% 50% ), pos100 : (50% 40% )),
36
+ (location : ' top' , type : 1 , size : 10% , pos0 : (55% 90% ), pos50 : (65% 20% ), pos100 : (65% 10% )),
37
+ (location : ' top' , type : 1 , size : 18% , pos0 : (70% 90% ), pos50 : (90% 30% ), pos100 : (90% 20% )),
30
38
// Bottom bubbles
31
- (location : ' bottom' , type : 1 , size :( 15 % 15% ) , pos0 :(10% -10% ), pos50 :( 0% 80% ), pos100 :( 0% 90% )),
32
- (location : ' bottom' , type : 1 , size :( 20 % 20% ) , pos0 :(30% 10% ), pos50 :( 20% 80% ), pos100 :( 20% 90% )),
33
- (location : ' bottom' , type : 3 , size :( 18 % 18% ) , pos0 :(55% -10% ), pos50 :( 45% 60% ), pos100 :( 45% 70% )),
34
- (location : ' bottom' , type : 1 , size :( 20 % 20% ) , pos0 :(70% -10% ), pos50 :( 60% 100% ), pos100 :( 60% 110% )),
35
- (location : ' bottom' , type : 1 , size :( 15 % 15% ) , pos0 :(85% -10% ), pos50 :( 75% 70% ), pos100 :( 75% 80% )),
36
- (location : ' bottom' , type : 1 , size :( 10 % 10% ) , pos0 :(70% -10% ), pos50 :( 95% 60% ), pos100 :( 95% 70% )),
37
- (location : ' bottom' , type : 1 , size :( 20 % 20% ) , pos0 :(70% 0% ), pos50 :(105% 0% ), pos100 :(110% 10% ))
39
+ (location : ' bottom' , type : 1 , size : 15% , pos0 : (10% -10% ), pos50 : ( 0% 80% ), pos100 : ( 0% 90% )),
40
+ (location : ' bottom' , type : 1 , size : 20% , pos0 : (30% 10% ), pos50 : ( 20% 80% ), pos100 : ( 20% 90% )),
41
+ (location : ' bottom' , type : 3 , size : 18% , pos0 : (55% -10% ), pos50 : ( 45% 60% ), pos100 : ( 45% 70% )),
42
+ (location : ' bottom' , type : 1 , size : 20% , pos0 : (70% -10% ), pos50 : ( 60% 100% ), pos100 : ( 60% 110% )),
43
+ (location : ' bottom' , type : 1 , size : 15% , pos0 : (85% -10% ), pos50 : ( 75% 70% ), pos100 : ( 75% 80% )),
44
+ (location : ' bottom' , type : 1 , size : 10% , pos0 : (70% -10% ), pos50 : ( 95% 60% ), pos100 : ( 95% 70% )),
45
+ (location : ' bottom' , type : 1 , size : 20% , pos0 : (70% 0% ), pos50 : (105% 0% ), pos100 : (110% 10% ))
38
46
);
39
47
40
48
// Initialize empty lists
@@ -52,20 +60,20 @@ $bottomBubblesPos100s: ();
52
60
@each $bubble in $bubbles {
53
61
$location : map .get ($bubble , location );
54
62
$type : map .get ($bubble , type );
55
- $size : map .get ($bubble , size );
63
+ $size : sizeCalc ( map .get ($bubble , size ) );
56
64
$pos0 : map .get ($bubble , pos0 );
57
65
$pos50 : map .get ($bubble , pos50 );
58
66
$pos100 : map .get ($bubble , pos100 );
59
67
60
68
@if $location == ' top' {
61
69
$topBubblesImages : list .append ($topBubblesImages , map .get ($bubbleTypes , $type ), comma );
62
- $topBubblesSizes : list .append ($topBubblesSizes , $size , comma );
70
+ $topBubblesSizes : list .append ($topBubblesSizes , ( $size $size ) , comma );
63
71
$topBubblesPos0s : list .append ($topBubblesPos0s , $pos0 , comma );
64
72
$topBubblesPos50s : list .append ($topBubblesPos50s , $pos50 , comma );
65
73
$topBubblesPos100s : list .append ($topBubblesPos100s , $pos100 , comma );
66
74
} @else if $location == ' bottom' {
67
75
$bottomBubblesImages : list .append ($bottomBubblesImages , map .get ($bubbleTypes , $type ), comma );
68
- $bottomBubblesSizes : list .append ($bottomBubblesSizes , $size , comma );
76
+ $bottomBubblesSizes : list .append ($bottomBubblesSizes , ( $size $size ) , comma );
69
77
$bottomBubblesPos0s : list .append ($bottomBubblesPos0s , $pos0 , comma );
70
78
$bottomBubblesPos50s : list .append ($bottomBubblesPos50s , $pos50 , comma );
71
79
$bottomBubblesPos100s : list .append ($bottomBubblesPos100s , $pos100 , comma );
@@ -74,7 +82,9 @@ $bottomBubblesPos100s: ();
74
82
75
83
.sf-bubble-button {
76
84
position : relative ;
77
- transition : transform linear 0.02s ;
85
+
86
+ // Transition the scale down effect of button press
87
+ transition : transform linear 50ms ;
78
88
79
89
& :active {
80
90
transform : scale (0.95 );
@@ -104,7 +114,6 @@ $bottomBubblesPos100s: ();
104
114
padding-top : 30% ; // Percentage of width of containing element
105
115
106
116
z-index : -1 ;
107
- transition : all ease-in-out 0.5s ;
108
117
background-repeat : no-repeat ;
109
118
}
110
119
@@ -125,11 +134,11 @@ $bottomBubblesPos100s: ();
125
134
& .sf-bubble-animate {
126
135
& :before {
127
136
display : block ;
128
- animation : emit- bubbles- top ease-in- out $animationDuration forwards ;
137
+ animation : emit- bubbles- top ease-out $animationDuration forwards ;
129
138
}
130
139
& :after {
131
140
display : block ;
132
- animation : emit- bubbles- bottom ease-in- out $animationDuration forwards ;
141
+ animation : emit- bubbles- bottom ease-out $animationDuration forwards ;
133
142
}
134
143
}
135
144
}
0 commit comments