Update hero-carousel

This commit is contained in:
prayag17 committed 2023-03-22 14:31:14 +05:30
1 parent 12d771c6c7
commit c851201872
4 files changed
+106 -18

No files matched your search

+27
View File
@@ -19,12 +19,14 @@
"@reduxjs/toolkit": "^1.9.3", "@reduxjs/toolkit": "^1.9.3",
"@tanstack/react-query": "^4.26.1", "@tanstack/react-query": "^4.26.1",
"@tanstack/react-query-devtools": "^4.27.0", "@tanstack/react-query-devtools": "^4.27.0",
"blurhash": "^2.0.5",
"events": "^3.3.0", "events": "^3.3.0",
"framer-motion": "^10.2.4", "framer-motion": "^10.2.4",
"localforage": "^1.10.0", "localforage": "^1.10.0",
"match-sorter": "^6.3.1", "match-sorter": "^6.3.1",
"notistack": "^3.0.1", "notistack": "^3.0.1",
"react": "^18.2.0", "react": "^18.2.0",
"react-blurhash": "^0.3.0",
"react-cookie": "^4.1.1", "react-cookie": "^4.1.1",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-material-ui-carousel": "^3.4.2", "react-material-ui-carousel": "^3.4.2",
@@ -1866,6 +1868,11 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/blurhash": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/blurhash/-/blurhash-2.0.5.tgz",
"integrity": "sha512-cRygWd7kGBQO3VEhPiTgq4Wc43ctsM+o46urrmPOiuAe+07fzlSB9OJVdpgDL0jPqXUVQ9ht7aq7kxOeJHRK+w=="
},
"node_modules/braces": { "node_modules/braces": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
@@ -2782,6 +2789,15 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/react-blurhash": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/react-blurhash/-/react-blurhash-0.3.0.tgz",
"integrity": "sha512-XlKr4Ns1iYFRnk6DkAblNbAwN/bTJvxTVoxMvmTcURdc5oLoXZwqAF9N3LZUh/HT+QFlq5n6IS6VsDGsviYAiQ==",
"peerDependencies": {
"blurhash": "^2.0.3",
"react": ">=15"
}
},
"node_modules/react-cookie": { "node_modules/react-cookie": {
"version": "4.1.1", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/react-cookie/-/react-cookie-4.1.1.tgz", "resolved": "https://registry.npmjs.org/react-cookie/-/react-cookie-4.1.1.tgz",
@@ -4358,6 +4374,11 @@
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
"devOptional": true "devOptional": true
}, },
"blurhash": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/blurhash/-/blurhash-2.0.5.tgz",
"integrity": "sha512-cRygWd7kGBQO3VEhPiTgq4Wc43ctsM+o46urrmPOiuAe+07fzlSB9OJVdpgDL0jPqXUVQ9ht7aq7kxOeJHRK+w=="
},
"braces": { "braces": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
@@ -4999,6 +5020,12 @@
"loose-envify": "^1.1.0" "loose-envify": "^1.1.0"
} }
}, },
"react-blurhash": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/react-blurhash/-/react-blurhash-0.3.0.tgz",
"integrity": "sha512-XlKr4Ns1iYFRnk6DkAblNbAwN/bTJvxTVoxMvmTcURdc5oLoXZwqAF9N3LZUh/HT+QFlq5n6IS6VsDGsviYAiQ==",
"requires": {}
},
"react-cookie": { "react-cookie": {
"version": "4.1.1", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/react-cookie/-/react-cookie-4.1.1.tgz", "resolved": "https://registry.npmjs.org/react-cookie/-/react-cookie-4.1.1.tgz",
+2
View File
@@ -20,12 +20,14 @@
"@reduxjs/toolkit": "^1.9.3", "@reduxjs/toolkit": "^1.9.3",
"@tanstack/react-query": "^4.26.1", "@tanstack/react-query": "^4.26.1",
"@tanstack/react-query-devtools": "^4.27.0", "@tanstack/react-query-devtools": "^4.27.0",
"blurhash": "^2.0.5",
"events": "^3.3.0", "events": "^3.3.0",
"framer-motion": "^10.2.4", "framer-motion": "^10.2.4",
"localforage": "^1.10.0", "localforage": "^1.10.0",
"match-sorter": "^6.3.1", "match-sorter": "^6.3.1",
"notistack": "^3.0.1", "notistack": "^3.0.1",
"react": "^18.2.0", "react": "^18.2.0",
"react-blurhash": "^0.3.0",
"react-cookie": "^4.1.1", "react-cookie": "^4.1.1",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-material-ui-carousel": "^3.4.2", "react-material-ui-carousel": "^3.4.2",
+22 -4
View File
@@ -12,6 +12,12 @@
margin: 0 auto; margin: 0 auto;
} }
&-background { &-background {
&-blurhash {
width: 100%;
height: 100%;
position: absolute;
z-index: 1;
}
&-container { &-container {
position: absolute; position: absolute;
z-index: 0; z-index: 0;
@@ -21,13 +27,12 @@
bottom: 0; bottom: 0;
mask-image: linear-gradient( mask-image: linear-gradient(
to right, to right,
transparent 20%, rgba(0, 0, 0, 0.1),
black 50% black 90%
); );
-webkit-mask-image: linear-gradient( -webkit-mask-image: linear-gradient(
to right, to right,
transparent 20%, rgba(0, 0, 0, 0.1),
rgb(0 0 0 / 0.5) 50%,
black 90% black 90%
); );
} }
@@ -40,6 +45,19 @@
right: 0; right: 0;
bottom: 0; bottom: 0;
background-position: center; background-position: center;
opacity: 1;
mask-image: linear-gradient(
to right,
transparent 10%,
rgba(0, 0, 0, 0.5) 50%,
black 90%
);
-webkit-mask-image: linear-gradient(
to right,
transparent 10%,
rgba(0, 0, 0, 0.5) 50%,
black 90%
);
} }
&-icon { &-icon {
position: absolute; position: absolute;
+55 -14
View File
@@ -2,6 +2,8 @@
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { Blurhash, BlurhashCanvas } from "react-blurhash";
import { useQueryClient, useQuery } from "@tanstack/react-query"; import { useQueryClient, useQuery } from "@tanstack/react-query";
import { EventEmitter as event } from "../../eventEmitter"; import { EventEmitter as event } from "../../eventEmitter";
@@ -40,6 +42,7 @@ import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"; import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api"; import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api"; import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { formateDate } from "../../utils/date/formateDate"; import { formateDate } from "../../utils/date/formateDate";
@@ -141,11 +144,27 @@ export const Home = () => {
enabled: !!user.data, enabled: !!user.data,
}); });
const [userLibraries, setUserLibraries] = useState([]); const fetchLatestMedia = async (lib) => {
const [latestMovies, setLatestMovies] = useState([]); const latmedia = useQuery({
const [Auser, setUser] = useState({ queryKey: ["home", "latestMedia", lib.name],
Name: "", queryFn: async () => {
const media = await getUserLibraryApi(
window.api,
).getLatestMedia({
userId: user.data.Id,
parentId: lib.parentId,
limit: 16,
}); });
return media.data;
},
});
return latmedia;
};
const [latestMediaContent, setLatestMediaContent] = useState([]);
const [latestMediaLib, setLatestMediaLib] = useState("");
// const latestMediaData = useQueries(latestMediaContent);
const dispatch = useDispatch(); const dispatch = useDispatch();
const dataT = useSelector((state) => { const dataT = useSelector((state) => {
@@ -187,6 +206,8 @@ export const Home = () => {
}, },
]; ];
const latestMediaLayout = [];
const excludeTypes = ["boxsets", "playlists", "livetv", "channels"]; const excludeTypes = ["boxsets", "playlists", "livetv", "channels"];
const getLatestMedia = async () => { const getLatestMedia = async () => {
@@ -195,19 +216,13 @@ export const Home = () => {
if (excludeTypes.includes(lib.CollectionType)) { if (excludeTypes.includes(lib.CollectionType)) {
return; return;
} else { } else {
let latmedia = await getUserLibraryApi( latestMediaLayout.push({
window.api,
).getLatestMedia({
userId: user.data.Id,
parentId: lib.Id,
limit: 16,
});
layout.push({
type: "latestMedia", type: "latestMedia",
name: `Latest ${lib.Name}`, name: `Latest ${lib.Name}`,
data: latmedia.data, parentId: lib.Id,
isLoading: false, isLoading: false,
}); });
setLatestMediaContent(latestMediaLayout);
} }
}); });
}; };
@@ -221,7 +236,11 @@ export const Home = () => {
useEffect(() => { useEffect(() => {
if (libraries.isSuccess) { if (libraries.isSuccess) {
getLatestMedia(); getLatestMedia();
setLayoutState(layout); console.log(latestMediaContent);
for (let lib of latestMediaContent) {
console.log(lib);
fetchLatestMedia(lib);
}
} }
}, []); }, []);
@@ -291,6 +310,27 @@ export const Home = () => {
<div className="hero-carousel-background-container"> <div className="hero-carousel-background-container">
{item.ImageBlurHashes {item.ImageBlurHashes
.Backdrop ? ( .Backdrop ? (
<>
<BlurhashCanvas
hash={
item
.ImageBlurHashes
.Backdrop[
item
.BackdropImageTags[0]
]
}
// hash="LEHV6nWB2yk8pyo0adR*.7kCMdnj"
width="1080"
height="720"
resolutionX={
512
}
resolutionY={
512
}
className="hero-carousel-background-blurhash"
/>
<div <div
className="hero-carousel-background-image" className="hero-carousel-background-image"
style={{ style={{
@@ -304,6 +344,7 @@ export const Home = () => {
})`, })`,
}} }}
></div> ></div>
</>
) : ( ) : (
<div className="hero-carousel-background-image empty"></div> <div className="hero-carousel-background-image empty"></div>
)} )}