Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22398517
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
13 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/back/jdd-components/autoscrolling-images/autoscrolling-images.css b/src/back/jdd-components/autoscrolling-images/autoscrolling-images.css
index 272c3de..99e266f 100644
--- a/src/back/jdd-components/autoscrolling-images/autoscrolling-images.css
+++ b/src/back/jdd-components/autoscrolling-images/autoscrolling-images.css
@@ -1,223 +1,281 @@
.autoscrolling-images {
display: flex;
justify-content: center;
margin: 2rem 0;
--gap-between-horizontal-images: 14px;
}
.autoscrolling-images-wrapper {
display: grid;
gap: 24px;
}
.autoscrolling-images__img-wrapper {
width: 288px;
height: 150px;
display: flex;
align-items: center;
justify-content: space-around;
}
.autoscrolling-images--mode-white .autoscrolling-images__img-wrapper {
background-color: white;
}
.autoscrolling-images__carousel-container {
position: relative;
max-width: min(940px, calc(100dvw - 48px));
picture,
img {
max-height: 150px;
max-width: 288px;
}
}
.autoscrolling-images__arrow img {
max-width: 30px;
}
.autoscrolling-images--mode-white-square .autoscrolling-images__img-wrapper,
.autoscrolling-images--mode-white .autoscrolling-images__img-wrapper {
img {
background: white; /* to get rid of weird artifacts on FF */
}
}
.autoscrolling-images--mode-white-square .autoscrolling-images__img-wrapper {
background-color: white;
padding: 16px;
height: unset;
width: 160px;
min-width: 0px;
aspect-ratio: 1/1;
}
.autoscrolling-images__title-wrapper {
max-width: 940px;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
}
.autoscrolling-images__title {
font-family: var(--font-headings);
font-size: 32px;
color: var(--color-brand-text-accent);
margin: 0;
}
.autoscrolling-images__arrow-carousel-container {
position: absolute;
top: -51px;
right: -90px;
width: 92px;
overflow-x: hidden;
}
.autoscrolling-images__arrow-carousel {
transition: none !important;
width: 100%;
display: flex;
flex-flow: row nowrap;
}
.autoscrolling-images__arrow-container {
display: flex;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
scroll-snap-align: start;
flex: 1 0 100%;
}
.autoscrolling-images__arrow:hover {
cursor: pointer;
}
.autoscrolling-images__img-arrow-left {
transform: rotate(180deg);
}
.autoscrolling-images__imgs-carousel {
overflow-x: clip;
}
.autoscrolling-images__carousel {
width: 100%;
display: flex;
flex-flow: row nowrap;
transition: transform 200ms;
}
.autoscrolling-images__carousel-page {
align-items: center;
scroll-snap-align: start;
box-sizing: border-box;
flex: 1 0 100%;
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
gap: var(--gap-between-horizontal-images);
max-width: 940px;
}
.autoscrolling-images__carousel-page--looping-head,
.autoscrolling-images__carousel-page--looping-tail {
display: none;
}
.autoscrolling-images__carousel-page--looping-tail {
position: absolute;
left: calc(100% + var(--gap-between-horizontal-images));
}
.autoscrolling-images__carousel-page--looping-head {
position: absolute;
right: 100%;
}
.autoscrolling-images__radio {
display: none;
}
.autoscrolling-images__dots-container {
display: flex;
justify-content: center;
margin-top: 24px;
}
.autoscrolling-images__dots {
cursor: pointer;
height: 12px;
width: 12px;
background-color: var(--color-brand-accent-09);
border-radius: 50%;
display: inline-block;
margin: 4px;
}
.autoscrolling-images__dots:hover {
background-color: var(--color-brand-accent-04);
}
@keyframes autoscrolling-images-infinite-scroll {
0% {
transform: translateX(0%);
}
100% {
transform: translateX(calc(-100% - var(--gap-between-horizontal-images)));
}
}
-@container (width < 1115px) {
- .autoscrolling-images__arrow-carousel-container {
- right: 0;
- }
-}
-
-@container (width < 800px) {
+.autoscrolling-images.endless {
.autoscrolling-images__arrow-carousel-container {
display: none;
}
.autoscrolling-images__dots-container {
display: none;
}
.autoscrolling-images__carousel {
max-width: none;
width: max-content;
animation-name: autoscrolling-images-infinite-scroll;
animation-duration: var(--animation-length);
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.autoscrolling-images__carousel-container {
margin: 0;
max-width: calc(100cqw - 20px);
}
.autoscrolling-images__carousel-page {
display: flex;
flex: none !important;
margin: 0;
flex-wrap: nowrap !important;
max-width: none;
}
.autoscrolling-images__img-wrapper {
min-width: 288px;
}
.autoscrolling-images__carousel-page--looping-head,
.autoscrolling-images__carousel-page--looping-tail {
display: flex;
}
+
+ @container (width > 800px) {
+ .autoscrolling-images__carousel-page {
+ display: grid !important;
+ grid-template-rows: repeat(2, auto);
+ grid-auto-flow: column;
+ gap: 16px;
+ }
+
+ .autoscrolling-images__img-wrapper:last-child:nth-child(odd) {
+ grid-row: 1 / span 2; /* take both rows */
+ align-self: center;
+ justify-self: center;
+ }
+ }
+}
+
+.autoscrolling-images:not(.endless) {
+ @container (width < 1115px) {
+ .autoscrolling-images__arrow-carousel-container {
+ right: 0;
+ }
+ }
+
+ @container (width < 800px) {
+ .autoscrolling-images__arrow-carousel-container {
+ display: none;
+ }
+
+ .autoscrolling-images__dots-container {
+ display: none;
+ }
+
+ .autoscrolling-images__carousel {
+ max-width: none;
+ width: max-content;
+ animation-name: autoscrolling-images-infinite-scroll;
+ animation-duration: var(--animation-length);
+ animation-iteration-count: infinite;
+ animation-timing-function: linear;
+ }
+
+ .autoscrolling-images__carousel-container {
+ margin: 0;
+ max-width: calc(100cqw - 20px);
+ }
+
+ .autoscrolling-images__carousel-page {
+ display: flex;
+ flex: none !important;
+ margin: 0;
+ flex-wrap: nowrap !important;
+ max-width: none;
+ }
+
+ .autoscrolling-images__img-wrapper {
+ min-width: 288px;
+ }
+
+ .autoscrolling-images__carousel-page--looping-head,
+ .autoscrolling-images__carousel-page--looping-tail {
+ display: flex;
+ }
+ }
}
diff --git a/src/back/jdd-components/autoscrolling-images/autoscrolling-images.jdd.tsx b/src/back/jdd-components/autoscrolling-images/autoscrolling-images.jdd.tsx
index 2030490..9af8a78 100644
--- a/src/back/jdd-components/autoscrolling-images/autoscrolling-images.jdd.tsx
+++ b/src/back/jdd-components/autoscrolling-images/autoscrolling-images.jdd.tsx
@@ -1,258 +1,268 @@
import { TempstreamJSX } from "tempstream";
import type {
ComponentToHTMLArgs,
ExtractStructuredComponentArgumentsParsed,
JDDContext,
} from "@sealcode/jdd";
import { Component, ComponentArguments } from "@sealcode/jdd";
import arrow from "./autoscrolling-images-arrow.svg";
import type { FilePointer } from "@sealcode/file-manager";
import type { makeJDDContext } from "../../jdd-context.js";
const images = new ComponentArguments.List(
new ComponentArguments.Structured({
image: new ComponentArguments.Image(),
alt: new ComponentArguments.ShortText(),
})
);
images.getExampleCount = () => {
return Math.round(4 + Math.random() * 9);
};
const component_arguments = {
title: new ComponentArguments.ShortText(),
imagesPerPage: new ComponentArguments.ShortText().setExampleValues(["6"]),
background_mode: new ComponentArguments.Enum([
"transparent",
"white",
"white-square",
]),
speed: new ComponentArguments.ShortText().setExampleValues(["5"]),
desktop_interval: new ComponentArguments.ShortText().setExampleValues(["5"]),
+ endless: new ComponentArguments.Enum(["true", "false"]),
images,
} as const;
function renderimagePageArrows({
radioButtonIdPrefix,
pageIndex,
imagePages,
}: {
radioButtonIdPrefix: string;
pageIndex: number;
imagePages: Array<Array<Record<string, unknown>>>;
}) {
return (
<div class="autoscrolling-images__arrow-container">
<label
for={`${radioButtonIdPrefix}-autoscrolling-images__radio-${
pageIndex == 0 ? imagePages.length - 1 : pageIndex - 1
}`}
class="autoscrolling-images__arrow"
>
<img
class="autoscrolling-images__img-arrow-left"
src={arrow.url}
alt="←"
/>
</label>
<label
for={`${radioButtonIdPrefix}-autoscrolling-images__radio-${
pageIndex == imagePages.length - 1 ? 0 : pageIndex + 1
}`}
class="autoscrolling-images__arrow"
>
<img src={arrow.url} alt="→" />
</label>
</div>
);
}
export function renderImagePage({
page,
render_image,
mode = "regular",
background_mode,
}: {
page: Array<{ image: FilePointer | null; alt: string }>;
render_image: ReturnType<typeof makeJDDContext>["render_image"];
mode?: "regular" | "looping-tail" | "looping-head";
background_mode: "white" | "white-square" | "transparent";
}): JSX.Element {
return (
<div
class={[
"autoscrolling-images__carousel-page",
`autoscrolling-images__carousel-page--${mode}`,
]}
>
{page.map((image) => (
<div class="autoscrolling-images__img-wrapper">
{render_image(image.image, {
container: {
...(background_mode == "white-square"
? { width: 128, height: 128 }
: { width: 212, height: 150 }),
objectFit: "contain",
},
alt: image.alt,
lossless: true,
thumbnailSize: 0,
})}
</div>
))}
</div>
);
}
export class AutoscrollingImages extends Component<typeof component_arguments> {
getArguments() {
return component_arguments;
}
getTitle(
_: JDDContext,
args: ExtractStructuredComponentArgumentsParsed<typeof component_arguments>
) {
return args.title || null;
}
toHTML({
- args: { title, imagesPerPage, images, speed, desktop_interval, background_mode },
+ args: {
+ title,
+ imagesPerPage,
+ images,
+ speed,
+ desktop_interval,
+ background_mode,
+ endless,
+ },
jdd_context: { render_image },
classes,
index,
}: ComponentToHTMLArgs<typeof component_arguments>) {
const imageNumberPerPage = parseInt(imagesPerPage);
const imagePages: (typeof images)[] = [];
for (let i = 0; i < images.length; i += imageNumberPerPage) {
imagePages.push(images.slice(i, i + imageNumberPerPage));
}
const radioButtonIdPrefix = "r" + Math.floor(100 + Math.random() * 900);
const radioButton_name = `autoscrolling-images__radio--${radioButtonIdPrefix}`;
return (
<div
class={[
"autoscrolling-images",
`autoscrolling-images--mode-${background_mode}`,
+ endless == "true" ? "endless" : "",
...classes,
]}
style={`--jdd-index: ${index}`}
data-controller="autoscrolling-images"
data-autoscrolling-images-interval={desktop_interval}
>
<style>
{imagePages
.map(
(_, pageIndex) =>
`#${radioButtonIdPrefix}-autoscrolling-images__radio-${pageIndex}:checked ~ .autoscrolling-images__imgs-carousel > .autoscrolling-images__carousel {
transform: translateX(calc(${pageIndex} * (-100%)));
}
#${radioButtonIdPrefix}-autoscrolling-images__radio-${pageIndex}:checked ~ .autoscrolling-images__arrow-carousel-container
> .autoscrolling-images__arrow-carousel {
transform: translateX(calc(${pageIndex} * (-100%)));
}
#${radioButtonIdPrefix}-autoscrolling-images__radio-${pageIndex}:checked ~ .autoscrolling-images__dots-container
> label:nth-child(${pageIndex + 1}) {
background-color: var(--color-brand-accent);
}`
)
.join("\n")}
</style>
<div
class="autoscrolling-images-wrapper"
data-carousel-id-prefix={radioButtonIdPrefix}
>
<div class="autoscrolling-images__title-wrapper">
<h2 class="autoscrolling-images__title">{title}</h2>
</div>
<div class="autoscrolling-images__carousel-container">
{imagePages.map((_, pageIndex) => (
<input
class="autoscrolling-images__radio"
type="radio"
name={radioButton_name}
title={`page ${pageIndex + 1}`}
value={pageIndex}
id={`${radioButtonIdPrefix}-autoscrolling-images__radio-${pageIndex}`}
checked={pageIndex === 0}
data-action="autoscrolling-images#handleRadioChange"
/>
))}
{imagePages.length > 1 ? (
<div class="autoscrolling-images__arrow-carousel-container">
<div class="autoscrolling-images__arrow-carousel">
{imagePages.map((_, pageIndex) =>
renderimagePageArrows({
pageIndex,
imagePages,
radioButtonIdPrefix,
})
)}
</div>
</div>
) : (
""
)}
<div class="autoscrolling-images__imgs-carousel">
<div
class="autoscrolling-images__carousel"
style={`--animation-length: ${
100 / parseInt(speed || "15")
}s`}
>
{renderImagePage({
page: imagePages.at(-1)!,
render_image,
mode: "looping-head",
background_mode,
})}
{imagePages.map((page) =>
renderImagePage({
page,
render_image,
background_mode,
})
)}
{/* for looping endless scroll*/}
{imagePages[0]
? renderImagePage({
page: imagePages[0],
render_image,
mode: "looping-tail",
background_mode,
})
: ""}
</div>
</div>
{imagePages.length > 1 ? (
<div class="autoscrolling-images__dots-container">
{imagePages.map((_, pageIndex) => (
<label
for={`${radioButtonIdPrefix}-autoscrolling-images__radio-${pageIndex}`}
class="autoscrolling-images__dots"
></label>
))}
</div>
) : (
""
)}
</div>
</div>
</div>
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Nov 27, 17:23 (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1229232
Default Alt Text
(13 KB)
Attached To
Mode
rAPROXY Assetproxy
Attached
Detach File
Event Timeline