refactoring: poster

This commit is contained in:
ner committed 2024-10-30 21:14:15 +02:00
1 parent 053283564c
commit 32e7885791
6 files changed
+30 -54

No files matched your search

+22 -36
View File
@@ -1,50 +1,36 @@
import { DetailedHTMLProps, FC, HTMLAttributes } from 'react';
import { FC } from 'react';
import { cn } from '@/lib/utils';
import Handlers from './components/Handlers';
interface Props {
show?: Show;
show: Show;
onClick?: () => void;
className?: string;
rounded?: string;
lazy?: boolean;
containerProps?: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
}
const Poster: FC<Props> = ({ show, onClick, className, rounded, containerProps, lazy = true }) => {
if (!show) return null;
return (
<div
{...(containerProps || {})}
className={cn('card-aspect-ratio relative bg-black overflow-hidden rounded-lg text-lg', className, rounded)}
>
<div className='flex size-full'>
<picture>
<source srcSet={show.poster['1x']} media='(max-resolution: 191dpi)' />
<source srcSet={show.poster['1x']} media='(max-device-pixel-ratio: 1.99)' />
<source srcSet={show.poster['1.5x']} media='(min-resolution: 192dpi)' />
<source srcSet={show.poster['1.5x']} media='(min-device-pixel-ratio: 2)' />
<img
className={cn('size-full rounded-lg object-cover', rounded)}
loading={lazy ? 'lazy' : 'eager'}
src={show.poster['1x']}
alt={show.title}
/>
</picture>
</div>
<div
className={cn(
'absolute left-0 top-0 flex size-full flex-col justify-between rounded-md bg-vignette p-2 text-white',
rounded
)}
>
<Handlers show={show} onClick={onClick} />
</div>
const Poster: FC<Props> = ({ show, onClick, className, lazy = true }) => (
<div className={cn('card-aspect-ratio relative bg-black overflow-hidden rounded-lg text-lg', className)}>
<div className='flex size-full'>
<picture>
<source srcSet={show.poster['1x']} media='(max-resolution: 191dpi)' />
<source srcSet={show.poster['1x']} media='(max-device-pixel-ratio: 1.99)' />
<source srcSet={show.poster['1.5x']} media='(min-resolution: 192dpi)' />
<source srcSet={show.poster['1.5x']} media='(min-device-pixel-ratio: 2)' />
<img
className='size-full rounded-lg object-cover md:rounded-none md:rounded-l-lg'
loading={lazy ? 'lazy' : 'eager'}
src={show.poster['1x']}
alt={show.title}
/>
</picture>
</div>
);
};
<div className='absolute left-0 top-0 flex size-full flex-col justify-between rounded-md bg-vignette p-2 text-white md:rounded-none md:rounded-l-lg'>
<Handlers show={show} onClick={onClick} />
</div>
</div>
);
export default Poster;
+1 -1
View File
@@ -35,7 +35,7 @@ const Preview: FC<Props> = ({ show: baseShow, className, onClose, poster }) => {
className
)}
>
{poster || <Poster className='mx-auto' rounded='md:rounded-none md:rounded-l-xl' show={show} />}
{poster || <Poster className='mx-auto md:rounded-none md:rounded-l-xl' show={show} />}
<div className={cn('flex grow flex-col bg-background', { 'p-0 pt-1 md:p-2': isModal })}>
<span className='order-3 mb-4 text-3xl md:order-1 md:line-clamp-2'>{show.title}</span>
+2 -10
View File
@@ -1,20 +1,12 @@
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';
import accountQuery from '@/data/queries/account';
import { useSession } from '@/hooks/useSession';
const useAccount = () => {
const queryClient = useQueryClient();
const session = useSession();
const options = accountQuery({ session });
const query = useQuery(options);
if (session === null) {
queryClient.removeQueries({ queryKey: options.queryKey });
queryClient.resetQueries({ queryKey: options.queryKey });
}
const query = useQuery(accountQuery({ session }));
return session ? query.data : undefined;
};
+4 -3
View File
@@ -10,7 +10,6 @@
"dependencies": {
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.2.2",
"@tanstack/react-query": "^5.59.15",
@@ -40,7 +39,6 @@
"devDependencies": {
"@tanstack/react-query-devtools": "^5.59.15",
"@types/js-cookie": "^3.0.3",
"@types/node": "20.4.4",
"@types/parse-torrent": "^5.8.7",
"@types/react": "18.2.15",
"@types/react-dom": "18.2.7",
@@ -55,7 +53,6 @@
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"parse-torrent-title": "^1.4.0",
"postcss": "^8.4.27",
"prettier": "^3.3.3",
"tailwind-merge": "^1.14.0",
"tailwindcss": "^3.3.3",
@@ -5083,6 +5080,7 @@
"url": "https://github.com/sponsors/ai"
}
],
"license": "MIT",
"dependencies": {
"browserslist": "^4.23.3",
"caniuse-lite": "^1.0.30001646",
@@ -5774,6 +5772,7 @@
"version": "0.0.25",
"resolved": "https://registry.npmjs.org/critters/-/critters-0.0.25.tgz",
"integrity": "sha512-ROF/tjJyyRdM8/6W0VqoN5Ql05xAGnkf5b7f3sTEl1bI5jTQQf8O918RD/V9tEb9pRY/TKcvJekDbJtniHyPtQ==",
"deprecated": "Ownership of Critters has moved to the Nuxt team, who will be maintaining the project going forward. If you'd like to keep using Critters, please switch to the actively-maintained fork at https://github.com/danielroe/beasties",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
@@ -7274,6 +7273,7 @@
"resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz",
"integrity": "sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==",
"dev": true,
"license": "MIT",
"engines": {
"node": "*"
},
@@ -9296,6 +9296,7 @@
"resolved": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz",
"integrity": "sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
-3
View File
@@ -14,7 +14,6 @@
"dependencies": {
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.2.2",
"@tanstack/react-query": "^5.59.15",
@@ -44,7 +43,6 @@
"devDependencies": {
"@tanstack/react-query-devtools": "^5.59.15",
"@types/js-cookie": "^3.0.3",
"@types/node": "20.4.4",
"@types/parse-torrent": "^5.8.7",
"@types/react": "18.2.15",
"@types/react-dom": "18.2.7",
@@ -59,7 +57,6 @@
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"parse-torrent-title": "^1.4.0",
"postcss": "^8.4.27",
"prettier": "^3.3.3",
"tailwind-merge": "^1.14.0",
"tailwindcss": "^3.3.3",
+1 -1
View File
@@ -1 +1 @@
if(!self.define){let e,s={};const n=(n,i)=>(n=new URL(n+".js",i).href,s[n]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=s,document.head.appendChild(e)}else e=n,importScripts(n),s()})).then((()=>{let e=s[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e})));self.define=(i,c)=>{const a=e||("document"in self?document.currentScript.src:"")||location.href;if(s[a])return;let t={};const d=e=>n(e,a),r={module:{uri:a},exports:t,require:d};s[a]=Promise.all(i.map((e=>r[e]||d(e)))).then((e=>(c(...e),t)))}}define(["./workbox-4754cb34"],(function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"0a184c7adf7bae0bee283da258000613"},{url:"/_next/static/bRidjOJn2wzDcwzed1Uh9/_buildManifest.js",revision:"2ec694eb52ae4f523f265a46bae4d768"},{url:"/_next/static/bRidjOJn2wzDcwzed1Uh9/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/101-f9422c830edc0af7.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/152.b96372f7a5392cef.js",revision:"b96372f7a5392cef"},{url:"/_next/static/chunks/209-8d08998363c1872f.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/23-e0259c2123520d87.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/26.286553a5ff2812fc.js",revision:"286553a5ff2812fc"},{url:"/_next/static/chunks/276.c3c1130f2adade69.js",revision:"c3c1130f2adade69"},{url:"/_next/static/chunks/329-eb2b4d4edbe9c401.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/344.05938a041227e582.js",revision:"05938a041227e582"},{url:"/_next/static/chunks/383.78d47f7582340f53.js",revision:"78d47f7582340f53"},{url:"/_next/static/chunks/460.ac20021c7496f1d6.js",revision:"ac20021c7496f1d6"},{url:"/_next/static/chunks/497.48f1dfd129122432.js",revision:"48f1dfd129122432"},{url:"/_next/static/chunks/61.e269d4a699fba0b6.js",revision:"e269d4a699fba0b6"},{url:"/_next/static/chunks/621-fa4d2ff1cf645813.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/67-60fc8e33bb856f69.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/673.362c29137dd3e968.js",revision:"362c29137dd3e968"},{url:"/_next/static/chunks/674-7c487cb45ac8eb18.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/695.156d21364de6e419.js",revision:"156d21364de6e419"},{url:"/_next/static/chunks/755.5cd959eac5682527.js",revision:"5cd959eac5682527"},{url:"/_next/static/chunks/792.b51012549074b93f.js",revision:"b51012549074b93f"},{url:"/_next/static/chunks/810.6105e84414768b0d.js",revision:"6105e84414768b0d"},{url:"/_next/static/chunks/922.9ce4bf0553cfb724.js",revision:"9ce4bf0553cfb724"},{url:"/_next/static/chunks/960.54e5f109de2227e3.js",revision:"54e5f109de2227e3"},{url:"/_next/static/chunks/app/(site)/favorites/page-4f66d7249c387516.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/app/(site)/loading-96645736797edde7.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/app/(site)/page-358c5cc4926aeabc.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/app/(site)/popular/page-add26ae8835ac1c8.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/app/(site)/similar/page-11791ab234595cee.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/app/(site)/starring/page-cf21389ac14b04a2.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/app/(site)/top/page-f4d956714d29d21f.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/app/(site)/watch-list/page-7c31876ef68d1dfb.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/app/_not-found/page-97bde446d7f1c840.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/app/layout-6287c39d1b3a615e.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/c8bcbd21.63daf74955ffea8b.js",revision:"63daf74955ffea8b"},{url:"/_next/static/chunks/fd9d1056-d1448f0cd0a3dc26.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/framework-f66176bb897dc684.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/main-a339d49e77d6dbd3.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/main-app-51cdaff1a81e6b49.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/pages/_app-6a626577ffa902a4.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/pages/_error-1be831200e60c5c0.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-3ccfcc5f58030301.js",revision:"bRidjOJn2wzDcwzed1Uh9"},{url:"/_next/static/css/0d5f6452b2682b9b.css",revision:"0d5f6452b2682b9b"},{url:"/_next/static/css/665efcf14fcbe2ba.css",revision:"665efcf14fcbe2ba"},{url:"/_next/static/media/a9b1453781eac9e6-s.p.woff2",revision:"c754cf60aba699077f00948285bf54b5"},{url:"/_next/static/media/dd843ebd3ff03195-s.p.woff2",revision:"333341dc4117Line truncated
if(!self.define){let e,s={};const t=(t,n)=>(t=new URL(t+".js",n).href,s[t]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=t,e.onload=s,document.head.appendChild(e)}else e=t,importScripts(t),s()})).then((()=>{let e=s[t];if(!e)throw new Error(`Module ${t} didn’t register its module`);return e})));self.define=(n,i)=>{const a=e||("document"in self?document.currentScript.src:"")||location.href;if(s[a])return;let c={};const r=e=>t(e,a),o={module:{uri:a},exports:c,require:r};s[a]=Promise.all(n.map((e=>o[e]||r(e)))).then((e=>(i(...e),c)))}}define(["./workbox-4754cb34"],(function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"2ee68148b2171bbb08dea54d7afd4d5d"},{url:"/_next/static/U_sSOvHtqS4FV6KRr2F67/_buildManifest.js",revision:"2ec694eb52ae4f523f265a46bae4d768"},{url:"/_next/static/U_sSOvHtqS4FV6KRr2F67/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/101-f9422c830edc0af7.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/152.431d65c3703a61be.js",revision:"431d65c3703a61be"},{url:"/_next/static/chunks/209-8d08998363c1872f.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/23-e0259c2123520d87.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/26.286553a5ff2812fc.js",revision:"286553a5ff2812fc"},{url:"/_next/static/chunks/276.c3c1130f2adade69.js",revision:"c3c1130f2adade69"},{url:"/_next/static/chunks/329-eb2b4d4edbe9c401.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/344.05938a041227e582.js",revision:"05938a041227e582"},{url:"/_next/static/chunks/383.78d47f7582340f53.js",revision:"78d47f7582340f53"},{url:"/_next/static/chunks/460.ac20021c7496f1d6.js",revision:"ac20021c7496f1d6"},{url:"/_next/static/chunks/497.48f1dfd129122432.js",revision:"48f1dfd129122432"},{url:"/_next/static/chunks/61.e269d4a699fba0b6.js",revision:"e269d4a699fba0b6"},{url:"/_next/static/chunks/621-fa4d2ff1cf645813.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/67-0fe37804d3065a2f.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/673.362c29137dd3e968.js",revision:"362c29137dd3e968"},{url:"/_next/static/chunks/674-7c487cb45ac8eb18.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/695.156d21364de6e419.js",revision:"156d21364de6e419"},{url:"/_next/static/chunks/755.5cd959eac5682527.js",revision:"5cd959eac5682527"},{url:"/_next/static/chunks/792.b51012549074b93f.js",revision:"b51012549074b93f"},{url:"/_next/static/chunks/810.6105e84414768b0d.js",revision:"6105e84414768b0d"},{url:"/_next/static/chunks/922.9ce4bf0553cfb724.js",revision:"9ce4bf0553cfb724"},{url:"/_next/static/chunks/960.a4d728274961d42c.js",revision:"a4d728274961d42c"},{url:"/_next/static/chunks/app/(site)/favorites/page-4f66d7249c387516.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/app/(site)/loading-96645736797edde7.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/app/(site)/page-358c5cc4926aeabc.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/app/(site)/popular/page-add26ae8835ac1c8.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/app/(site)/similar/page-11791ab234595cee.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/app/(site)/starring/page-cf21389ac14b04a2.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/app/(site)/top/page-f4d956714d29d21f.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/app/(site)/watch-list/page-7c31876ef68d1dfb.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/app/_not-found/page-97bde446d7f1c840.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/app/layout-359def3e989a446d.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/c8bcbd21.63daf74955ffea8b.js",revision:"63daf74955ffea8b"},{url:"/_next/static/chunks/fd9d1056-d1448f0cd0a3dc26.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/framework-f66176bb897dc684.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/main-a339d49e77d6dbd3.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/main-app-51cdaff1a81e6b49.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/pages/_app-6a626577ffa902a4.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/pages/_error-1be831200e60c5c0.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-134a99c33ababfb0.js",revision:"U_sSOvHtqS4FV6KRr2F67"},{url:"/_next/static/css/0d5f6452b2682b9b.css",revision:"0d5f6452b2682b9b"},{url:"/_next/static/css/e0dab83f11395ded.css",revision:"e0dab83f11395ded"},{url:"/_next/static/media/a9b1453781eac9e6-s.p.woff2",revision:"c754cf60aba699077f00948285bf54b5"},{url:"/_next/static/media/dd843ebd3ff03195-s.p.woff2",revision:"333341dc4117Line truncated