From bc3f53b9ff0ac01aace52f75d8ea11f20dfe61f9 Mon Sep 17 00:00:00 2001 From: Carmi Weinzweig Date: Tue, 21 Feb 2023 12:11:29 -0800 Subject: [PATCH] Added `sizes`, `height` and `width` `Attributes` to the PictureSourceContext. --- Sources/Plot/API/HTMLAttributes.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Sources/Plot/API/HTMLAttributes.swift b/Sources/Plot/API/HTMLAttributes.swift index 9c9b8f6..79a5c19 100644 --- a/Sources/Plot/API/HTMLAttributes.swift +++ b/Sources/Plot/API/HTMLAttributes.swift @@ -261,6 +261,24 @@ public extension Attribute where Context == HTML.PictureSourceContext { static func type(_ type: String) -> Attribute { Attribute(name: "type", value: type) } + + /// A string with a media query describing which image from the `srcset` attribute should be used. + /// - parameter sizes: The sizes used for the of sources that this element should point to. + static func sizes(_ sizes: String) -> Attribute { + Attribute(name: "sizes", value: sizes) + } + + /// Assign an integer giving the intinsic height of the `srcset` image in pixels. + /// - parameter height: The height of the image in the source. + static func height(_ height: Int) -> Attribute { + Attribute(name: "height", value: String(height)) + } + + /// Assign an integer giving the intrinsic width of the `srcset` image in pixels. + /// - parameter width: The width of the image in the source. + static func width(_ width: Int) -> Attribute { + Attribute(name: "width", value: String(width)) + } } // MARK: - Forms, input and options