From a7f40efba90da0a2453fa41db078d0b063249944 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Sat, 10 Jan 2026 20:37:57 -0500 Subject: [PATCH] feat: Updates button styles. --- Sources/ViewController/Live.swift | 1 - .../EffectiveLengthsView.swift | 9 ++-- .../Views/Project/ProjectsTable.swift | 47 ++++++++++++------- .../Views/Rooms/RoomsView.swift | 4 +- 4 files changed, 39 insertions(+), 22 deletions(-) diff --git a/Sources/ViewController/Live.swift b/Sources/ViewController/Live.swift index 2147e24..89aae50 100644 --- a/Sources/ViewController/Live.swift +++ b/Sources/ViewController/Live.swift @@ -92,7 +92,6 @@ extension SiteRoute.View.ProjectRoute { func renderView(on request: ViewController.Request) async -> AnySendableHTML { @Dependency(\.database) var database - // let user = try request.currentUser() switch self { case .index: diff --git a/Sources/ViewController/Views/EffectiveLength/EffectiveLengthsView.swift b/Sources/ViewController/Views/EffectiveLength/EffectiveLengthsView.swift index 7266092..c235c8d 100644 --- a/Sources/ViewController/Views/EffectiveLength/EffectiveLengthsView.swift +++ b/Sources/ViewController/Views/EffectiveLength/EffectiveLengthsView.swift @@ -29,7 +29,10 @@ struct EffectiveLengthsView: HTML, Sendable { Row { h1(.class("text-2xl font-bold")) { "Equivalent Lengths" } PlusButton() - .attributes(.showModal(id: EffectiveLengthForm.id(nil))) + .attributes( + .class("btn-ghost"), + .showModal(id: EffectiveLengthForm.id(nil)) + ) } .attributes(.class("pb-6")) @@ -131,7 +134,7 @@ struct EffectiveLengthsView: HTML, Sendable { div(.class("join")) { TrashButton() .attributes( - .class("join-item"), + .class("join-item btn-ghost"), .hx.delete( route: .project( .detail( @@ -146,7 +149,7 @@ struct EffectiveLengthsView: HTML, Sendable { ) EditButton() .attributes( - .class("join-item"), + .class("join-item btn-ghost"), .showModal(id: EffectiveLengthForm.id(effectiveLength)) ) } diff --git a/Sources/ViewController/Views/Project/ProjectsTable.swift b/Sources/ViewController/Views/Project/ProjectsTable.swift index 3b07562..4af3e42 100644 --- a/Sources/ViewController/Views/Project/ProjectsTable.swift +++ b/Sources/ViewController/Views/Project/ProjectsTable.swift @@ -19,12 +19,10 @@ struct ProjectsTable: HTML, Sendable { div(.class("m-6")) { Row { h1(.class("text-2xl font-bold")) { "Projects" } - div( - .class("tooltip tooltip-left"), - .data("tip", value: "Add project") - ) { + Tooltip("Add project") { PlusButton() .attributes( + .class("btn-ghost"), .showModal(id: ProjectForm.id) ) } @@ -56,25 +54,42 @@ extension ProjectsTable { struct Rows: HTML, Sendable { let projects: Page + func tooltipPosition(_ n: Int) -> TooltipPosition { + if projects.metadata.page == 1 && projects.items.count == 1 { + return .left + } else if n == (projects.items.count - 1) { + return .left + } else { + return .bottom + } + } + var body: some HTML { - for project in projects.items { + for (n, project) in projects.items.enumerated() { tr(.id("\(project.id)")) { td { DateView(project.createdAt) } td { "\(project.name)" } td { "\(project.streetAddress)" } td { div(.class("flex justify-end space-x-6")) { - TrashButton() - .attributes( - .hx.delete(route: .project(.delete(id: project.id))), - .hx.confirm("Are you sure?"), - .hx.target("closest tr") - ) - a( - .class("btn btn-success btn-circle dark:text-white"), - .href(route: .project(.detail(project.id, .index()))) - ) { - SVG(.chevronRight) + div(.class("join")) { + Tooltip("Delete project", position: tooltipPosition(n)) { + TrashButton() + .attributes( + .class("join-item btn-ghost"), + .hx.delete(route: .project(.delete(id: project.id))), + .hx.confirm("Are you sure?"), + .hx.target("closest tr") + ) + } + Tooltip("View project", position: tooltipPosition(n)) { + a( + .class("join-item btn btn-success btn-ghost"), + .href(route: .project(.detail(project.id, .index()))) + ) { + SVG(.chevronRight) + } + } } } } diff --git a/Sources/ViewController/Views/Rooms/RoomsView.swift b/Sources/ViewController/Views/Rooms/RoomsView.swift index 0d33391..f807c35 100644 --- a/Sources/ViewController/Views/Rooms/RoomsView.swift +++ b/Sources/ViewController/Views/Rooms/RoomsView.swift @@ -33,7 +33,7 @@ struct RoomsView: HTML, Sendable { Tooltip("Edit SHR") { EditButton() - .attributes(.showModal(id: SHRForm.id)) + .attributes(.class("btn-ghost"), .showModal(id: SHRForm.id)) } } .attributes(.class("m-4")) @@ -55,7 +55,7 @@ struct RoomsView: HTML, Sendable { Tooltip("Add Room") { PlusButton() .attributes( - .class("mx-auto"), + .class("btn-ghost mx-auto"), .showModal(id: RoomForm.id()) ) }