Compare commits
6 Commits
f3d7c7abf2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 76b50ec462 | |||
| d332635d6a | |||
| 1d0c3f68c5 | |||
| 8743133f05 | |||
| dae708c765 | |||
| 162f21089d |
Generated
+1190
-1067
File diff suppressed because it is too large
Load Diff
+2
-1
@@ -47,6 +47,7 @@
|
|||||||
"eslint-config-prettier": "^9.0.0",
|
"eslint-config-prettier": "^9.0.0",
|
||||||
"eslint-plugin-prettier": "^5.0.1",
|
"eslint-plugin-prettier": "^5.0.1",
|
||||||
"prettier": "^3.0.3",
|
"prettier": "^3.0.3",
|
||||||
"typescript": "^5.2.2"
|
"react-router-dom": "^6.20.0",
|
||||||
|
"typescript": "4.9.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-4
@@ -38,7 +38,12 @@ body {
|
|||||||
overflow: clip;
|
overflow: clip;
|
||||||
}
|
}
|
||||||
|
|
||||||
.GalleryItem > img,
|
.GalleryItem > .ImgLink {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.GalleryItem > .ImgLink > img,
|
||||||
.GalleryItem > video {
|
.GalleryItem > video {
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
max-height: 80vh;
|
max-height: 80vh;
|
||||||
@@ -63,16 +68,30 @@ body {
|
|||||||
background-color: #0056b3;
|
background-color: #0056b3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.PlaceholderItem {
|
||||||
|
animation: loading 1.5s infinite;
|
||||||
|
}
|
||||||
|
|
||||||
.PlaceholderItem > button,
|
.PlaceholderItem > button,
|
||||||
.ParentDirectoryItem > button {
|
.ParentDirectoryItem > button {
|
||||||
background-color: #4D4F5D;
|
background-color: #4D4F5D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.PlaceholderItem > button,
|
||||||
|
.DirectoryItem > button {
|
||||||
|
height: 2.5em;
|
||||||
|
min-width: 6em;
|
||||||
|
}
|
||||||
|
|
||||||
.PlaceholderItem > a {
|
.PlaceholderItem > a {
|
||||||
height: 1em;
|
height: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.PlaceholderItem > button {
|
@keyframes loading {
|
||||||
height: calc(16px + 10px * 2);
|
0%, 100% {
|
||||||
width: 6em;
|
filter: brightness(80%);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
filter: brightness(100%);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-4
@@ -1,12 +1,14 @@
|
|||||||
|
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
||||||
import './App.css';
|
import './App.css';
|
||||||
|
|
||||||
import Gallery from './Gallery/index';
|
import Gallery from './Gallery/index';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<BrowserRouter>
|
||||||
<Gallery />
|
<Routes>
|
||||||
</div>
|
<Route path="/photos/*" element={<Gallery />} />
|
||||||
|
</Routes>
|
||||||
|
</BrowserRouter>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+38
-12
@@ -1,21 +1,34 @@
|
|||||||
import React from 'react';
|
|
||||||
import '../App.css';
|
import '../App.css';
|
||||||
import placeholderPng from './placeholder.png';
|
import placeholderPng from './placeholder.png';
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
|
import { useParams, useNavigate, useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
function Gallery() {
|
function Gallery() {
|
||||||
|
const params = useParams<string>()['*'];
|
||||||
|
const location = useLocation();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [data, setData] = useState<galleryItemInfo[]>([]);
|
const [data, setData] = useState<galleryItemInfo[]>([]);
|
||||||
const [category, setCategory] = useState('');
|
const [category, setCategory] = useState(params === undefined ? '' : params);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
post(category, (data: galleryItemInfo[]) => {
|
post(category, (data: galleryItemInfo[]) => {
|
||||||
|
if (data.length === 0) {
|
||||||
|
updateCategory('');
|
||||||
|
}
|
||||||
setData(data);
|
setData(data);
|
||||||
});
|
});
|
||||||
}, [category]);
|
}, [category]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setData(getPlaceholderData());
|
||||||
|
setCategory(params as string);
|
||||||
|
}, [location]);
|
||||||
|
|
||||||
const updateCategory = (category: string) => {
|
const updateCategory = (category: string) => {
|
||||||
setData(getPlaceholderData);
|
setData(getPlaceholderData());
|
||||||
setCategory(category);
|
setCategory(category);
|
||||||
|
navigate(`/photos/${category}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -68,16 +81,18 @@ function Contents(
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (item.is_dir) {
|
if (item.is_dir) {
|
||||||
itemProps.onClick = () => {
|
itemProps.onClick = item.isPlaceholder
|
||||||
const subCategory = getFileName(itemProps.url);
|
? () => {}
|
||||||
|
: () => {
|
||||||
|
const subCategory = getFileName(itemProps.url);
|
||||||
|
|
||||||
if (category !== '') category = `${category}/${subCategory}`;
|
if (category !== '') category = `${category}/${subCategory}`;
|
||||||
else category = subCategory;
|
else category = subCategory;
|
||||||
if (subCategory === '..')
|
if (subCategory === '..')
|
||||||
category = category.split('/').slice(0, -2).join('/');
|
category = category.split('/').slice(0, -2).join('/');
|
||||||
|
|
||||||
setCategory(category);
|
setCategory(category);
|
||||||
};
|
};
|
||||||
return <DirectoryItem {...itemProps} />;
|
return <DirectoryItem {...itemProps} />;
|
||||||
}
|
}
|
||||||
if (itemProps.url.endsWith('.mp4')) {
|
if (itemProps.url.endsWith('.mp4')) {
|
||||||
@@ -101,7 +116,9 @@ function ImageItem({ thumbnail_url, url, isPlaceholder }: galleryItem) {
|
|||||||
<a href={url} target="_blank">
|
<a href={url} target="_blank">
|
||||||
{getFileName(url)}
|
{getFileName(url)}
|
||||||
</a>
|
</a>
|
||||||
<img src={thumbnail_url} loading="lazy" />
|
<a href={url} target="_blank" className="ImgLink">
|
||||||
|
<img src={thumbnail_url} loading="lazy" />
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -137,6 +154,14 @@ function getFileName(string: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getPlaceholderData(): galleryItemInfo[] {
|
function getPlaceholderData(): galleryItemInfo[] {
|
||||||
|
const backDir = (): galleryItemInfo => {
|
||||||
|
return {
|
||||||
|
is_dir: true,
|
||||||
|
url: '..',
|
||||||
|
thumbnail_url: '',
|
||||||
|
isPlaceholder: true,
|
||||||
|
};
|
||||||
|
};
|
||||||
const placeholderDir = (): galleryItemInfo => {
|
const placeholderDir = (): galleryItemInfo => {
|
||||||
return {
|
return {
|
||||||
is_dir: true,
|
is_dir: true,
|
||||||
@@ -155,6 +180,7 @@ function getPlaceholderData(): galleryItemInfo[] {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
backDir(),
|
||||||
placeholderDir(),
|
placeholderDir(),
|
||||||
placeholderDir(),
|
placeholderDir(),
|
||||||
placeholderImg(),
|
placeholderImg(),
|
||||||
|
|||||||
Reference in New Issue
Block a user