This PR contains the latest updates from the generic Website template, which have been added while working on #loud-amsterdam. Reviewed-on: #1 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
30 lines
853 B
Swift
30 lines
853 B
Swift
/// A rendition an image asset is available at, from the narrowest up to the full-size file.
|
|
///
|
|
/// ``StaticFile`` names one file per rendition, and a page's `srcset` offers them all so the browser picks by rendered width.
|
|
/// The declaration order is the `srcset` order: narrowest first.
|
|
enum ImageWidth: CaseIterable {
|
|
/// The small rendition, 480 pixels wide.
|
|
case small
|
|
/// The medium rendition, 800 pixels wide.
|
|
case medium
|
|
/// The large rendition: the full-size file, 1200 pixels wide.
|
|
case large
|
|
}
|
|
|
|
// MARK: - Extensions
|
|
|
|
extension ImageWidth {
|
|
|
|
// MARK: Computed
|
|
|
|
/// The rendition's width in pixels: what the file is resampled to, and what its `srcset` descriptor states.
|
|
var width: Int {
|
|
switch self {
|
|
case .small: 480
|
|
case .medium: 800
|
|
case .large: 1200
|
|
}
|
|
}
|
|
|
|
}
|