Skip to content

Commit 4d2c993

Browse files
committed
Improve banner CSS
* On standalone pages the banner will sit in page and be hidden. * On package page (and landing page) the banner will float over content with position absolute, as these pages have sufficient margin to allow for this. In both cases content will not jump when the banner is dismissed, or when the banner is loaded.
1 parent 6630cae commit 4d2c993

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

pkg/web_app/lib/src/widget/widget.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:web/web.dart';
1010

1111
import '../web_util.dart';
1212
import 'completion/widget.dart' deferred as completion;
13-
import 'switch/widget.dart' deferred as switch_;
13+
import 'switch/widget.dart' as switch_;
1414

1515
/// Function to create an instance of the widget given an element and options.
1616
///
@@ -32,7 +32,7 @@ typedef _WidgetLoaderFn = FutureOr<_WidgetFn> Function();
3232
/// Map from widget name to widget loader
3333
final _widgets = <String, _WidgetLoaderFn>{
3434
'completion': () => completion.loadLibrary().then((_) => completion.create),
35-
'switch': () => switch_.loadLibrary().then((_) => switch_.create),
35+
'switch': () => switch_.create,
3636
};
3737

3838
Future<_WidgetFn> _noSuchWidget() async =>

pkg/web_css/lib/src/_base.scss

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -393,30 +393,32 @@ pre {
393393
text-align: center;
394394

395395
.dismisser {
396-
float: right;
396+
position: absolute;
397+
display: inline-block;
398+
right: 0px;
397399
padding: 5px 15px;
398400
margin-top: -5px;
399401
cursor: pointer;
400402
user-select: none;
401403
}
402404

403405
&.dismissed {
404-
visibility: hidden;
406+
display: none;
405407
}
406408

407-
z-index: 0;
408-
animation-duration: 200ms;
409-
animation-name: slide-down;
410-
animation-timing-function: ease;
409+
z-index: 1000;
410+
411+
position: absolute;
412+
left: 0px;
413+
right: 0px;
411414
}
412415

413-
@keyframes slide-down {
414-
from {
415-
translate: 0 -100%;
416-
}
416+
.page-standalone .announcement-banner {
417+
position: initial;
417418

418-
to {
419-
translate: 0 0;
419+
&.dismissed {
420+
display: block;
421+
visibility: hidden;
420422
}
421423
}
422424

0 commit comments

Comments
 (0)