feat: Adds ductulator button to logged in views.
All checks were successful
CI / Linux Tests (push) Successful in 5m46s
All checks were successful
CI / Linux Tests (push) Successful in 5m46s
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ struct ProjectView<Inner: HTML>: 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)
|
||||
|
||||
@@ -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" }
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user