Skip to content

Commit c9f0726

Browse files
committed
fix: workaround for chrome bug with bottom app bar background
1 parent 9ccaff2 commit c9f0726

File tree

12 files changed

+75
-12
lines changed

12 files changed

+75
-12
lines changed

packages/bottom-app-bar/_mixins.scss

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ $acceleration-curve-timing-function: cubic-bezier(0.4, 0, 1, 1) !default;
3232
display: flex;
3333
flex-direction: row;
3434
justify-content: center;
35+
position: relative;
3536
padding: $section-padding-vertical $section-padding-horizontal;
3637
height: $section-height;
3738
box-sizing: border-box;
@@ -134,6 +135,61 @@ $acceleration-curve-timing-function: cubic-bezier(0.4, 0, 1, 1) !default;
134135
.smui-bottom-app-bar--fixed-adjust {
135136
padding-bottom: $section-height;
136137
}
138+
139+
/*
140+
"What the fuck is this nonsense?" (I hear you asking after reading the
141+
following styles.)
142+
143+
That's a great question.
144+
145+
In Google Chrome (the worst browser now that IE is dead), the background style
146+
on the bar sections doesn't get applied, so the bar is... just transparent.
147+
Super weird. BUUUT, if an animation runs inside the bar (like a ripple on
148+
button click), the background is rendered again.
149+
150+
"Well why not just run the animation once on component load?"
151+
152+
Also a great quesiton.
153+
154+
Even if the background is rendered, if it is scrolled *down* to below the
155+
fold, then scrolled back into view, it will be transparent again.
156+
157+
"Won't this have an impact on power consumption/battery life?"
158+
159+
Yes.
160+
*/
161+
@supports (-webkit-appearance: none) and (not (overflow: -webkit-marquee)) and
162+
(not (-moz-appearance: none)) {
163+
// ^ That supports query makes this only apply to Chromium based
164+
// browsers. (Chrome, Edge, Brave, etc.)
165+
.smui-bottom-app-bar.smui-bottom-app-bar--standard
166+
> .smui-bottom-app-bar__section::after,
167+
.smui-bottom-app-bar.smui-bottom-app-bar--fixed
168+
> .smui-bottom-app-bar__section::after {
169+
display: block;
170+
content: ' ';
171+
position: absolute;
172+
bottom: 0;
173+
right: 0;
174+
height: 10px;
175+
width: 10px;
176+
pointer-events: none;
177+
background-color: #000;
178+
opacity: 0;
179+
animation: 60s linear 0s infinite chrome-fix;
180+
}
181+
@keyframes chrome-fix {
182+
0% {
183+
bottom: 0;
184+
}
185+
50% {
186+
bottom: $section-height - 10px;
187+
}
188+
100% {
189+
bottom: 0px;
190+
}
191+
}
192+
}
137193
}
138194

139195
@mixin inset-color($color, $xpos, $query: feature-targeting.all()) {

packages/bottom-app-bar/src/AutoAdjust.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@
5151
5252
$: propStore = bottomAppBar && bottomAppBar.getPropStore();
5353
$: adjustClass = (() => {
54-
if (!propStore || $propStore.variant === 'static') {
54+
if (
55+
!propStore ||
56+
$propStore.variant === 'standard' ||
57+
$propStore.variant === 'static'
58+
) {
5559
return '';
5660
}
5761

packages/site/src/routes/demo/bottom-app-bar/+page.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<h5>Installation</h5>
99

10-
<pre class="demo-spaced">npm i -D @smui/bottom-app-bar</pre>
10+
<pre class="demo-spaced">npm i -D @smui-extra/bottom-app-bar</pre>
1111

1212
<h5>Demos</h5>
1313

@@ -20,7 +20,10 @@
2020

2121
<Demo
2222
component={Variants}
23-
files={['bottom-app-bar/iframe/fixed/+page.svelte']}
23+
files={[
24+
'bottom-app-bar/iframe/standard/+page.svelte',
25+
'bottom-app-bar/iframe/fixed/+page.svelte',
26+
]}
2427
>
2528
Page level bottom app bars
2629
<svelte:fragment slot="subtitle">

packages/site/src/routes/demo/bottom-app-bar/iframe/inset-fab-right/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
<style>
4040
/* Hide everything above this component. */
41-
:global(app),
41+
:global(#smui-app),
4242
:global(body),
4343
:global(html) {
4444
display: block !important;

packages/site/src/routes/demo/bottom-app-bar/iframe/inset-fab/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
<style>
4040
/* Hide everything above this component. */
41-
:global(app),
41+
:global(#smui-app),
4242
:global(body),
4343
:global(html) {
4444
display: block !important;

packages/site/src/routes/demo/bottom-app-bar/iframe/standard/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
<style>
3434
/* Hide everything above this component. */
35-
:global(app),
35+
:global(#smui-app),
3636
:global(body),
3737
:global(html) {
3838
display: block !important;

packages/site/src/routes/demo/top-app-bar/iframe/dense/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
<style>
4343
/* Hide everything above this component. */
44-
:global(app),
44+
:global(#smui-app),
4545
:global(body),
4646
:global(html) {
4747
display: block !important;

packages/site/src/routes/demo/top-app-bar/iframe/fixed/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
<style>
4343
/* Hide everything above this component. */
44-
:global(app),
44+
:global(#smui-app),
4545
:global(body),
4646
:global(html) {
4747
display: block !important;

packages/site/src/routes/demo/top-app-bar/iframe/prominent/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
<style>
4343
/* Hide everything above this component. */
44-
:global(app),
44+
:global(#smui-app),
4545
:global(body),
4646
:global(html) {
4747
display: block !important;

packages/site/src/routes/demo/top-app-bar/iframe/short-closed/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
<style>
3838
/* Hide everything above this component. */
39-
:global(app),
39+
:global(#smui-app),
4040
:global(body),
4141
:global(html) {
4242
display: block !important;

0 commit comments

Comments
 (0)