Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend the environment #156

Merged
merged 16 commits into from
Jan 10, 2025
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
42 changes: 42 additions & 0 deletions Sources/HTMLKit/Framework/Environment/Condition.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/// A type representing a conditional that compares an environment value against another value
@_documentation(visibility: internal)
public struct Condition {

/// A enumeration of potential comparison
public enum Comparison {

/// Indicates an equal comparison
case equal

/// Indicates a not-equal comparison
case unequal

/// Indicates a greater-than comparison
case greater

/// Indicates a less-than comparison
case less
}

/// The left-hand side value
internal let lhs: EnvironmentValue

/// The right-hand side value to test against
internal let rhs: any Comparable

/// The comparison to perfom
internal let comparison: Comparison

/// Initializes a condition
///
/// - Parameters:
/// - lhs: The origin value
/// - rhs: The value to atest against
/// - operation: The comparison to perfom
public init(lhs: EnvironmentValue, rhs: any Comparable, comparison: Comparison) {

self.lhs = lhs
self.rhs = rhs
self.comparison = comparison
}
}
19 changes: 19 additions & 0 deletions Sources/HTMLKit/Framework/Environment/Conditional.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// A type that defines a conditonal value which will be evualuated by the renderer.
@_documentation(visibility: internal)
public indirect enum Conditional {

/// Holds an optional
case optional(EnvironmentValue)

/// Holds an relation
case relation(Relation)

/// Holds a condition
case condition(Condition)

/// Holds a negation
case negation(Negation)

/// Holds a value
case value(EnvironmentValue)
}
Loading
Loading