Skip to content

Commit e9c271d

Browse files
authored
Merge pull request #30 from sertschgi/dev
Fixed new and edit with formify
2 parents 2e50311 + b1bf7e2 commit e9c271d

10 files changed

Lines changed: 103 additions & 29 deletions

File tree

packages/frontend/assets/style/entry.css

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ section {
4444
flex-grow: 1;
4545
}
4646

47+
.Page {
48+
justify-content: center;
49+
align-items: center;
50+
}
51+
4752
#main,
4853
main {
4954
display: flex;
@@ -206,20 +211,23 @@ input[type="range"]::-webkit-slider-thumb:focus {
206211
}
207212

208213
.FormifyForm {
209-
flex-grow: 1;
214+
margin: auto;
215+
align-items: end;
216+
width: 100%;
217+
max-width: 50rem;
218+
max-height: 80%;
219+
box-sizing: border-box;
220+
gap: 1rem;
210221
}
211222

212223
.FormifyInputs {
213-
width: 80%;
224+
width: 100%;
214225
display: flex;
215226
flex-direction: column;
216227
gap: 1rem;
217228
}
218229

219230
.FormifyButton {
220-
margin: auto;
221-
height: 8rem;
222-
width: 8rem;
223231
border-radius: 5rem;
224232
}
225233

@@ -228,7 +236,6 @@ input[type="range"]::-webkit-slider-thumb:focus {
228236
box-sizing: border-box;
229237
align-items: center;
230238
gap: 1rem;
231-
padding: 0.5rem;
232239
}
233240

234241
.FormifyText {

packages/frontend/assets/style/pages/edit.css

Whitespace-only changes.

packages/frontend/assets/style/pages/new.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
.New {
2-
display: flex;
3-
}
41
/**/
52
/* .New .LabeledBox { */
63
/* width: 100%; */

packages/frontend/src/modules/components/project.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn Project(name: String, date: DateTime<Utc>, desc: String) -> Element {
1515
div { class: "divider" }
1616
section { class: "actions",
1717
Link { to: Route::ProjectNav {}, class: "open", FolderOpenIcon {} }
18-
Link { to: Route::Editor {}, class: "edit", SettingsIcon {} }
18+
Link { to: Route::Edit {}, class: "edit", SettingsIcon {} }
1919
Link { to: Route::Editor {}, class: "delete", TrashIcon {} }
2020
}
2121
}

packages/frontend/src/modules/pages.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// %%% pages.rs %%%
22

33
// %% exports %%
4+
pub mod edit;
45
pub mod editor;
56
pub mod new;
67
pub mod project_nav;
@@ -10,6 +11,7 @@ pub mod start;
1011

1112
// %% prelude %%
1213
pub mod prelude {
14+
pub use super::edit::Edit;
1315
pub use super::editor::Editor;
1416
pub use super::new::New;
1517
pub use super::project_nav::ProjectNav;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use super::utils::*;
2+
3+
#[derive(Formifiable)]
4+
pub struct Project {
5+
pub name: String,
6+
pub description: String,
7+
}
8+
9+
#[page]
10+
pub fn Edit() -> Element {
11+
let mut proj = Project {
12+
name: "".into(),
13+
description: "".into(),
14+
};
15+
rsx! {
16+
main {
17+
{proj.rsx_edit_form(|e| { debug!("editing {:?}", e) })}
18+
// form {
19+
// LabeledBox {
20+
// name: "name",
21+
// kind: "text",
22+
// required: true,
23+
// placeholder: "SampleProject",
24+
// }
25+
// LabeledBox {
26+
// name: "description",
27+
// kind: "text",
28+
// required: false,
29+
// placeholder: "this is a description",
30+
// }
31+
// section { class: "button-wrapper",
32+
// button { r#type: "submit", NewIcon {} }
33+
// }
34+
// }
35+
}
36+
}
37+
}

packages/frontend/src/modules/pages/editor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const CREATE_VIEWPORT: &str = r#"
1414
// -> convert to Node of backend (serde json)
1515
// -> add something like simple_ai_backend :: onnx :: Project . save_nodes(Vec<Nodes>)
1616
#[page]
17-
pub fn Editor() -> Element {
17+
pub fn Editor(children: Element) -> Element {
1818
rsx! {
1919
main {
2020
onmounted: move |e| async move {

packages/frontend/src/modules/pages/new.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn New() -> Element {
1414
};
1515
rsx! {
1616
main {
17-
{proj.rsx_form()}
17+
{proj.rsx_creation_form(|e| { debug!("creating {:?}", e) })}
1818
// form {
1919
// LabeledBox {
2020
// name: "name",

packages/frontend/src/modules/router.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@ pub mod core {
1111
#[layout(TopNavLayout)]
1212
#[route("/")]
1313
Start {},
14-
#[nest("/editor")]
15-
#[route("/")]
16-
Editor {},
1714
#[end_nest]
18-
#[layout(HeadingLayout)]
1915
#[nest("/projects")]
16+
#[layout(HeadingLayout)]
2017
#[route("/")]
2118
Projects {},
2219
#[route("/projects_nav")]
2320
ProjectNav {},
21+
#[route("/edit")]
22+
Edit {},
23+
#[end_layout]
24+
#[route("/editor")]
25+
Editor {},
2426
#[end_nest]
27+
#[layout(HeadingLayout)]
2528
#[nest("/new")]
2629
#[route("/")]
2730
New {},

packages/macros/src/formifiable.rs

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,52 @@ pub fn macro_impl(item: TokenStream) -> TokenStream {
2727
.to_tokens(&mut inputs);
2828
}
2929
quote! {
30-
use dioxus::prelude::*;
31-
impl #struct_ident {
32-
pub fn rsx_form(&mut self) -> Element {
33-
rsx! {
34-
form {
35-
class: "FormifyForm",
30+
simple_ai_macros::icon! {
31+
formify_creation: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M13.0001 10.9999L22.0002 10.9997L22.0002 12.9997L13.0001 12.9999L13.0001 21.9998L11.0001 21.9998L11.0001 12.9999L2.00004 13.0001L2 11.0001L11.0001 10.9999L11 2.00025L13 2.00024L13.0001 10.9999Z"></path></svg>,
32+
formify_edit: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M15.7279 9.57627L14.3137 8.16206L5 17.4758V18.89H6.41421L15.7279 9.57627ZM17.1421 8.16206L18.5563 6.74785L17.1421 5.33363L15.7279 6.74785L17.1421 8.16206ZM7.24264 20.89H3V16.6473L16.435 3.21231C16.8256 2.82179 17.4587 2.82179 17.8492 3.21231L20.6777 6.04074C21.0682 6.43126 21.0682 7.06443 20.6777 7.45495L7.24264 20.89Z"></path></svg>
33+
}
34+
use dioxus::prelude::*;
35+
impl #struct_ident {
36+
pub fn rsx_creation_form(&mut self, oncreate: fn(dioxus::html::events::FormEvent)) -> Element {
37+
rsx! {
38+
form {
39+
class: "FormifyForm FormifyCreation",
40+
onsubmit: oncreate,
41+
42+
div {
43+
class: "FormifyInputs",
44+
#inputs
45+
}
46+
47+
button {
48+
class: "FormifyButton",
49+
r#type: "submit",
50+
FormifyCreationIcon {}
51+
}
52+
}
53+
}
54+
}
55+
56+
pub fn rsx_edit_form(&mut self, onedit: fn(dioxus::html::events::FormEvent)) -> Element {
57+
rsx! {
58+
form {
59+
class: "FormifyForm FormifyEdit",
60+
onsubmit: onedit,
3661

37-
div {
38-
class: "FormifyInputs",
39-
#inputs
62+
div {
63+
class: "FormifyInputs",
64+
#inputs
4065
}
41-
button {
42-
class: "FormifyButton",
43-
"confirm"
44-
}
66+
67+
button {
68+
class: "FormifyButton",
69+
r#type: "submit",
70+
FormifyEditIcon {}
4571
}
4672
}
4773
}
74+
4875
}
4976
}
77+
}
5078
}

0 commit comments

Comments
 (0)