diff --git a/src/components/details/details.module.css b/src/components/details/details.module.css index c4935f4..49fb003 100644 --- a/src/components/details/details.module.css +++ b/src/components/details/details.module.css @@ -1,6 +1,6 @@ .container { isolation: isolate; - display: block grid; + display: block grid; container-type: inline-size; } @@ -14,10 +14,13 @@ position: absolute; inset: 0; display: block; - background: linear-gradient(182.5deg, transparent 20%, var(--surface-2) 90%), - linear-gradient(transparent 50%, #0007 75%); + background: linear-gradient( + calc(atan(var(--ratio))), + var(--surface-2) 20em, + transparent 90% + ); } - + & > .background { position: absolute; inset: 0; @@ -28,4 +31,3 @@ z-index: 0; } } - diff --git a/src/components/details/details.tsx b/src/components/details/details.tsx index ee7fa04..4391ca7 100644 --- a/src/components/details/details.tsx +++ b/src/components/details/details.tsx @@ -1,19 +1,38 @@ -import { Component } from 'solid-js'; -import { Entry } from '~/features/content'; -import css from './details.module.css'; +import { Component, createSignal, onCleanup, onMount } from "solid-js"; +import { Entry } from "~/features/content"; +import css from "./details.module.css"; interface DetailsProps { - entry: Entry + entry: Entry; } export const Details: Component = (props) => { - return ( -
-
- + const [header, setHeader] = createSignal(); -

{props.entry.title}

-
-
- ); -}; \ No newline at end of file + onMount(() => { + const observer = new ResizeObserver(([entry]) => { + const _20em = 20 * 16; + const { inlineSize, blockSize } = entry.contentBoxSize[0]; + console.log(blockSize / inlineSize); + + (entry.target as HTMLElement).style.setProperty( + "--ratio", + String(_20em / inlineSize), + ); + }); + + observer.observe(header()!); + + onCleanup(() => observer.disconnect()); + }); + + return ( +
+
+ + +

{props.entry.title}

+
+
+ ); +}; diff --git a/src/features/content/apis/jellyfin.ts b/src/features/content/apis/jellyfin.ts index a0879ab..bffca42 100644 --- a/src/features/content/apis/jellyfin.ts +++ b/src/features/content/apis/jellyfin.ts @@ -24,7 +24,6 @@ const getBaseUrl = () => { return process.env.JELLYFIN_BASE_URL; }; - const getClient = () => { "use server"; @@ -34,11 +33,11 @@ const getClient = () => { Authorization: `MediaBrowser DeviceId="Streamarr", Token="${process.env.JELLYFIN_API_KEY}"`, "Content-Type": 'application/json; profile="CamelCase"', }, - }) + }); }; export const getCurrentUser = query(async () => { - "use server"; + "use server"; const { data, error, response } = await getClient().GET("/Users/Public", { params: {}, @@ -48,7 +47,7 @@ export const getCurrentUser = query(async () => { }, "jellyfin.getCurrentUser"); export const listUsers = query(async () => { - "use server"; + "use server"; const { data, error } = await getClient().GET("/Users", { params: {}, @@ -134,8 +133,8 @@ export const getRandomItem = query( async (userId: string): Promise => { "use server"; - return getRandomItems(userId, 1).then((items) => items?.at(0)); - }, + return getRandomItems(userId, 1).then((items) => items?.at(0)); + }, "jellyfin.listRandomItem", );