Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 90 additions & 17 deletions Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,52 @@ public protocol AcceptAttribute: Attribute {
/// ```swift
/// Input()
/// .type(.file)
/// .accept("image/png, image/jpeg")
/// .accept(["image/png", "image/jpeg"])
/// ```
///
/// - Parameter value: The file types to pick from.
/// - Parameter specifiers: The file types to pick from.
///
/// - Returns: The element
func accept(_ value: String) -> Self
func accept(_ specifiers: [String]) -> Self

/// Filter accepted file types for upload.
///
/// ```swift
/// Input()
/// .type(.file)
/// .accept("image/png", "image/jpeg")
/// ```
///
/// - Parameter specifiers: The file types to pick from.
///
/// - Returns: The element
func accept(_ specifiers: String...) -> Self

/// Filter accepted file types for upload.
///
/// ```swift
/// Input()
/// .type(.file)
/// .accept([.ogg, .mpeg])
/// ```
///
/// - Parameter specifiers: The file types to pick from.
///
/// - Returns: The element
func accept(_ specifiers: [Values.Media]) -> Self

/// Filter accepted file types for upload.
///
/// ```swift
/// Input()
/// .type(.file)
/// .accept(.ogg, .mpeg)
/// ```
///
/// - Parameter specifiers: The file types to pick from.
///
/// - Returns: The element
func accept(_ specifiers: Values.Media...) -> Self
}

extension AcceptAttribute where Self: ContentNode {
Expand Down Expand Up @@ -2113,14 +2152,34 @@ public protocol MediaAttribute: Attribute {
///
/// ```swift
/// Link()
/// .reference("https://...")
/// .media("print")
/// .reference("...css")
/// .media([
/// MediaQuery(target: .screen, features: .orientation(.portrait)),
/// MediaQuery(target: .print, features: .resolution("300dpi"))
/// ])
/// ```
///
/// - Parameter value: The media to be considered.
/// - Parameter queries: The media to be considered.
///
/// - Returns: The element
func media(_ value: String) -> Self
func media(_ queries: [MediaQuery]) -> Self


/// Specify the media the ressource is optimized for.
///
/// ```swift
/// Link()
/// .reference("...css")
/// .media(
/// MediaQuery(target: .screen, features: .orientation(.portrait)),
/// MediaQuery(target: .print, features: .resolution("300dpi"))
/// )
/// ```
///
/// - Parameter queries: The media to be considered.
///
/// - Returns: The element
func media(_ queries: MediaQuery...) -> Self
}

extension MediaAttribute where Self: ContentNode {
Expand Down Expand Up @@ -3139,29 +3198,31 @@ extension SizeAttribute where Self: EmptyNode {
@_documentation(visibility: internal)
public protocol SizesAttribute: Attribute {

associatedtype SizesValueType

/// Describe different sizes for different viewport sizes.
///
/// ```swift
/// Link()
/// .sizes(16x16)
/// .sizes("16x16", "32x32")
/// ```
///
/// - Parameter size: The sizes to take into consideration.
/// - Parameter candidates: The sizes to take into consideration.
///
/// - Returns: The element
func sizes(_ size: Int) -> Self
func sizes(_ candidates: [SizesValueType]) -> Self
}

extension SizesAttribute where Self: ContentNode {

internal func mutate(sizes value: Int) -> Self {
internal func mutate(sizes value: String) -> Self {
return self.mutate(key: "sizes", value: value)
}
}

extension SizesAttribute where Self: EmptyNode {

internal func mutate(sizes value: Int) -> Self {
internal func mutate(sizes value: String) -> Self {
return self.mutate(key: "sizes", value: value)
}
}
Expand Down Expand Up @@ -4062,21 +4123,33 @@ extension LoadingAttribute where Self: EmptyNode {
@_documentation(visibility: internal)
public protocol SourceSetAttribute: Attribute {

/// Set a source set for a picture element.
/// Define a set of sources for a picture element.
///
/// ```swift
/// Picture {
/// Source()
/// .sourceSet("https://...")
/// .sourceSet([SourceCandidate("...webp", width: 1024), SourceCandidate("...webp", width: 1680)])
/// }
/// ```
///
/// - Parameter candidates: The candidates to choose from.
///
/// - Returns: The element.
func sourceSet(_ candidates: [SourceCandidate]) -> Self

/// Define a set of sources for a picture element.
///
/// ```swift
/// Picture {
/// Source()
/// .sourceSet("https://...")
/// .sourceSet(SourceCandidate("...webp", width: 1024), SourceCandidate("...webp", width: 1680))
/// }
/// ```
///
/// - Parameter url: The url path to load from.
/// - Parameter candidates: The candidates to choose from.
///
/// - Returns: The element.
func sourceSet(_ url: String) -> Self
func sourceSet(_ candidates: SourceCandidate...) -> Self
}

extension SourceSetAttribute where Self: ContentNode {
Expand Down
Loading