Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dartpad_ui] Add splash screen #3089

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions pkgs/dartpad_ui/web/flutter_bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{flutter_js}}
{{flutter_build_config}}

const serviceWorkerSettings = {
serviceWorkerVersion: {{flutter_service_worker_version}}
};

_flutter.loader.load({
serviceWorkerSettings,
});

const splash = document.querySelector('#splash');

_initSplashTheme();

window.addEventListener('flutter-first-frame', () => {
splash.classList.add('done');

setTimeout(() => splash.remove(), 500);
});

async function _initSplashTheme() {
const queryParams = new URLSearchParams(window.location.search);
const queryTheme = queryParams.get('theme');
const theme = ['light', 'dark'].includes(queryTheme) ? queryTheme : 'dark';

splash.classList.add(theme);
}
1 change: 1 addition & 0 deletions pkgs/dartpad_ui/web/icons/Icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 12 additions & 58 deletions pkgs/dartpad_ui/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,83 +8,37 @@
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="An online Dart editor with support for console and Flutter apps.">

<!-- iOS meta tags & icons -->
<meta name="viewport" content="width=device-width, initial-scale=1">

<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="DartPad">
<link rel="apple-touch-icon" href="icons/Icon-192.png">

<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png" />

<link rel="preconnect" href="https://www.gstatic.com">

<title>DartPad</title>

<link rel="manifest" href="manifest.json">

<link href="https://fonts.googleapis.com/css2?family=Roboto&family=Roboto+Mono&display=swap" rel="stylesheet">
<link href="codemirror/codemirror.css" rel="stylesheet">
<link href="styles/cm-dartpad-dark.css" rel="stylesheet" media="screen">
<link href="styles/cm-dartpad-light.css" rel="stylesheet" media="screen">
<script src="codemirror/codemirror.js"></script>
<script src="ga.js" defer></script>

<style>
.CodeMirror {
height: 100%;
}

.squiggle-info {
border-bottom: 2px solid #7EA7D8;
}
.squiggle-warning {
border-bottom: 2px solid #d9d077;
}
.squiggle-error {
border-bottom: 2px solid #EF5350;
}
.squiggle-deprecation {
text-decoration: line-through;
text-decoration-thickness: 10%;
}
<link href="styles/index.css" rel="stylesheet">

.CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div {
position: absolute;
-moz-box-sizing: border-box;
box-sizing: border-box;
border-radius: 4px;
}

.CodeMirror-simplescroll-horizontal, .CodeMirror-simplescroll-vertical {
position: absolute;
z-index: 6;
}

.CodeMirror-simplescroll-horizontal {
bottom: 0;
left: 0;
height: 9px;
}

.CodeMirror-simplescroll-horizontal div {
bottom: 0;
height: 100%;
}

.CodeMirror-simplescroll-vertical {
right: 0;
top: 0;
width: 9px;
}
<link href="https://fonts.googleapis.com/css2?family=Roboto&family=Roboto+Mono&display=swap" rel="stylesheet">

.CodeMirror-simplescroll-vertical div {
right: 0;
width: 100%;
}
</style>
<script src="codemirror/codemirror.js" defer></script>
<script src="flutter_bootstrap.js" defer></script>
<script src="ga.js" defer></script>
</head>

<body>
<script>{{flutter_bootstrap_js}}</script>
<div id="splash">
<img src="icons/Icon.svg" alt="Loading indicator" />
</div>
</body>

</html>
112 changes: 112 additions & 0 deletions pkgs/dartpad_ui/web/styles/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
.CodeMirror {
height: 100%;
}

.squiggle-info {
border-bottom: 2px solid #7ea7d8;
}

.squiggle-warning {
border-bottom: 2px solid #d9d077;
}

.squiggle-error {
border-bottom: 2px solid #ef5350;
}

.squiggle-deprecation {
text-decoration: line-through;
text-decoration-thickness: 10%;
}

.CodeMirror-simplescroll-horizontal div,
.CodeMirror-simplescroll-vertical div {
position: absolute;
-moz-box-sizing: border-box;
box-sizing: border-box;
border-radius: 4px;
}

.CodeMirror-simplescroll-horizontal,
.CodeMirror-simplescroll-vertical {
position: absolute;
z-index: 6;
}

.CodeMirror-simplescroll-horizontal {
bottom: 0;
left: 0;
height: 9px;
}

.CodeMirror-simplescroll-horizontal div {
bottom: 0;
height: 100%;
}

.CodeMirror-simplescroll-vertical {
right: 0;
top: 0;
width: 9px;
}

.CodeMirror-simplescroll-vertical div {
right: 0;
width: 100%;
}

#splash {
position: fixed;
display: flex;
align-items: center;
justify-content: center;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 999;
transition: opacity 500ms;
}

#splash.light {
background-color: #f5f5f7;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this color is the color we'd settle into after we've started up in the light theme?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's right.

}

#splash.dark {
background-color: #1f2833;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this with the dark theme?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep.

}

#splash.done {
opacity: 0;
}

#splash img {
width: 28vmin;
animation: 1s ease-in-out 200ms infinite alternate breathe;
transition: opacity 500ms;
}

#splash.done img {
animation: 500ms ease-in-out 0s 1 forwards zoom;
opacity: 0;
}

@keyframes breathe {
from {
transform: scale(1);
}

to {
transform: scale(0.95);
}
}

@keyframes zoom {
from {
transform: scale(1);
}

to {
transform: scale(0.01);
}
}