Skip to content

Commit

Permalink
Merge pull request #212 from JPToroDev/length-unit
Browse files Browse the repository at this point in the history
Improve `LengthUnit` API.
  • Loading branch information
twostraws authored Jan 4, 2025
2 parents 6508afb + 6e400c7 commit 88c1258
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions Sources/Ignite/Framework/LengthUnit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@

/// Represents a CSS length value with its unit of measurement
public enum LengthUnit: Hashable, Equatable, Sendable, CustomStringConvertible, Defaultable {
/// Pixels (px)
/// Pixels
case px(Double)
/// Relative to root element font size (rem)
/// Relative to root element font size
case rem(Double)
/// Relative to parent element font size (em)
/// Relative to parent element font size
case em(Double)
/// Percentage (%)
/// Relative to the parent element
case percent(Percentage)
/// Viewport width unit (vw)
case vw(Double)
/// Viewport height unit (vh)
case vh(Double)
/// Relative to 1% of the viewport width
case vw(Percentage)
/// Relative to 1% of the viewport height
case vh(Percentage)

public var description: String {
switch self {
case .px(let value): "\(value)px"
case .rem(let value): "\(value)rem"
case .em(let value): "\(value)em"
case .percent(let percentage): "\(percentage.value)%"
case .vw(let value): "\(value)vw"
case .vh(let value): "\(value)vh"
case .vw(let percentage): "\(percentage.value)vw"
case .vh(let percentage): "\(percentage.value)vh"
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Ignite/Modifiers/Frame.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct FrameModifier: HTMLModifier {
guard let value else { return }

switch value {
case .vh(100), .vw(100):
case .vh(100%), .vw(100%):
classes.append(dimension.viewportClass)
if dimension.needsFlexAlignment {
classes.append("d-flex")
Expand Down

0 comments on commit 88c1258

Please sign in to comment.