1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#![allow(non_snake_case)]
use dioxus::prelude::*;
#[derive(Props, Clone, PartialEq)]
pub struct AppLayoutProps {
title: String,
fav_icon_src: Option<String>,
stylesheets: Vec<String>,
js_href: Option<String>,
header: Element,
children: Element,
sidebar: Element,
sidebar_footer: Element,
sidebar_header: Element,
}
pub fn AppLayout(props: AppLayoutProps) -> Element {
rsx!(
head {
title {
"{props.title}"
}
meta {
charset: "utf-8"
}
meta {
"http-equiv": "X-UA-Compatible",
content: "IE=edge"
}
meta {
name: "viewport",
content: "width=device-width, initial-scale=1"
}
for href in &props.stylesheets {
link {
rel: "stylesheet",
href: "{href}",
"type": "text/css"
}
}
if let Some(js_href) = props.js_href {
script {
"type": "module",
src: "{js_href}"
}
}
if let Some(fav_icon_src) = props.fav_icon_src {
link {
rel: "icon",
"type": "image/svg+xml",
href: "{fav_icon_src}"
}
}
}
body {
div {
class: "flex h-screen overflow-hidden",
nav {
id: "sidebar",
class: "
border-r border-base-300
fixed
bg-base-200
inset-y-0
left-0
w-64
transform
-translate-x-full
transition-transform
duration-200
ease-in-out
flex
flex-col
lg:translate-x-0
lg:static
lg:inset-auto
lg:transform-none
z-20",
div {
class: "flex items-center p-4",
{props.sidebar_header}
}
div {
class: "flex-1 overflow-y-auto",
{props.sidebar}
}
div {
class: "p-4",
{props.sidebar_footer}
}
}
main {
id: "main-content",
class: "flex-1 flex flex-col",
header {
class: "flex items-center p-4 border-b border-base-300",
button {
id: "toggleButton",
svg {
xmlns: "http://www.w3.org/2000/svg",
width: "24",
height: "24",
view_box: "0 0 24 24",
fill: "none",
stroke: "currentColor",
stroke_width: "2",
stroke_linecap: "round",
stroke_linejoin: "round",
class: "lucide lucide-panel-left",
rect {
width: "18",
height: "18",
x: "3",
y: "3",
rx: "2",
}
path {
d: "M9 3v18",
}
}
}
{props.header}
}
section {
class: "flex-1 overflow-y-auto",
{props.children}
}
}
}
}
)
}