chore: initialize the Dioxus project
This commit is contained in:
		
							
								
								
									
										12
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| # Generated by Cargo | ||||
| # will have compiled files and executables | ||||
| /target/ | ||||
| /dist/ | ||||
| /static/ | ||||
| /.dioxus/ | ||||
|  | ||||
| # this file will generate by tailwind: | ||||
| /assets/tailwind.css | ||||
|  | ||||
| # These are backup files generated by rustfmt | ||||
| **/*.rs.bk | ||||
							
								
								
									
										5
									
								
								.idea/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								.idea/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| # Default ignored files | ||||
| /shelf/ | ||||
| /workspace.xml | ||||
| # Editor-based HTTP Client requests | ||||
| /httpRequests/ | ||||
							
								
								
									
										8
									
								
								.idea/modules.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								.idea/modules.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <project version="4"> | ||||
|   <component name="ProjectModuleManager"> | ||||
|     <modules> | ||||
|       <module fileurl="file://$PROJECT_DIR$/.idea/todo_baggins.iml" filepath="$PROJECT_DIR$/.idea/todo_baggins.iml" /> | ||||
|     </modules> | ||||
|   </component> | ||||
| </project> | ||||
							
								
								
									
										6
									
								
								.idea/rust.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.idea/rust.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <project version="4"> | ||||
|   <component name="RsVcsConfiguration"> | ||||
|     <option name="rustFmt" value="true" /> | ||||
|   </component> | ||||
| </project> | ||||
							
								
								
									
										13
									
								
								.idea/todo_baggins.iml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								.idea/todo_baggins.iml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <module type="EMPTY_MODULE" version="4"> | ||||
|   <component name="NewModuleRootManager"> | ||||
|     <content url="file://$MODULE_DIR$"> | ||||
|       <sourceFolder url="file://$MODULE_DIR$/backend/src" isTestSource="false" /> | ||||
|       <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||||
|       <excludeFolder url="file://$MODULE_DIR$/backend/target" /> | ||||
|       <excludeFolder url="file://$MODULE_DIR$/target" /> | ||||
|     </content> | ||||
|     <orderEntry type="inheritedJdk" /> | ||||
|     <orderEntry type="sourceFolder" forTests="false" /> | ||||
|   </component> | ||||
| </module> | ||||
							
								
								
									
										12
									
								
								.idea/vcs.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								.idea/vcs.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <project version="4"> | ||||
|   <component name="CommitMessageInspectionProfile"> | ||||
|     <profile version="1.0"> | ||||
|       <inspection_tool class="CommitFormat" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|       <inspection_tool class="CommitNamingConvention" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     </profile> | ||||
|   </component> | ||||
|   <component name="VcsDirectoryMappings"> | ||||
|     <mapping directory="$PROJECT_DIR$" vcs="Git" /> | ||||
|   </component> | ||||
| </project> | ||||
							
								
								
									
										2029
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										2029
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										14
									
								
								Cargo.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								Cargo.toml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| [package] | ||||
| name = "todo-baggins" | ||||
| version = "0.1.0" | ||||
| authors = ["Matouš Volf <66163112+matous-volf@users.noreply.github.com>"] | ||||
| edition = "2021" | ||||
|  | ||||
| # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||||
|  | ||||
| [dependencies] | ||||
|  | ||||
| dioxus = { version = "0.5", features = ["web", "router"] } | ||||
|  | ||||
| # Debug | ||||
| dioxus-logger = "0.5.1" | ||||
							
								
								
									
										43
									
								
								Dioxus.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								Dioxus.toml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | ||||
| [application] | ||||
|  | ||||
| # App (Project) Name | ||||
| name = "todo-baggins" | ||||
|  | ||||
| # Dioxus App Default Platform | ||||
| # web, desktop, fullstack | ||||
| default_platform = "web" | ||||
|  | ||||
| # `build` & `serve` dist path | ||||
| out_dir = "dist" | ||||
|  | ||||
| # resource (assets) file folder | ||||
| asset_dir = "assets" | ||||
|  | ||||
| [web.app] | ||||
|  | ||||
| # HTML title tag content | ||||
| title = "todo-baggins" | ||||
|  | ||||
| [web.watcher] | ||||
|  | ||||
| # when watcher trigger, regenerate the `index.html` | ||||
| reload_html = true | ||||
|  | ||||
| # which files or dirs will be watcher monitoring | ||||
| watch_path = ["src", "assets"] | ||||
|  | ||||
| # include `assets` in web platform | ||||
| [web.resource] | ||||
|  | ||||
| # CSS style file | ||||
|  | ||||
| style = ["/tailwind.css"] | ||||
|  | ||||
| # Javascript code file | ||||
| script = [] | ||||
|  | ||||
| [web.resource.dev] | ||||
|  | ||||
| # Javascript code file | ||||
| # serve: [dev-server] only | ||||
| script = [] | ||||
							
								
								
									
										17
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| # Development | ||||
|  | ||||
| 1. Install npm: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm | ||||
| 2. Install the tailwind css cli: https://tailwindcss.com/docs/installation | ||||
| 3. Run the following command in the root of the project to start the tailwind CSS compiler: | ||||
|  | ||||
| ```bash | ||||
| npx tailwindcss -i ./input.css -o ./assets/tailwind.css --watch | ||||
| ``` | ||||
|  | ||||
| Run the following command in the root of the project to start the Dioxus dev server: | ||||
|  | ||||
| ```bash | ||||
| dx serve --hot-reload | ||||
| ``` | ||||
|  | ||||
| - Open the browser to http://localhost:8080 | ||||
							
								
								
									
										
											BIN
										
									
								
								assets/favicon.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								assets/favicon.ico
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 130 KiB | 
							
								
								
									
										171
									
								
								assets/header.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										171
									
								
								assets/header.svg
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| After Width: | Height: | Size: 25 KiB | 
							
								
								
									
										40
									
								
								assets/main.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								assets/main.css
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| body { | ||||
|     background-color: #111216; | ||||
| } | ||||
|  | ||||
| #main { | ||||
|     margin: 0; | ||||
|     display: flex; | ||||
|     flex-direction: column; | ||||
|     justify-content: center; | ||||
|     align-items: center; | ||||
|     font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif | ||||
| } | ||||
|  | ||||
| #links { | ||||
|     width: 400px; | ||||
|     text-align: left; | ||||
|     font-size: x-large; | ||||
|     color: white; | ||||
|     display: flex; | ||||
|     flex-direction: column; | ||||
| } | ||||
|  | ||||
| #links a { | ||||
|     color: white; | ||||
|     text-decoration: none; | ||||
|     margin-top: 20px; | ||||
|     margin: 10px; | ||||
|     border: white 1px solid; | ||||
|     border-radius: 5px; | ||||
|     padding: 10px; | ||||
| } | ||||
|  | ||||
| #links a:hover { | ||||
|     background-color: #1f1f1f; | ||||
|     cursor: pointer; | ||||
| } | ||||
|  | ||||
| #header { | ||||
|     max-width: 1200px; | ||||
| } | ||||
							
								
								
									
										3
									
								
								input.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								input.css
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| @tailwind base; | ||||
| @tailwind components; | ||||
| @tailwind utilities; | ||||
							
								
								
									
										52
									
								
								src/main.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								src/main.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| #![allow(non_snake_case)] | ||||
|  | ||||
| use dioxus::prelude::*; | ||||
| use dioxus_logger::tracing::{info, Level}; | ||||
|  | ||||
| #[derive(Clone, Routable, Debug, PartialEq)] | ||||
| enum Route { | ||||
|     #[route("/")] | ||||
|     Home {}, | ||||
|     #[route("/blog/:id")] | ||||
|     Blog { id: i32 }, | ||||
| } | ||||
|  | ||||
| fn main() { | ||||
|     // Init logger | ||||
|     dioxus_logger::init(Level::INFO).expect("failed to init logger"); | ||||
|     info!("starting app"); | ||||
|     launch(App); | ||||
| } | ||||
|  | ||||
| fn App() -> Element { | ||||
|     rsx! { | ||||
|         Router::<Route> {} | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[component] | ||||
| fn Blog(id: i32) -> Element { | ||||
|     rsx! { | ||||
|         Link { to: Route::Home {}, "Go to counter" } | ||||
|         "Blog post {id}" | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[component] | ||||
| fn Home() -> Element { | ||||
|     let mut count = use_signal(|| 0); | ||||
|  | ||||
|     rsx! { | ||||
|         Link { | ||||
|             to: Route::Blog { | ||||
|                 id: count() | ||||
|             }, | ||||
|             "Go to blog" | ||||
|         } | ||||
|         div { | ||||
|             h1 { "High-Five counter: {count}" } | ||||
|             button { onclick: move |_| count += 1, "Up high!" } | ||||
|             button { onclick: move |_| count -= 1, "Down low!" } | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										9
									
								
								tailwind.config.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								tailwind.config.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| /** @type {import('tailwindcss').Config} */ | ||||
| module.exports = { | ||||
|     mode: "all", | ||||
|     content: ["./src/**/*.{rs,html,css}", "./dist/**/*.html"], | ||||
|     theme: { | ||||
|         extend: {}, | ||||
|     }, | ||||
|     plugins: [], | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user