struct WallpaperSlider: HtmlProducer { static let frameHeight = 585 static let frameWidth = 270 static let imageWidth = 250 static let imageHeight = 500 let frame: Frame let images: [Image] let id: String struct Frame { let alt: String let x1: ImageVersion let x2: ImageVersion init(frame: FileResource, language: ContentLanguage, results: PageGenerationResults) { self.x1 = frame.imageVersion( width: WallpaperSlider.frameWidth * 2, height: WallpaperSlider.frameHeight * 2, type: frame.type) self.x2 = frame.imageVersion( width: WallpaperSlider.frameWidth * 2, height: WallpaperSlider.frameHeight * 2, type: frame.type) self.alt = frame.localized(in: language) ?? "A frame" results.require(image: x1) results.require(image: x2) } } struct Image { let display: ImageSet let wide: DownloadImage let tall: DownloadImage struct DownloadImage { let url: String let button: String } init(tall: FileResource, wide: FileResource, language: ContentLanguage, results: PageGenerationResults) { self.display = tall.imageSet( width: WallpaperSlider.imageWidth, height: WallpaperSlider.imageHeight, language: language) let wideButton = language == .english ? "Wide" : "Breit" self.wide = .init(url: wide.absoluteUrl, button: wideButton) let tallButton = language == .english ? "Tall" : "Hoch" self.tall = .init(url: tall.absoluteUrl, button: tallButton) results.require(imageSet: display) results.require(file: wide) results.require(file: tall) results.require(icon: .buttonDownload) } } func populate(_ result: inout String) { let icon: PageIcon = .buttonDownload result += "
" result += "" result += "
" for image in images { result += "
" image.display.populate(&result) result += "
" // Close button-container, swiper-slide } result += "
" // Close swiper-wrapper result += "
" result += "
" result += "
" // Close swiper result += "
" // Close swiper-container } var style: String { """ .swiper { overflow: hidden; border-radius: 10px; } .swiper-container { position: relative; max-width: 250px; max-height: 500px; margin: auto; margin-top: 40px; aspect-ratio: 1 / 2; } .overlay-image { position: absolute; top: -8.5%; left: -4%; width: 108%; height: 117%; z-index: 10; object-fit: contain; pointer-events: none; } .button-container { position: absolute; bottom: 15%; width: 100%; margin: auto; display: flex; justify-content: space-evenly; } .custom-button { padding: 10px 10px; width: 60px; border: none; border-radius: 10px; background-color: rgba(29, 29, 29, 0.74); color: white; cursor: pointer; text-decoration: none; font-size: 12px; justify-content: space-evenly; } .swiper-button-next { margin-right: 5px; } .swiper-button-prev { margin-left: 5px; } """ } var script: String { """ """ } }