Skip to content

Commit 76b4508

Browse files
committed
SF-2193 Add bubble size constraints
1 parent afc2b4e commit 76b4508

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

src/SIL.XForge.Scripture/ClientApp/src/xforge-common/bubble-button/bubble-button.scss

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
@use 'sass:list';
33
@use 'src/variables' as vars;
44

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;
513
$bubbleColor: vars.$blueMedium;
614
$animationDuration: 0.7s;
715

@@ -18,23 +26,23 @@ $bubbleTypes: (
1826
// prettier-ignore
1927
$bubbles: (
2028
// 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%)),
3038
// 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%))
3846
);
3947

4048
// Initialize empty lists
@@ -52,20 +60,20 @@ $bottomBubblesPos100s: ();
5260
@each $bubble in $bubbles {
5361
$location: map.get($bubble, location);
5462
$type: map.get($bubble, type);
55-
$size: map.get($bubble, size);
63+
$size: sizeCalc(map.get($bubble, size));
5664
$pos0: map.get($bubble, pos0);
5765
$pos50: map.get($bubble, pos50);
5866
$pos100: map.get($bubble, pos100);
5967

6068
@if $location == 'top' {
6169
$topBubblesImages: list.append($topBubblesImages, map.get($bubbleTypes, $type), comma);
62-
$topBubblesSizes: list.append($topBubblesSizes, $size, comma);
70+
$topBubblesSizes: list.append($topBubblesSizes, ($size $size), comma);
6371
$topBubblesPos0s: list.append($topBubblesPos0s, $pos0, comma);
6472
$topBubblesPos50s: list.append($topBubblesPos50s, $pos50, comma);
6573
$topBubblesPos100s: list.append($topBubblesPos100s, $pos100, comma);
6674
} @else if $location == 'bottom' {
6775
$bottomBubblesImages: list.append($bottomBubblesImages, map.get($bubbleTypes, $type), comma);
68-
$bottomBubblesSizes: list.append($bottomBubblesSizes, $size, comma);
76+
$bottomBubblesSizes: list.append($bottomBubblesSizes, ($size $size), comma);
6977
$bottomBubblesPos0s: list.append($bottomBubblesPos0s, $pos0, comma);
7078
$bottomBubblesPos50s: list.append($bottomBubblesPos50s, $pos50, comma);
7179
$bottomBubblesPos100s: list.append($bottomBubblesPos100s, $pos100, comma);
@@ -74,7 +82,9 @@ $bottomBubblesPos100s: ();
7482

7583
.sf-bubble-button {
7684
position: relative;
77-
transition: transform linear 0.02s;
85+
86+
// Transition the scale down effect of button press
87+
transition: transform linear 50ms;
7888

7989
&:active {
8090
transform: scale(0.95);
@@ -104,7 +114,6 @@ $bottomBubblesPos100s: ();
104114
padding-top: 30%; // Percentage of width of containing element
105115

106116
z-index: -1;
107-
transition: all ease-in-out 0.5s;
108117
background-repeat: no-repeat;
109118
}
110119

@@ -125,11 +134,11 @@ $bottomBubblesPos100s: ();
125134
&.sf-bubble-animate {
126135
&:before {
127136
display: block;
128-
animation: emit-bubbles-top ease-in-out $animationDuration forwards;
137+
animation: emit-bubbles-top ease-out $animationDuration forwards;
129138
}
130139
&:after {
131140
display: block;
132-
animation: emit-bubbles-bottom ease-in-out $animationDuration forwards;
141+
animation: emit-bubbles-bottom ease-out $animationDuration forwards;
133142
}
134143
}
135144
}

0 commit comments

Comments
 (0)