WIP: Begins creating some project views.
This commit is contained in:
@@ -11,14 +11,18 @@ public struct MainPage<Inner: HTML>: SendableHTMLDocument where Inner: Sendable
|
||||
|
||||
public var head: some HTML {
|
||||
meta(.charset(.utf8))
|
||||
meta(.name(.viewport), .content("width=device-width, initial-scale=1.0"))
|
||||
script(.src("https://unpkg.com/htmx.org@2.0.8")) {}
|
||||
script(.src("https://cdn.tailwindcss.com")) {}
|
||||
script(.src("/js/main.js")) {}
|
||||
link(.rel(.stylesheet), .href("/css/main.css"))
|
||||
link(.rel(.icon), .href("/images/favicon.ico"), .custom(name: "type", value: "image/x-icon"))
|
||||
}
|
||||
|
||||
public var body: some HTML {
|
||||
inner
|
||||
div(.class("bg-white dark:bg-gray-800 dark:text-white")) {
|
||||
inner
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
86
Sources/ViewController/Views/Project/ProjectForm.swift
Normal file
86
Sources/ViewController/Views/Project/ProjectForm.swift
Normal file
@@ -0,0 +1,86 @@
|
||||
import Elementary
|
||||
import ElementaryHTMX
|
||||
import ManualDCore
|
||||
|
||||
struct ProjectForm: HTML, Sendable {
|
||||
|
||||
let project: Project?
|
||||
|
||||
init(
|
||||
project: Project? = nil
|
||||
) {
|
||||
self.project = project
|
||||
}
|
||||
|
||||
var body: some HTML {
|
||||
// TODO: Add htmx attributes.
|
||||
div(.class("mx-20 my-20")) {
|
||||
form(.class("w-full max-w-sm")) {
|
||||
div(.class("flex items-center mb-6")) {
|
||||
label(
|
||||
.for("name"), .class("block text-gray-500 font-bold mr-4")
|
||||
) { "Name:" }
|
||||
input(
|
||||
.type(.text), .name("name"), .placeholder("Customer Name"),
|
||||
.value(project?.name ?? ""), .required, .autofocus
|
||||
)
|
||||
.defaultInput()
|
||||
}
|
||||
div(.class("flex items-center mb-6")) {
|
||||
label(.for("streetAddress"), .class("block text-gray-500 font-bold mr-4")) { "Address:" }
|
||||
input(
|
||||
.type(.text), .name("streetAddress"),
|
||||
.placeholder("Street Address"),
|
||||
.value(project?.streetAddress ?? ""),
|
||||
.required
|
||||
)
|
||||
.defaultInput()
|
||||
}
|
||||
// div(.class("w-full space-x-2")) {
|
||||
// label(.for("city")) { "City:" }
|
||||
//
|
||||
// input(
|
||||
// .type(.text), .name("city"),
|
||||
// .placeholder("City"),
|
||||
// .value(project?.city ?? ""),
|
||||
// .required
|
||||
// )
|
||||
// .defaultInput()
|
||||
// }
|
||||
// div(.class("w-full space-y-2")) {
|
||||
// label(.for("state")) { "State:" }
|
||||
// input(
|
||||
// .type(.text), .name("state"),
|
||||
// .placeholder("State"),
|
||||
// .value(project?.state ?? ""),
|
||||
// .required
|
||||
// )
|
||||
// .defaultInput()
|
||||
// }
|
||||
// div(.class("w-full space-y-2")) {
|
||||
// label(.for("zipCode")) {
|
||||
// "Zip:"
|
||||
// }
|
||||
// input(
|
||||
// .type(.text), .name("zipCode"),
|
||||
// .placeholder("Zip Code"),
|
||||
// .value(project?.zipCode ?? ""),
|
||||
// .required
|
||||
// )
|
||||
// .defaultInput()
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Move
|
||||
extension input {
|
||||
func defaultInput() -> some HTML<HTMLTag.input> {
|
||||
attributes(
|
||||
.class(
|
||||
"w-full rounded-md bg-white px-3 py-1.5 text-slate-900 outline-1 -outline-offset-1 outline-slate-300 focus:outline focus:-outline-offset-2 focus:outline-indigo-600"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user