feat: Refactoring climate zone.

This commit is contained in:
2025-03-03 15:52:34 -05:00
parent 8e0860af8e
commit 1727e9a905
6 changed files with 73 additions and 30 deletions

View File

@@ -1,33 +1,67 @@
public enum ClimateZone: String, CaseIterable, Codable, Equatable, Sendable {
// NOTE: Keep in this order.
// TODO: This should be renamed to ClimateZoneType.
case hotHumid
case moist
case dry
case marine
public enum ClimateZone {
public var zoneIdentifiers: [String] {
switch self {
case .dry:
return ["2B", "3B", "4B", "5B", "6B", "7B"]
case .hotHumid:
return ["1A", "2A"]
case .marine:
return ["3C", "4C"]
case .moist:
return ["3A", "4A", "5A", "6A", "7A"]
public enum ZoneType: String, CaseIterable, Codable, Equatable, Sendable {
// NOTE: Keep in this order.
case hotHumid
case moist
case dry
case marine
// FIX: Return ZoneIdentifiers.
public var zoneIdentifiers: [String] {
switch self {
case .dry:
return ["2B", "3B", "4B", "5B", "6B", "7B"]
case .hotHumid:
return ["1A", "2A"]
case .marine:
return ["3C", "4C"]
case .moist:
return ["3A", "4A", "5A", "6A", "7A"]
}
}
}
public var cfmPerTon: Int {
switch self {
case .dry: return 450
case .hotHumid: return 350
case .marine, .moist: return 400
public var cfmPerTon: Int {
switch self {
case .dry: return 450
case .hotHumid: return 350
case .marine, .moist: return 400
}
}
}
public var label: String {
return "\(self == .hotHumid ? "Hot Humid" : rawValue.capitalized) (\(zoneIdentifiers.joined(separator: ", ")))"
public var label: String {
return "\(self == .hotHumid ? "Hot Humid" : rawValue.capitalized) (\(zoneIdentifiers.joined(separator: ", ")))"
}
/// Represents climate zone identifiers.
public enum ZoneIdentifier: String, CaseIterable, Codable, Equatable, Sendable {
// A zones (hotHumid)
case oneA = "1A"
case twoA = "2A"
// A zones (moist)
case threeA = "3A"
case fourA = "4A"
case fiveA = "5A"
case sixA = "6A"
case sevenA = "7A"
// B zones (dry)
case twoB = "2B"
case threeB = "3B"
case fourB = "4B"
case fiveB = "5B"
case sixB = "6B"
case sevenB = "7B"
// C zones (marine)
case threeC = "3C"
case fourC = "4C"
public var label: String { rawValue }
}
}
}

View File

@@ -16,14 +16,14 @@ public enum FilterPressureDrop {
public struct Basic: Codable, Equatable, Sendable {
public let systemSize: Double
public let climateZone: ClimateZone
public let climateZone: ClimateZone.ZoneType
public let filterType: FilterType
public let filterWidth: Double
public let filterHeight: Double
public init(
systemSize: Double,
climateZone: ClimateZone,
climateZone: ClimateZone.ZoneType,
filterType: FilterPressureDrop.FilterType,
filterWidth: Double,
filterHeight: Double

View File

@@ -255,7 +255,7 @@ public extension SiteRoute {
OneOf {
FormData {
Field("systemSize") { Double.parser() }
Field("climateZone") { ClimateZone.parser() }
Field("climateZone") { ClimateZone.ZoneType.parser() }
Field("filterType") { Routes.FilterPressureDrop.FilterType.parser() }
Field("filterWidth") { Double.parser() }
Field("filterHeight") { Double.parser() }

View File

@@ -11,6 +11,14 @@ struct MainPage<Inner: HTML>: SendableHTMLDocument where Inner: Sendable {
var head: some HTML {
meta(.charset(.utf8))
meta(.name("viewport"), .content("width=device-width, initial-scale=1.0"))
meta(.name("author"), .content("Michael Housh and Dustin Cole"))
meta(.name("og:site-name"), .content("HVAC-Toolbox"))
meta(.name("apple-mobile-web-app-title"), .content("HVAC-Toolbox"))
meta(.name("format-detection"), .content("telephone=no"))
meta(.name("HandheldFriendly"), .content("True"))
meta(.name("MobileOptimized"), .content("320"))
meta(.name("keywords"), .content("hvac, HVAC, design, system-design, calculators"))
Elementary.title { self.title }
link(.rel(.stylesheet), .href("/output.css"))
link(
.rel(.icon),

View File

@@ -62,7 +62,7 @@ struct FilterPressureDropForm: HTML, Sendable {
}
div {
InputLabel(for: "climateZone") { "Climate Zone" }
Select(for: ClimateZone.self, id: "climateZone") {
Select(for: ClimateZone.ZoneType.self, id: "climateZone") {
$0.label
}
}

View File

@@ -21,4 +21,5 @@ clean:
push-image:
@docker push {{docker_registiry}}/{{docker_image}}:{{docker_tag}}
build-and-push: (build-docker "linux/amd64") push-image
build-docker-production:
@docker build --platform "linux/amd64" -t {{docker_registiry}}/{{docker_image}}:{{docker_tag}} .