Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

Commit 1ea22c0

Browse files
author
John Richard Chipps-Harding
authored
Title support (#2)
1 parent a308b55 commit 1ea22c0

File tree

5 files changed

+47
-1
lines changed

5 files changed

+47
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ You can configure a few things by editing the file `src/config/index.tsx`.
2121
- `POLL_INTERVAL` - How often should the frontend look for updates. Default 5 seconds.
2222
- `FILE_EXTENSION` - The filetypes supported. Default `png`.
2323
- `FILE_MIME` - The file mime type. Default `image/png`.
24+
- `SHOW_TITLE` - If the title should be overlaid. Default `true`.
25+
26+
You can also adjust the title field formatter here: `src/utils/images.ts`.

src/components/ImageStack/ImageStack.module.css

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
@keyframes fadeIn {
2+
from {
3+
opacity: 0;
4+
}
5+
to {
6+
opacity: 1;
7+
}
8+
}
9+
110
@keyframes slitherIn {
211
from {
312
opacity: 0;
@@ -21,13 +30,35 @@
2130
}
2231

2332
.list li {
33+
position: relative;
2434
width: 100%;
2535
margin-bottom: 16px;
2636
border-radius: 8px;
2737
overflow: hidden;
2838
animation-name: slitherIn;
29-
animation-duration: 2s;
39+
animation-duration: 4s;
40+
animation-timing-function: ease-in-out;
41+
}
42+
43+
.list li h2 {
44+
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
45+
font-weight: normal;
46+
font-size: 1em;
47+
position: absolute;
48+
bottom: 0;
49+
left: 0;
50+
right: 0;
51+
padding: 16px;
52+
margin: 0;
53+
background-color: #00000033;
54+
text-shadow: 2px 2px #00000044;
55+
color: white;
56+
57+
animation-name: fadeIn;
58+
animation-delay: 3s;
59+
animation-duration: 4s;
3060
animation-timing-function: ease-in-out;
61+
animation-fill-mode: both;
3162
}
3263

3364
.list li img {

src/components/ImageStack/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* eslint-disable @next/next/no-img-element */
2+
import { getTitle } from "@/utils/images";
3+
import { SHOW_TITLE } from "@/config";
4+
25
import styles from "./ImageStack.module.css";
36

47
interface Props {
@@ -9,6 +12,7 @@ export const ImageStack = ({ images = [] }: Props) => (
912
<ul className={styles.list}>
1013
{images.map((image) => (
1114
<li key={image}>
15+
{SHOW_TITLE && <h2>{getTitle(image)}</h2>}
1216
<img src={`/api/image?image=${image}`} alt={image} />
1317
</li>
1418
))}

src/config/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export const MAX_IMAGES = 10;
33
export const POLL_INTERVAL = 5 * 1000;
44
export const FILE_EXTENSION = "png";
55
export const FILE_MIME = "image/png";
6+
export const SHOW_TITLE = true;

src/utils/images.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const getTitle = (url: string) => {
2+
const split1 = url.split("-");
3+
if (split1.length < 2) return "Filename: " + url;
4+
const withoutNumbers = split1[2];
5+
const lastDot = withoutNumbers.lastIndexOf(".");
6+
return withoutNumbers.substring(0, lastDot);
7+
};

0 commit comments

Comments
 (0)