feat: Initial filter pressure drop views, calculations need implemented.

This commit is contained in:
2025-03-02 21:51:52 -05:00
parent a8022ec80a
commit 67488e06a9
17 changed files with 610 additions and 97 deletions

View File

@@ -50,7 +50,7 @@ public struct Input: HTML, Sendable {
input(
.id(id), .placeholder(placeholder), .name(name ?? id),
.class("""
w-full px-4 py-2 border rounded-md
w-full px-4 py-2 border rounded-md min-h-11
focus:ring-2 focus:ring-yellow-800 focus:border-yellow-800
placeholder-shown:!border-gray-400
invalid:border-red-500 out-of-range:border-red-500
@@ -84,3 +84,57 @@ public struct InputLabel<InputLabel: HTML>: HTML {
}
extension InputLabel: Sendable where InputLabel: Sendable {}
public struct Select<T>: HTML {
let id: String
let name: String?
let values: [T]
let label: @Sendable (T) -> String
let value: @Sendable (T) -> String
public init(
id: String,
name: String? = nil,
values: [T],
label: @escaping @Sendable (T) -> String,
value: @escaping @Sendable (T) -> String
) {
self.id = id
self.name = name
self.values = values
self.label = label
self.value = value
}
public var content: some HTML<HTMLTag.select> {
select(
.id(id),
.name(name ?? id),
.class("w-full rounded-md border px-4 py-2 min-h-11")
) {
for value in values {
option(.value(self.value(value))) { label(value) }
}
}
}
}
extension Select: Sendable where T: Sendable {}
public extension Select where T: CaseIterable, T: RawRepresentable, T.RawValue: CustomStringConvertible {
init(
for type: T.Type,
id: String,
name: String? = nil,
label: @escaping @Sendable (T) -> String
) {
self.init(
id: id,
name: name,
values: Array(T.allCases),
label: label,
value: { $0.rawValue.description }
)
}
}