Files
LazyPM/pkg/web/components/layout.templ
2026-02-25 11:53:56 +01:00

64 lines
1.2 KiB
Plaintext

package components
templ Layout(props LayoutProps) {
<!DOCTYPE html>
<html lang="en" data-theme="corporate">
<head>
<meta charset="UTF-8"/>
<title>{ props.Title }</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content={ props.Description }/>
@Head(props.Head)
</head>
<body class="h-screen overflow-auto">
@Header(props.Header)
<div class="flex">
//@Sidebar(props.Routes) Hidden until we need it
<main class="flex-1 p-1 overflow-auto">
{ children... }
</main>
@props.Modal
</div>
</body>
</html>
}
type LayoutProps struct {
Title string
Description string
Head HeadProps
Header HeaderProps
Routes []NavRoutes
Modal templ.Component
}
type NavRoutes struct {
Name string
Path string
Icon templ.Component
}
templ Head(props HeadProps) {
for _, link := range props.Links {
<link href={ link.Href } rel={ link.Rel } as={ link.As }/>
}
for _, script := range props.Scripts {
<script src={ script.Src } defer={ script.Defer }></script>
}
}
type HeadProps struct {
Links []Link
Scripts []Script
}
type Link struct {
Href string
Rel string
As string
}
type Script struct {
Src string
Defer bool
}