diff --git a/ext/ext.unsigned.zip b/ext/ext.unsigned.zip new file mode 100644 index 0000000..c55022e Binary files /dev/null and b/ext/ext.unsigned.zip differ diff --git a/ext/icons/icon.png b/ext/icons/icon.png new file mode 100644 index 0000000..063cfa8 Binary files /dev/null and b/ext/icons/icon.png differ diff --git a/ext/manifest.json b/ext/manifest.json new file mode 100644 index 0000000..308531a --- /dev/null +++ b/ext/manifest.json @@ -0,0 +1,20 @@ +{ + "manifest_version": 3, + "name": "halfPage", + "description": "Use halfPage as your Startpage.", + "version": "0.0.1", + "browser_specific_settings": { + "gecko": { + "id": "halfPage@new-tab.ipv4.army" + } + }, + "optional_permissions": [ + "geolocation" + ], + "icons": { + "64": "icons/icon.png" + }, + "chrome_url_overrides": { + "newtab": "dist/index.html" + } +} \ No newline at end of file diff --git a/index.html b/index.html index 5ebbd88..5f7b81a 100644 --- a/index.html +++ b/index.html @@ -1,10 +1,10 @@ - + - + New Tab diff --git a/src/components/app.tsx b/src/components/app.tsx index 56caeda..9274b62 100644 --- a/src/components/app.tsx +++ b/src/components/app.tsx @@ -1,5 +1,6 @@ import Navbar from './navbar'; import Container from './container'; +import Sidebar from './sidebar'; import './app.css'; @@ -8,6 +9,7 @@ export default () => { <> + ) } diff --git a/src/components/container/index.tsx b/src/components/container/index.tsx index b92c381..f6455df 100644 --- a/src/components/container/index.tsx +++ b/src/components/container/index.tsx @@ -2,11 +2,11 @@ export default () => { return ( <>
-
Hello, Seth.
+
Hello, {localStorage.getItem("name")}.


-
- + +
diff --git a/src/components/navbar/index.tsx b/src/components/navbar/index.tsx index 765a6c3..63e1b5a 100644 --- a/src/components/navbar/index.tsx +++ b/src/components/navbar/index.tsx @@ -1,72 +1,22 @@ import { useState } from 'preact/hooks'; import { ChevronLeft, ChevronRight } from 'lucide-preact'; -import desc from "./desc.json"; - -const favicon = document.getElementById("favicon") as HTMLLinkElement; - -const fetchWeather = async (lat: number, long: number) => { - const req = await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${long}¤t=temperature_2m,is_day,weather_code&timezone=${Intl.DateTimeFormat().resolvedOptions().timeZone}`) - const res = await req.json(); - - return res as { - current: { - temperature_2m: number, - is_day: number; - weather_code: number; - } - } -} - export default () => { - const [weather, setWeather] = useState("Loading..."); - const [imgSrc, setSrc] = useState("favicon.svg"); const [wttrDesc, setWttrDesc] = useState("Loading..."); - const getWeather = async (coords: GeolocationCoordinates) => { - const weather = await fetchWeather(coords.latitude, coords.longitude); - - const weatherCode = weather.current.weather_code; - const isDay = weather.current.is_day === 1; - const dayOrNight = isDay ? "Day" : "Night"; - const weatherDesc = desc[weatherCode.toString() as keyof typeof desc][dayOrNight.toLowerCase() as "day" | "night"]; - - setWeather(`${weather.current.temperature_2m}°C`); - setSrc(weatherDesc.image); - favicon.href = weatherDesc.image; - setWttrDesc(`${weatherDesc.description} & ${dayOrNight}`); - } - - const getAproximateLocation = async () => { - const req = await fetch("https://cf.ipv4-army.workers.dev/") - const res = await req.json(); - return await getWeather(res); - } - - if ("geolocation" in navigator) { - navigator.geolocation.getCurrentPosition((position) => { - const coords = position.coords; - getWeather(coords); - }, getAproximateLocation, { - enableHighAccuracy: true, - maximumAge: 30 * 60 * 1000, // 30 minutes - timeout: 5000 - }); - } else { - getAproximateLocation(); - } + fetch(`https://wttr.in/${localStorage.getItem("location") || ""}?format=%t%20with%20%C%c&m`) + .then(res => res.text()) + .then(desc => { + setWttrDesc(desc.trim()); + }) return ( <>