This commit is contained in:
parent
582af2ba98
commit
e8e924b595
14 changed files with 406 additions and 292 deletions
|
@ -1,15 +1,15 @@
|
|||
import Navbar from './navbar';
|
||||
import Container from './container';
|
||||
import Sidebar from './sidebar';
|
||||
import Container from "./container";
|
||||
import Navbar from "./navbar";
|
||||
import Sidebar from "./sidebar";
|
||||
|
||||
import './app.css';
|
||||
import "./app.css";
|
||||
|
||||
export default () => {
|
||||
return (
|
||||
<>
|
||||
<Navbar />
|
||||
<Container />
|
||||
<Sidebar />
|
||||
</>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Navbar />
|
||||
<Container />
|
||||
<Sidebar />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
export default () => {
|
||||
return (
|
||||
<>
|
||||
<div class="container bg-body-tertiary shadow text-center position-absolute top-50 start-50 translate-middle mx-auto py-4">
|
||||
<h6 class="display-4">Hello, {localStorage.getItem("name")}.</h6>
|
||||
<br />
|
||||
<br />
|
||||
<form action={localStorage.getItem("searchEngine") || ""} method="get">
|
||||
<input class="form-control me-2" type="search" placeholder={`Search with ${localStorage.getItem("searchEngineName")}`} aria-label="Search with Google" name="q" />
|
||||
</form>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<div class="container bg-body-tertiary shadow text-center position-absolute top-50 start-50 translate-middle mx-auto py-4">
|
||||
<h6 class="display-4">Hello, {localStorage.getItem("name")}.</h6>
|
||||
<br />
|
||||
<br />
|
||||
<form action={localStorage.getItem("searchEngine") || ""} method="get">
|
||||
<input
|
||||
class="form-control me-2"
|
||||
type="search"
|
||||
placeholder={`Search with ${localStorage.getItem("searchEngineName")}`}
|
||||
aria-label="Search with Google"
|
||||
name="q"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -279,4 +279,4 @@
|
|||
"image": "https://wsrv.nl/?l=9w=24&url=https://openweathermap.org/img/wn/11n@2x.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,43 @@
|
|||
import { useState } from 'preact/hooks';
|
||||
import { ChevronLeft, ChevronRight } from 'lucide-preact';
|
||||
import { ChevronLeft, ChevronRight } from "lucide-preact";
|
||||
import { useState } from "preact/hooks";
|
||||
|
||||
export default () => {
|
||||
const [wttrDesc, setWttrDesc] = useState<string>("Loading...");
|
||||
const [wttrDesc, setWttrDesc] = useState<string>("Loading...");
|
||||
|
||||
fetch(`https://wttr.in/${localStorage.getItem("location") || ""}?format=%t%20with%20%C%c&m`)
|
||||
.then(res => res.text())
|
||||
.then(desc => {
|
||||
setWttrDesc(desc.trim());
|
||||
})
|
||||
fetch(
|
||||
`https://wttr.in/${localStorage.getItem("location") || ""}?format=%t%20with%20%C%c&m`,
|
||||
)
|
||||
.then((res) => res.text())
|
||||
.then((desc) => {
|
||||
setWttrDesc(desc.trim());
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<nav class="navbar shadow fixed-top" style="background-color: var(--bs-content-bg); border-bottom: var(--bs-border-width) solid var(--bs-content-border-color);">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-brand">
|
||||
{wttrDesc}
|
||||
</div>
|
||||
<div class="d-flex hstack gap-2">
|
||||
<button type="button" class="btn btn-outline-light btn-sm" onClick={history.back}><ChevronLeft size={20} /></button>
|
||||
<button type="button" class="btn btn-outline-light btn-sm" onClick={history.forward}><ChevronRight size={20} /></button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<nav
|
||||
class="navbar shadow fixed-top"
|
||||
style="background-color: var(--bs-content-bg); border-bottom: var(--bs-border-width) solid var(--bs-content-border-color);"
|
||||
>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-brand">{wttrDesc}</div>
|
||||
<div class="d-flex hstack gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline-light btn-sm"
|
||||
onClick={history.back}
|
||||
>
|
||||
<ChevronLeft size={20} />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline-light btn-sm"
|
||||
onClick={history.forward}
|
||||
>
|
||||
<ChevronRight size={20} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,109 +1,204 @@
|
|||
const dataset = document.documentElement.dataset;
|
||||
|
||||
export default () => {
|
||||
return (
|
||||
return (
|
||||
<nav
|
||||
class="sidebar offcanvas-start offcanvas-md"
|
||||
style={
|
||||
localStorage.getItem("sidebar") === "false" ? "display: none;" : ""
|
||||
}
|
||||
>
|
||||
<div class="offcanvas-header border-bottom border-secondary border-opacity-25">
|
||||
<span class="sidebar-brand">.</span>
|
||||
|
||||
<nav class="sidebar offcanvas-start offcanvas-md" style={(localStorage.getItem("sidebar") === "false" ? "display: none;" : "")}>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close d-md-none"
|
||||
data-bs-dismiss="offcanvas"
|
||||
data-bs-target="#sidebar-example"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="offcanvas-header border-bottom border-secondary border-opacity-25">
|
||||
<div class="offcanvas-body">
|
||||
<h6>Name</h6>
|
||||
<form
|
||||
class="d-flex"
|
||||
id="name"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
const form = document.forms.namedItem("name");
|
||||
if (form) {
|
||||
localStorage.setItem("name", form.userName.value);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<input
|
||||
name="userName"
|
||||
class="form-control me-2"
|
||||
placeholder="Set Name"
|
||||
/>
|
||||
|
||||
<span class="sidebar-brand">
|
||||
.
|
||||
</span>
|
||||
<button class="btn btn-primary" type="submit">
|
||||
Save
|
||||
</button>
|
||||
</form>
|
||||
<hr class="sidebar-divider" />
|
||||
<h6>Search Engine</h6>
|
||||
<form
|
||||
id="searchEngine"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
const form = document.forms.namedItem("searchEngine");
|
||||
if (form) {
|
||||
localStorage.setItem("searchEngine", form.engine.value);
|
||||
localStorage.setItem("searchEngineName", form.engineName.value);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<input
|
||||
name="engine"
|
||||
class="form-control me-2"
|
||||
placeholder="e.g. https://google.com/search"
|
||||
/>
|
||||
<br />
|
||||
<input
|
||||
name="engineName"
|
||||
class="form-control me-2"
|
||||
placeholder="e.g. Google"
|
||||
/>
|
||||
<br />
|
||||
<button class="btn btn-primary" type="submit">
|
||||
Save
|
||||
</button>
|
||||
</form>
|
||||
<hr class="sidebar-divider" />
|
||||
<h6>Weather Location</h6>
|
||||
<form
|
||||
class="d-flex"
|
||||
id="weatherLocation"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
const form = document.forms.namedItem("weatherLocation");
|
||||
if (form) {
|
||||
localStorage.setItem("location", form.location.value);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<input
|
||||
name="location"
|
||||
class="form-control me-2"
|
||||
placeholder="Leave blank for current location"
|
||||
/>
|
||||
|
||||
<button type="button" class="btn-close d-md-none" data-bs-dismiss="offcanvas" data-bs-target="#sidebar-example" />
|
||||
<button class="btn btn-primary" type="submit">
|
||||
Save
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<hr class="sidebar-divider" />
|
||||
<h6>Color Scheme</h6>
|
||||
<ul class="nav nav-pills nav-fill">
|
||||
<li class="nav-item">
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
type={"button"}
|
||||
onClick={() => {
|
||||
localStorage.setItem("colorScheme", "auto");
|
||||
location.reload();
|
||||
}}
|
||||
>
|
||||
Auto
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
type={"button"}
|
||||
onClick={() => {
|
||||
localStorage.setItem("colorScheme", "light");
|
||||
dataset.bsTheme = "light";
|
||||
}}
|
||||
>
|
||||
Light
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
type={"button"}
|
||||
onClick={() => {
|
||||
localStorage.setItem("colorScheme", "dark");
|
||||
dataset.bsTheme = "dark";
|
||||
}}
|
||||
>
|
||||
Dark
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="offcanvas-body">
|
||||
<h6>Name</h6>
|
||||
<form class="d-flex" id="name" onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
const form = document.forms.namedItem("name");
|
||||
if (form) {
|
||||
localStorage.setItem("name", form.userName.value);
|
||||
}
|
||||
}}>
|
||||
<hr class="sidebar-divider" />
|
||||
<h6>Theme</h6>
|
||||
<ul class="nav nav-pills nav-fill">
|
||||
<li class="nav-item">
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
type={"button"}
|
||||
onClick={() => {
|
||||
localStorage.setItem("theme", "default");
|
||||
dataset.bsCore = "default";
|
||||
}}
|
||||
>
|
||||
Default
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
type={"button"}
|
||||
onClick={() => {
|
||||
localStorage.setItem("theme", "modern");
|
||||
dataset.bsCore = "modern";
|
||||
}}
|
||||
>
|
||||
Modern
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
type={"button"}
|
||||
onClick={() => {
|
||||
localStorage.setItem("theme", "elegant");
|
||||
dataset.bsCore = "elegant";
|
||||
}}
|
||||
>
|
||||
Elegant
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<hr class="sidebar-divider" />
|
||||
|
||||
<input name="userName" class="form-control me-2" placeholder="Set Name" />
|
||||
<button
|
||||
class="btn btn-secondary"
|
||||
type={"button"}
|
||||
onClick={() => {
|
||||
localStorage.setItem("sidebar", "false");
|
||||
location.reload();
|
||||
}}
|
||||
>
|
||||
Save & Close
|
||||
</button>
|
||||
|
||||
<button class="btn btn-primary" type="submit">Save</button>
|
||||
|
||||
</form>
|
||||
<hr class="sidebar-divider" />
|
||||
<h6>Search Engine</h6>
|
||||
<form id="searchEngine" onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
const form = document.forms.namedItem("searchEngine");
|
||||
if (form) {
|
||||
localStorage.setItem("searchEngine", form.engine.value);
|
||||
localStorage.setItem("searchEngineName", form.engineName.value);
|
||||
}
|
||||
}}>
|
||||
|
||||
<input name="engine" class="form-control me-2" placeholder="e.g. https://google.com/search" />
|
||||
<br />
|
||||
<input name="engineName" class="form-control me-2" placeholder="e.g. Google" />
|
||||
<br />
|
||||
<button class="btn btn-primary" type="submit">Save</button>
|
||||
|
||||
</form>
|
||||
<hr class="sidebar-divider" />
|
||||
<h6>Weather Location</h6>
|
||||
<form class="d-flex" id="weatherLocation" onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
const form = document.forms.namedItem("weatherLocation");
|
||||
if (form) {
|
||||
localStorage.setItem("location", form.location.value);
|
||||
}
|
||||
}}>
|
||||
|
||||
<input name="location" class="form-control me-2" placeholder="Leave blank for current location" />
|
||||
|
||||
<button class="btn btn-primary" type="submit">Save</button>
|
||||
|
||||
</form>
|
||||
|
||||
<hr class="sidebar-divider" />
|
||||
<h6>Color Scheme</h6>
|
||||
<ul class="nav nav-pills nav-fill">
|
||||
<li class="nav-item">
|
||||
<button class="btn btn-primary" type={"button"} onClick={() => { localStorage.setItem("colorScheme", "auto"); location.reload() }}>Auto</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button class="btn btn-primary" type={"button"} onClick={() => { localStorage.setItem("colorScheme", "light"); dataset.bsTheme = "light" }}>Light</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button class="btn btn-primary" type={"button"} onClick={() => { localStorage.setItem("colorScheme", "dark"); dataset.bsTheme = "dark" }}>Dark</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr class="sidebar-divider" />
|
||||
<h6>Theme</h6>
|
||||
<ul class="nav nav-pills nav-fill">
|
||||
<li class="nav-item">
|
||||
<button class="btn btn-primary" type={"button"} onClick={() => { localStorage.setItem("theme", "default"); dataset.bsCore = "default" }}>Default</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button class="btn btn-primary" type={"button"} onClick={() => { localStorage.setItem("theme", "modern"); dataset.bsCore = "modern" }}>Modern</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button class="btn btn-primary" type={"button"} onClick={() => { localStorage.setItem("theme", "elegant"); dataset.bsCore = "elegant" }}>Elegant</button>
|
||||
</li>
|
||||
</ul>
|
||||
<hr class="sidebar-divider" />
|
||||
|
||||
<button class="btn btn-secondary" type={"button"} onClick={() => { localStorage.setItem("sidebar", "false"); location.reload() }}>Save & Close</button>
|
||||
|
||||
<hr class="sidebar-divider" />
|
||||
<h6>About</h6>
|
||||
<p>halfPage is a minimalistic startpage, built on only open-source software.</p>
|
||||
<a href="https://www.gethalfmoon.com/wttr">halfmoon</a>
|
||||
<a href="https://github.com/chubin/wttr.in">wttr.in</a>
|
||||
<a href="https://git.creations.works/seth/halfPage">Source</a>
|
||||
|
||||
</div>
|
||||
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
<hr class="sidebar-divider" />
|
||||
<h6>About</h6>
|
||||
<p>
|
||||
halfPage is a minimalistic startpage, built on only open-source
|
||||
software.
|
||||
</p>
|
||||
<a href="https://www.gethalfmoon.com/wttr">halfmoon</a>
|
||||
<a href="https://github.com/chubin/wttr.in">wttr.in</a>
|
||||
<a href="https://git.creations.works/seth/halfPage">Source</a>
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
* {
|
||||
border-color: transparent !important;
|
||||
}
|
||||
border-color: transparent !important;
|
||||
}
|
||||
|
|
38
src/main.tsx
38
src/main.tsx
|
@ -1,17 +1,24 @@
|
|||
import { render } from 'preact'
|
||||
import './index.css'
|
||||
import 'halfmoon/css/halfmoon.min.css';
|
||||
import 'halfmoon/css/cores/halfmoon.modern.css';
|
||||
import 'halfmoon/css/cores/halfmoon.elegant.css';
|
||||
import App from './components/app.tsx'
|
||||
import { render } from "preact";
|
||||
import "./index.css";
|
||||
import "halfmoon/css/halfmoon.min.css";
|
||||
import "halfmoon/css/cores/halfmoon.modern.css";
|
||||
import "halfmoon/css/cores/halfmoon.elegant.css";
|
||||
import App from "./components/app.tsx";
|
||||
|
||||
const dataset = document.documentElement.dataset;
|
||||
|
||||
const colorScheme = localStorage.getItem("colorScheme") || (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") || "auto";
|
||||
const colorScheme =
|
||||
localStorage.getItem("colorScheme") ||
|
||||
(window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
? "dark"
|
||||
: "light") ||
|
||||
"auto";
|
||||
if (colorScheme === "auto") {
|
||||
dataset.bsTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
||||
dataset.bsTheme = window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
? "dark"
|
||||
: "light";
|
||||
} else {
|
||||
dataset.bsTheme = colorScheme;
|
||||
dataset.bsTheme = colorScheme;
|
||||
}
|
||||
|
||||
dataset.bsCore = localStorage.getItem("theme") || "default";
|
||||
|
@ -19,9 +26,12 @@ dataset.bsCore = localStorage.getItem("theme") || "default";
|
|||
const favicon = document.getElementById("favicon") as HTMLLinkElement;
|
||||
|
||||
fetch(`https://wttr.in/${localStorage.getItem("location") || ""}?format=%c`)
|
||||
.then(res => res.text())
|
||||
.then(emoji => {
|
||||
favicon.href = `data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>${emoji.trim()}</text></svg>`
|
||||
})
|
||||
.then((res) => res.text())
|
||||
.then((emoji) => {
|
||||
favicon.href = `data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>${emoji.trim()}</text></svg>`;
|
||||
});
|
||||
|
||||
render(<App />, document.getElementById('app') as HTMLElement || document.body)
|
||||
render(
|
||||
<App />,
|
||||
(document.getElementById("app") as HTMLElement) || document.body,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue