Update hero-carousel
This commit is contained in:
4 files changed
+120
-32
No files matched your search
Generated
+27
@@ -19,12 +19,14 @@
|
||||
"@reduxjs/toolkit": "^1.9.3",
|
||||
"@tanstack/react-query": "^4.26.1",
|
||||
"@tanstack/react-query-devtools": "^4.27.0",
|
||||
"blurhash": "^2.0.5",
|
||||
"events": "^3.3.0",
|
||||
"framer-motion": "^10.2.4",
|
||||
"localforage": "^1.10.0",
|
||||
"match-sorter": "^6.3.1",
|
||||
"notistack": "^3.0.1",
|
||||
"react": "^18.2.0",
|
||||
"react-blurhash": "^0.3.0",
|
||||
"react-cookie": "^4.1.1",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-material-ui-carousel": "^3.4.2",
|
||||
@@ -1866,6 +1868,11 @@
|
||||
"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": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
||||
@@ -2782,6 +2789,15 @@
|
||||
"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": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/react-cookie/-/react-cookie-4.1.1.tgz",
|
||||
@@ -4358,6 +4374,11 @@
|
||||
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
|
||||
"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": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
||||
@@ -4999,6 +5020,12 @@
|
||||
"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": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/react-cookie/-/react-cookie-4.1.1.tgz",
|
||||
|
||||
@@ -20,12 +20,14 @@
|
||||
"@reduxjs/toolkit": "^1.9.3",
|
||||
"@tanstack/react-query": "^4.26.1",
|
||||
"@tanstack/react-query-devtools": "^4.27.0",
|
||||
"blurhash": "^2.0.5",
|
||||
"events": "^3.3.0",
|
||||
"framer-motion": "^10.2.4",
|
||||
"localforage": "^1.10.0",
|
||||
"match-sorter": "^6.3.1",
|
||||
"notistack": "^3.0.1",
|
||||
"react": "^18.2.0",
|
||||
"react-blurhash": "^0.3.0",
|
||||
"react-cookie": "^4.1.1",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-material-ui-carousel": "^3.4.2",
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
margin: 0 auto;
|
||||
}
|
||||
&-background {
|
||||
&-blurhash {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
}
|
||||
&-container {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
@@ -21,13 +27,12 @@
|
||||
bottom: 0;
|
||||
mask-image: linear-gradient(
|
||||
to right,
|
||||
transparent 20%,
|
||||
black 50%
|
||||
rgba(0, 0, 0, 0.1),
|
||||
black 90%
|
||||
);
|
||||
-webkit-mask-image: linear-gradient(
|
||||
to right,
|
||||
transparent 20%,
|
||||
rgb(0 0 0 / 0.5) 50%,
|
||||
rgba(0, 0, 0, 0.1),
|
||||
black 90%
|
||||
);
|
||||
}
|
||||
@@ -40,6 +45,19 @@
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
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 {
|
||||
position: absolute;
|
||||
|
||||
+69
-28
@@ -2,6 +2,8 @@
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
import { Blurhash, BlurhashCanvas } from "react-blurhash";
|
||||
|
||||
import { useQueryClient, useQuery } from "@tanstack/react-query";
|
||||
|
||||
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 { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
import { formateDate } from "../../utils/date/formateDate";
|
||||
@@ -141,11 +144,27 @@ export const Home = () => {
|
||||
enabled: !!user.data,
|
||||
});
|
||||
|
||||
const [userLibraries, setUserLibraries] = useState([]);
|
||||
const [latestMovies, setLatestMovies] = useState([]);
|
||||
const [Auser, setUser] = useState({
|
||||
Name: "",
|
||||
});
|
||||
const fetchLatestMedia = async (lib) => {
|
||||
const latmedia = useQuery({
|
||||
queryKey: ["home", "latestMedia", lib.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 dataT = useSelector((state) => {
|
||||
@@ -187,6 +206,8 @@ export const Home = () => {
|
||||
},
|
||||
];
|
||||
|
||||
const latestMediaLayout = [];
|
||||
|
||||
const excludeTypes = ["boxsets", "playlists", "livetv", "channels"];
|
||||
|
||||
const getLatestMedia = async () => {
|
||||
@@ -195,19 +216,13 @@ export const Home = () => {
|
||||
if (excludeTypes.includes(lib.CollectionType)) {
|
||||
return;
|
||||
} else {
|
||||
let latmedia = await getUserLibraryApi(
|
||||
window.api,
|
||||
).getLatestMedia({
|
||||
userId: user.data.Id,
|
||||
parentId: lib.Id,
|
||||
limit: 16,
|
||||
});
|
||||
layout.push({
|
||||
latestMediaLayout.push({
|
||||
type: "latestMedia",
|
||||
name: `Latest ${lib.Name}`,
|
||||
data: latmedia.data,
|
||||
parentId: lib.Id,
|
||||
isLoading: false,
|
||||
});
|
||||
setLatestMediaContent(latestMediaLayout);
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -221,7 +236,11 @@ export const Home = () => {
|
||||
useEffect(() => {
|
||||
if (libraries.isSuccess) {
|
||||
getLatestMedia();
|
||||
setLayoutState(layout);
|
||||
console.log(latestMediaContent);
|
||||
for (let lib of latestMediaContent) {
|
||||
console.log(lib);
|
||||
fetchLatestMedia(lib);
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
@@ -291,19 +310,41 @@ export const Home = () => {
|
||||
<div className="hero-carousel-background-container">
|
||||
{item.ImageBlurHashes
|
||||
.Backdrop ? (
|
||||
<div
|
||||
className="hero-carousel-background-image"
|
||||
style={{
|
||||
backgroundImage: `url(${
|
||||
window
|
||||
.api
|
||||
.basePath +
|
||||
"/Items/" +
|
||||
item.Id +
|
||||
"/Images/Backdrop"
|
||||
})`,
|
||||
}}
|
||||
></div>
|
||||
<>
|
||||
<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
|
||||
className="hero-carousel-background-image"
|
||||
style={{
|
||||
backgroundImage: `url(${
|
||||
window
|
||||
.api
|
||||
.basePath +
|
||||
"/Items/" +
|
||||
item.Id +
|
||||
"/Images/Backdrop"
|
||||
})`,
|
||||
}}
|
||||
></div>
|
||||
</>
|
||||
) : (
|
||||
<div className="hero-carousel-background-image empty"></div>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user