x4js gallery

AssistBox

A StackBox that goes from page to page in their order, without animation: for a wizard. For slides that move: Carousel.

import { AssistBox } from "x4js"

A wizard

Back and Next call selectNextPage; isFirstPage and isLastPage enable them at each pageChange.

export function wizard( ) {
	const back = new Button( { label: "Back", click: ( ) => steps.selectNextPage( false ) } );
	const next = new Button( { label: "Next", click: ( ) => steps.selectNextPage( true ) } );

	const steps = new AssistBox( {
		cls: "steps",
		height: 140,
		default: "name",
		items: [
			{ name: "name", content: new VBox( { cls: "step", content: [
				new Label( { text: "1. Your name" } ),
				new Input( { type: "text", placeholder: "Name" } ),
			] } ) },
			{ name: "mail", content: new VBox( { cls: "step", content: [
				new Label( { text: "2. Your email" } ),
				new Input( { type: "email", placeholder: "you@example.com" } ),
			] } ) },
			{ name: "done", content: new VBox( { cls: "step", content: [
				new Label( { text: "3. Done: thank you." } ),
			] } ) },
		],
		pageChange: ( ) => {
			back.enable( !steps.isFirstPage( ) );
			next.enable( !steps.isLastPage( ) );
		},
	} );

	return new VBox( { width: 360, content: [
		steps,
		new HBox( { content: [ back, new Flex( ), next ] } ),
	] } );
}
.x4assistbox.steps {
	border: 1px solid var( --border );

	.step {
		justify-content: center;
		gap: 8px;
		padding: 16px;

		.x4input {
			padding: 4px 6px;
			border: 1px solid var( --border );
		}
	}
}

At the last page, Next goes back to the first one with select. For slides that move, with arrows, dots, a swipe and an autoplay: Carousel.

export function carousel( ) {
	const slides = new AssistBox( {
		cls: "slides",
		height: 140,
		default: "home",
		items: [
			{ name: "home", content: new Label( { cls: "slide", icon: icon_home, text: "Home" } ) },
			{ name: "star", content: new Label( { cls: "slide", icon: icon_star, text: "Star" } ) },
			{ name: "heart", content: new Label( { cls: "slide", icon: icon_heart, text: "Heart" } ) },
		],
	} );

	return new VBox( { width: 360, content: [
		slides,
		new HBox( { content: [
			new Flex( ),
			new Button( { label: "Next", click: ( ) => {
				if( slides.isLastPage( ) ) {
					slides.select( slides.enumPageNames( )[0] );
				}
				else {
					slides.selectNextPage( );
				}
			} } ),
		] } ),
	] } );
}
.x4assistbox.slides {
	background: var( --background-secondary );

	.slide {
		justify-content: center;
		gap: 10px;
		font-size: 1.4rem;
		--label-color: var( --text-primary );

		#icon {
			width: 2rem;
			height: 2rem;
			fill: var( --accent-background );
		}
	}
}

For an assistant: llms.txt, llms-full.txt.