Skip to content

Commit

Permalink
Add favicon util
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwofford committed Feb 4, 2022
1 parent daea29e commit a1fcdc2
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 2 deletions.
Binary file added assets/favicon/blue-alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/favicon/blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/favicon/err.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/favicon/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/favicon/pink-alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/favicon/pink.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/favicon/red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/favicon/white-alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/favicon/white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/favicon/yellow-alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
10 changes: 9 additions & 1 deletion dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { createEval } from "./evalGameScript.js";
import uiSounds from "./assets/ui-sounds.js";
import notification from "./utils/notification.js";
import validate from "./utils/validate.js";
import favicon from "./utils/favicon.js";

const STATE = {
codemirror: undefined,
Expand Down Expand Up @@ -131,9 +132,16 @@ const ACTIONS = {
} // Best(?) combination of checking if certain error properties exist
dispatch("RENDER");
},
SOUND(arg, state) {
SOUND(arg = null, state) {
uiSounds[arg]();
},
FAVICON(arg = null, state) {
if (typeof arg === 'string') {
favicon(arg)
} else {
favicon()
}
},
REPORT_BUG: async (args, state) => {
state.bugReportStatus = "loading";
notification({
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>gamelab</title>
<link rel="icon" type="image/png" href="./assets/favicon.png">
<link rel="icon" type="image/png" href="./assets/favicon/loading.gif">
<link rel="stylesheet" href="./styles/editor.css"></link>
<link rel="stylesheet" href="./styles/cursors.css"></link>
<!-- <link rel="stylesheet" href="./styles/tooltip.css"></link> -->
Expand Down
1 change: 1 addition & 0 deletions init.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,5 @@ export async function init(state) {

dispatch("LOAD_CARTRIDGE", { saved });
dispatch("SOUND", "bootup");
dispatch("FAVICON")
}
14 changes: 14 additions & 0 deletions utils/favicon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// ex.
// `favicon()` to set default favicon
// `favicon('yellow.png')` to set to a yellow variant of the favicon
// `favicon('loading.gif)` to set to a loading icon
export default function favicon(type = 'white.png') {
console.log('setting favicon', type)
const icon = document.querySelector("link[rel~='icon']");
if (!icon) {
icon = document.createElement('link');
icon.rel = 'icon';
document.head.appendChild(link);
}
icon.href = `./assets/favicon/${type}`
}

0 comments on commit a1fcdc2

Please sign in to comment.