From 980d99e40b7c292553084202a15e5b223da92e6b Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Mon, 9 Feb 2026 16:58:28 -0500 Subject: [PATCH] feat: Adds ductulator button to logged in views. --- Public/css/output.css | 28 --------- .../Views/Ductulator/DuctulatorView.swift | 4 +- Sources/ViewController/Views/Navbar.swift | 60 +++++++++++-------- .../Views/Project/ProjectView.swift | 2 +- .../Views/Project/ProjectsTable.swift | 2 +- Sources/ViewController/Views/TestPage.swift | 2 +- .../ViewController/Views/User/UserView.swift | 2 +- TODO.md | 9 ++- .../ViewControllerTests/ductulator.1.html | 7 ++- .../ViewControllerTests/projectDetail.1.html | 21 ++++--- .../ViewControllerTests/projectDetail.2.html | 21 ++++--- .../ViewControllerTests/projectDetail.3.html | 21 ++++--- .../ViewControllerTests/projectDetail.4.html | 21 ++++--- .../ViewControllerTests/projectDetail.5.html | 21 ++++--- .../ViewControllerTests/projectDetail.6.html | 21 ++++--- .../ViewControllerTests/projectIndex.1.html | 21 ++++--- .../ViewControllerTests/userProfile.1.html | 7 ++- 17 files changed, 148 insertions(+), 122 deletions(-) diff --git a/Public/css/output.css b/Public/css/output.css index f0a018d..84b660b 100644 --- a/Public/css/output.css +++ b/Public/css/output.css @@ -13,8 +13,6 @@ --color-black: #000; --color-white: #fff; --spacing: 0.25rem; - --container-lg: 32rem; - --container-xl: 36rem; --text-xs: 0.75rem; --text-xs--line-height: calc(1 / 0.75); --text-sm: 0.875rem; @@ -5305,15 +5303,9 @@ .-mx-2 { margin-inline: calc(var(--spacing) * -2); } - .-mx-4 { - margin-inline: calc(var(--spacing) * -4); - } .mx-10 { margin-inline: calc(var(--spacing) * 10); } - .mx-20 { - margin-inline: calc(var(--spacing) * 20); - } .mx-auto { margin-inline: auto; } @@ -5403,18 +5395,12 @@ } } } - .-my-4 { - margin-block: calc(var(--spacing) * -4); - } .my-1\.5 { margin-block: calc(var(--spacing) * 1.5); } .my-6 { margin-block: calc(var(--spacing) * 6); } - .my-8 { - margin-block: calc(var(--spacing) * 8); - } .my-auto { margin-block: auto; } @@ -5687,15 +5673,9 @@ .mt-6 { margin-top: calc(var(--spacing) * 6); } - .mt-8 { - margin-top: calc(var(--spacing) * 8); - } .mt-10 { margin-top: calc(var(--spacing) * 10); } - .mt-20 { - margin-top: calc(var(--spacing) * 20); - } .mt-30 { margin-top: calc(var(--spacing) * 30); } @@ -6556,9 +6536,6 @@ .min-h-14 { min-height: calc(var(--spacing) * 14); } - .min-h-\[400px\] { - min-height: 400px; - } .min-h-screen { min-height: 100vh; } @@ -9745,11 +9722,6 @@ } } } - .md\:mt-6 { - @media (width >= 48rem) { - margin-top: calc(var(--spacing) * 6); - } - } .md\:mt-15 { @media (width >= 48rem) { margin-top: calc(var(--spacing) * 15); diff --git a/Sources/ViewController/Views/Ductulator/DuctulatorView.swift b/Sources/ViewController/Views/Ductulator/DuctulatorView.swift index e5f1b95..77fdb8b 100644 --- a/Sources/ViewController/Views/Ductulator/DuctulatorView.swift +++ b/Sources/ViewController/Views/Ductulator/DuctulatorView.swift @@ -17,8 +17,8 @@ struct DuctulatorView: HTML, Sendable { var body: some HTML { div { Navbar( - sidebarToggle: false, - userProfile: isLoggedIn + showSidebarToggle: false, + isLoggedIn: isLoggedIn ) div(.class("flex justify-center items-center px-10")) { div( diff --git a/Sources/ViewController/Views/Navbar.swift b/Sources/ViewController/Views/Navbar.swift index feefafe..8257087 100644 --- a/Sources/ViewController/Views/Navbar.swift +++ b/Sources/ViewController/Views/Navbar.swift @@ -3,19 +3,19 @@ import ManualDCore import Styleguide struct Navbar: HTML, Sendable { - let sidebarToggle: Bool - let userProfile: Bool + let showSidebarToggle: Bool + let isLoggedIn: Bool init( - sidebarToggle: Bool, - userProfile: Bool = true + showSidebarToggle: Bool, + isLoggedIn: Bool = true ) { - self.sidebarToggle = sidebarToggle - self.userProfile = userProfile + self.showSidebarToggle = showSidebarToggle + self.isLoggedIn = isLoggedIn } var homeRoute: SiteRoute.View { - if userProfile { + if isLoggedIn { return .project(.index) } return .home @@ -30,7 +30,7 @@ struct Navbar: HTML, Sendable { ) ) { div(.class("flex flex-1 space-x-4 items-center")) { - if sidebarToggle { + if showSidebarToggle { label( .for("my-drawer-1"), .class("size-7"), @@ -43,7 +43,7 @@ struct Navbar: HTML, Sendable { } a( - .class("flex w-fit h-fit text-xl items-end px-4 py-2"), + .class("flex w-fit h-fit text-2xl items-end px-4 py-2"), .href(route: homeRoute) ) { img( @@ -52,23 +52,33 @@ struct Navbar: HTML, Sendable { span { "Duct Calc" } } .navButton() - .tooltip("Home", position: .right) + .tooltip(isLoggedIn ? "Projects" : "Home", position: .right) } - if userProfile { - div(.class("flex-none dropdown dropdown-end dropdown-hover")) { - div(.class("btn m-1"), .tabindex(0), .role("button")) { - SVG(.circleUser) - } - .navButton() - ul( - .tabindex(-1), - .class("dropdown-content menu bg-base-200 rounded-box z-1 w-52 py-2 shadow-sm") - ) { - li { - a(.href(route: .user(.profile(.index)))) { "Profile" } - } - li { - a(.href(route: .user(.logout))) { "Logout" } + + div(.class("flex-none")) { + div(.class("flex items-end space-x-4")) { + + DuctulatorButton() + .attributes(.class("btn-ghost btn-primary text-lg")) + .tooltip("Duct size calculator", position: .left) + + if isLoggedIn { + div(.class("dropdown dropdown-end dropdown-hover")) { + div(.class("btn m-1"), .tabindex(0), .role("button")) { + SVG(.circleUser) + } + .navButton() + ul( + .tabindex(-1), + .class("dropdown-content menu bg-base-200 rounded-box z-1 w-52 py-2 shadow-sm") + ) { + li { + a(.href(route: .user(.profile(.index)))) { "Profile" } + } + li { + a(.href(route: .user(.logout))) { "Logout" } + } + } } } } diff --git a/Sources/ViewController/Views/Project/ProjectView.swift b/Sources/ViewController/Views/Project/ProjectView.swift index 73e6a12..e086e21 100644 --- a/Sources/ViewController/Views/Project/ProjectView.swift +++ b/Sources/ViewController/Views/Project/ProjectView.swift @@ -35,7 +35,7 @@ struct ProjectView: HTML, Sendable where Inner: Sendable { input(.id("my-drawer-1"), .type(.checkbox), .class("drawer-toggle")) div(.class("drawer-content overflow-auto")) { - Navbar(sidebarToggle: true) + Navbar(showSidebarToggle: true) div(.class("p-4")) { inner .environment(ProjectViewValue.$projectID, projectID) diff --git a/Sources/ViewController/Views/Project/ProjectsTable.swift b/Sources/ViewController/Views/Project/ProjectsTable.swift index 375a4b2..623a89e 100644 --- a/Sources/ViewController/Views/Project/ProjectsTable.swift +++ b/Sources/ViewController/Views/Project/ProjectsTable.swift @@ -17,7 +17,7 @@ struct ProjectsTable: HTML, Sendable { var body: some HTML { div { - Navbar(sidebarToggle: false) + Navbar(showSidebarToggle: false) div(.class("m-6")) { PageTitleRow { PageTitle { "Projects" } diff --git a/Sources/ViewController/Views/TestPage.swift b/Sources/ViewController/Views/TestPage.swift index b979360..c5c0cde 100644 --- a/Sources/ViewController/Views/TestPage.swift +++ b/Sources/ViewController/Views/TestPage.swift @@ -10,7 +10,7 @@ struct TestPage: HTML, Sendable { var body: some HTML { div { - Navbar(sidebarToggle: false, userProfile: false) + Navbar(showSidebarToggle: false, isLoggedIn: false) div(.class("flex justify-center items-center px-10")) { div( .class( diff --git a/Sources/ViewController/Views/User/UserView.swift b/Sources/ViewController/Views/User/UserView.swift index c5addde..60893f0 100644 --- a/Sources/ViewController/Views/User/UserView.swift +++ b/Sources/ViewController/Views/User/UserView.swift @@ -8,7 +8,7 @@ struct UserView: HTML, Sendable { var body: some HTML { div { - Navbar(sidebarToggle: false, userProfile: false) + Navbar(showSidebarToggle: false, isLoggedIn: false) div(.class("p-4")) { Row { diff --git a/TODO.md b/TODO.md index 8c53de0..0b499bf 100644 --- a/TODO.md +++ b/TODO.md @@ -4,16 +4,15 @@ - [x] Pdf generation - [x] Add postgres / mysql support - [x] Opensource / license ?? -- [ ] Figure out domain to host (currently thinking ductcalc.pro) - - [ ] Logo / navbar name may have to change if it's not duct-calc. - - [ ] MainPage meta items will have to change also +- [x] Figure out domain to host (currently thinking ductcalc.pro) - [x] Add ability for either sensible or total load while specifying a room load. - CoolCalc current version specifies the sensible cooling for a room break down, and currently we require the total load and calculate sensible based on project shr. - [x] Add ability to associate room load / airflow with another room. -- [ ] Trunk size form, room / register selection is wonky when labels are long. +- [x] Trunk size form, room / register selection is wonky when labels are long. - They will overlap each other making it difficult to read / decipher which checkbox belongs to which label. -- [ ] Add select all rooms for trunks, useful for sizing main supply or return trunks. +- [x] Add select all rooms for trunks, useful for sizing main supply or return trunks. +- [ ] Add optional level to room model. - [ ] Add way to sponsor the project. diff --git a/Tests/ViewControllerTests/__Snapshots__/ViewControllerTests/ductulator.1.html b/Tests/ViewControllerTests/__Snapshots__/ViewControllerTests/ductulator.1.html index 3183b1a..1890195 100644 --- a/Tests/ViewControllerTests/__Snapshots__/ViewControllerTests/ductulator.1.html +++ b/Tests/ViewControllerTests/__Snapshots__/ViewControllerTests/ductulator.1.html @@ -35,11 +35,16 @@
- -