add browser tab indicator for coding and update favicon images
This commit is contained in:
parent
87cf6f4cc2
commit
cdbb78ea55
@ -2,11 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link
|
<link rel="icon" type="image/png" href="/favicon/main.png" />
|
||||||
rel="icon"
|
|
||||||
type="image/svg+xml"
|
|
||||||
href="https://picoapps.xyz/favicon.png"
|
|
||||||
/>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|
||||||
<!-- Google Fonts -->
|
<!-- Google Fonts -->
|
||||||
|
|||||||
BIN
frontend/public/favicon/coding.png
Normal file
BIN
frontend/public/favicon/coding.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
BIN
frontend/public/favicon/main.png
Normal file
BIN
frontend/public/favicon/main.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@ -38,6 +38,7 @@ import { Stack } from "./lib/stacks";
|
|||||||
import { CodeGenerationModel } from "./lib/models";
|
import { CodeGenerationModel } from "./lib/models";
|
||||||
import ModelSettingsSection from "./components/ModelSettingsSection";
|
import ModelSettingsSection from "./components/ModelSettingsSection";
|
||||||
import { extractHtml } from "./components/preview/extractHtml";
|
import { extractHtml } from "./components/preview/extractHtml";
|
||||||
|
import useBrowserTabIndicator from "./hooks/useBrowserTabIndicator";
|
||||||
|
|
||||||
const IS_OPENAI_DOWN = false;
|
const IS_OPENAI_DOWN = false;
|
||||||
|
|
||||||
@ -83,6 +84,9 @@ function App() {
|
|||||||
|
|
||||||
const wsRef = useRef<WebSocket>(null);
|
const wsRef = useRef<WebSocket>(null);
|
||||||
|
|
||||||
|
// Indicate coding state using the browser tab's favicon and title
|
||||||
|
useBrowserTabIndicator(appState === AppState.CODING);
|
||||||
|
|
||||||
// When the user already has the settings in local storage, newly added keys
|
// When the user already has the settings in local storage, newly added keys
|
||||||
// do not get added to the settings so if it's falsy, we populate it with the default
|
// do not get added to the settings so if it's falsy, we populate it with the default
|
||||||
// value
|
// value
|
||||||
|
|||||||
29
frontend/src/hooks/useBrowserTabIndicator.ts
Normal file
29
frontend/src/hooks/useBrowserTabIndicator.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
|
const CODING_SETTINGS = {
|
||||||
|
title: "Coding...",
|
||||||
|
favicon: "/favicon/coding.png",
|
||||||
|
};
|
||||||
|
const DEFAULT_SETTINGS = {
|
||||||
|
title: "Screenshot to Code",
|
||||||
|
favicon: "/favicon/main.png",
|
||||||
|
};
|
||||||
|
|
||||||
|
const useBrowserTabIndicator = (isCoding: boolean) => {
|
||||||
|
useEffect(() => {
|
||||||
|
const settings = isCoding ? CODING_SETTINGS : DEFAULT_SETTINGS;
|
||||||
|
|
||||||
|
// Set favicon
|
||||||
|
const faviconEl = document.querySelector(
|
||||||
|
"link[rel='icon']"
|
||||||
|
) as HTMLLinkElement | null;
|
||||||
|
if (faviconEl) {
|
||||||
|
faviconEl.href = settings.favicon;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set title
|
||||||
|
document.title = settings.title;
|
||||||
|
}, [isCoding]);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useBrowserTabIndicator;
|
||||||
Loading…
Reference in New Issue
Block a user