From 6123956f08d3e017040627c9219328576df3eb21 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 8 Aug 2023 11:18:54 +0200 Subject: [PATCH] feat: inline critical css --- islands/KMenu.tsx | 3 ++- islands/Search.tsx | 8 ++------ routes/_app.tsx | 35 +++++++++++++++++++++++++++++++++++ routes/series/index.tsx | 2 +- static/global.css | 30 ------------------------------ 5 files changed, 40 insertions(+), 38 deletions(-) diff --git a/islands/KMenu.tsx b/islands/KMenu.tsx index 209e4ec..32844db 100644 --- a/islands/KMenu.tsx +++ b/islands/KMenu.tsx @@ -4,6 +4,7 @@ import { useEventListener } from "@lib/hooks/useEventListener.ts"; import { menus } from "@islands/KMenu/commands.ts"; import { MenuEntry } from "@islands/KMenu/types.ts"; import * as icons from "@components/icons.tsx"; +import { IS_BROWSER } from "$fresh/runtime.ts"; const KMenuEntry = ( { entry, activeIndex, index }: { entry: MenuEntry; @@ -150,7 +151,7 @@ export const KMenu = ( } else { input.current?.blur(); } - }, typeof document !== "undefined" ? document?.body : undefined); + }, IS_BROWSER ? document?.body : undefined); return (
{ useEventListener("keydown", (e: KeyboardEvent) => { @@ -20,7 +16,7 @@ export const RedirectSearchHandler = () => { ) { window.location.href += "?q="; } - }, typeof document !== "undefined" ? document?.body : undefined); + }, IS_BROWSER ? document?.body : undefined); return <>; }; diff --git a/routes/_app.tsx b/routes/_app.tsx index 8417772..c77ae4d 100644 --- a/routes/_app.tsx +++ b/routes/_app.tsx @@ -7,6 +7,41 @@ export default function App({ Component }: AppProps) { + diff --git a/routes/series/index.tsx b/routes/series/index.tsx index 1882cfa..1b958c1 100644 --- a/routes/series/index.tsx +++ b/routes/series/index.tsx @@ -28,7 +28,7 @@ export default function Greet(props: PageProps) { Back -

🍿 Movies

+

🎥 Series

{props.data?.map((doc) => { diff --git a/static/global.css b/static/global.css index 31d124d..62c836f 100644 --- a/static/global.css +++ b/static/global.css @@ -1,33 +1,3 @@ -/* work-sans-regular - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'Work Sans'; - font-style: normal; - font-weight: 400; - src: url('/fonts/work-sans-v18-latin-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} - -/* work-sans-700 - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'Work Sans'; - font-style: normal; - font-weight: 700; - src: url('/fonts/work-sans-v18-latin-700.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} - -body { - background: #141218; - padding: 0px 20px; -} -pre { - font-family:Work Sans; -} - -a { - color: cadetblue; - font-family: Work Sans; -} .custom-grid { grid-template-columns: repeat(auto-fit, minmax(37vw, 1fr)) ;