lexa_framework/view/layouts/
empty.rs

1// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2// ┃ Copyright: (c) 2023, Mike 'PhiSyX' S. (https://github.com/PhiSyX)         ┃
3// ┃ SPDX-License-Identifier: MPL-2.0                                          ┃
4// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
5// ┃                                                                           ┃
6// ┃  This Source Code Form is subject to the terms of the Mozilla Public      ┃
7// ┃  License, v. 2.0. If a copy of the MPL was not distributed with this      ┃
8// ┃  file, You can obtain one at https://mozilla.org/MPL/2.0/.                ┃
9// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
10
11use lexa_framework_macro::html;
12
13use crate::view::{Node, ViewLayoutInterface};
14
15// --------- //
16// Structure //
17// --------- //
18
19/// Mise en page HTML vide.
20pub struct EmptyHTMLLayout {
21	body: Node,
22}
23
24// -------------- //
25// Implémentation // -> Interface
26// -------------- //
27
28impl ViewLayoutInterface for EmptyHTMLLayout {
29	type Metadata = Node;
30	type Scripts = Node;
31	type Styles = Node;
32	type View = Node;
33
34	fn new() -> Self
35	where
36		Self: Sized,
37	{
38		Self {
39			body: Default::default(),
40		}
41	}
42
43	fn set_title(&mut self, _: impl ToString) {}
44
45	fn set_body(&mut self, body: Self::View) {
46		self.body = body;
47	}
48
49	fn add_meta(&mut self, _: Self::Metadata) {}
50
51	fn add_script(&mut self, _: Self::Scripts) {}
52
53	fn add_style(&mut self, _: Self::Styles) {}
54
55	fn view(&self) -> Self::View {
56		html! {
57			{ unsafe &self.body }
58		}
59	}
60}