Compare commits

...

7 Commits

Author SHA1 Message Date
796412888d Cleanup Cargo.toml 2025-02-21 11:49:19 +01:00
796aa3e846 Cleanup assets and copy over old styles and title 2025-02-21 11:47:37 +01:00
e0a227486b Cleanup app 2025-02-21 11:45:29 +01:00
7b28c580f4 Add dioxus template for simpler experimenting 2025-02-21 11:37:07 +01:00
3c12e3ff29 Reformat project 2025-02-21 10:52:55 +01:00
1d760a2415 Reformat project 2025-02-21 10:49:50 +01:00
f9aae520e9 Add dioxus project skeleton 2025-02-20 10:56:28 +01:00
26 changed files with 1087 additions and 576 deletions

View File

@ -2,7 +2,7 @@
resolver = "2"
members = [
"leptos_webpage", "session_iter", "app",
"leptos_webpage", "session_iter", "app", "dioxus_template",
]
[profile]

7
app/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target
.DS_Store
# These are backup files generated by rustfmt
**/*.rs.bk

16
app/Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
name = "app"
version = "0.1.0"
authors = ["steppy <jonlaurem@gmail.com>"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dioxus = { version = "0.6.0", features = ["fullstack"] }
[features]
default = ["web"]
web = ["dioxus/web"]
desktop = ["dioxus/desktop"]
mobile = ["dioxus/mobile"]

24
app/Dioxus.toml Normal file
View File

@ -0,0 +1,24 @@
[application]
# App (Project) Name
name = "app"
[web.app]
# HTML title tag content
title = "Band Sessions"
# include `assets` in web platform
[web.resource]
# Additional CSS style files
style = []
# Additional JavaScript files
script = []
[web.resource.dev]
# Javascript code file
# serve: [dev-server] only
script = []

18
app/README.md Normal file
View File

@ -0,0 +1,18 @@
# Development
Your new bare-bones project includes minimal organization with a single `main.rs` file and a few assets.
### Serving Your App
Run the following command in the root of your project to start developing with the default platform:
```bash
dx serve --platform web
```
To run for a different platform, use the `--platform platform` flag. E.g.
```bash
dx serve --platform desktop
```

112
app/assets/styles.css Normal file
View File

@ -0,0 +1,112 @@
:root {
--darkred: darkred;
--darkgreen: #196e0a;
--darkgray: #292929;
--gray: #606060;
--white: white;
--black: black;
--red: red;
--yellow: #bbbb11;
--green: #1fd51f;
}
ul {
list-style-position: inside;
}
body {
font-size: 2rem;
}
html, body {
margin: 0;
padding: 0;
}
p {
margin: 0;
}
@media screen and (max-width: 1000px) {
body {
font-size: 3rem;
}
}
.background {
background-color: var(--darkgray);
color: var(--white);
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
overflow: scroll;
}
.column {
display: flex;
flex-direction: column;
gap: 10px;
}
.box {
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
text-align: center;
justify-content: center;
align-items: center;
margin: 0 auto;
width: 80%;
max-width: 800px;
box-sizing: border-box;
}
.wide {
width: 100%;
max-width: 1000px;
}
.button {
cursor: pointer;
}
.button:hover {
filter: brightness(1.2);
}
.elem-background {
background-color: var(--darkgreen);
}
.error-background {
background-color: var(--darkred);
}
.highlight-background {
background-color: var(--green);
}
.cancel-background {
background-color: var(--red);
}
.change-background {
background-color: var(--yellow);
}
.small-text {
color: var(--darkgray);
font-size: 1rem;
text-align: left;
}
.strikethrough {
text-decoration: line-through;
}
.bold {
font-weight: bold;
}

15
app/src/main.rs Normal file
View File

@ -0,0 +1,15 @@
use dioxus::prelude::*;
const MAIN_CSS: Asset = asset!("/assets/styles.css");
fn main() {
launch(App);
}
#[component]
fn App() -> Element {
rsx! {
document::Link { rel: "stylesheet", href: MAIN_CSS }
"Hello world"
}
}

7
dioxus_template/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target
.DS_Store
# These are backup files generated by rustfmt
**/*.rs.bk

View File

@ -0,0 +1,16 @@
[package]
name = "dioxus_template"
version = "0.1.0"
authors = ["steppy <jonlaurem@gmail.com>"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dioxus = { version = "0.6.0", features = ["router", "fullstack"] }
[features]
default = ["web"]
web = ["dioxus/web"]
desktop = ["dioxus/desktop"]
mobile = ["dioxus/mobile"]

View File

@ -0,0 +1,24 @@
[application]
# App (Project) Name
name = "dioxus_template"
[web.app]
# HTML title tag content
title = "dioxus_template"
# include `assets` in web platform
[web.resource]
# Additional CSS style files
style = []
# Additional JavaScript files
script = []
[web.resource.dev]
# Javascript code file
# serve: [dev-server] only
script = []

17
dioxus_template/README.md Normal file
View File

@ -0,0 +1,17 @@
# Development
Your new bare-bones project includes minimal organization with a single `main.rs` file and a few assets.
### Serving Your App
Run the following command in the root of your project to start developing with the default platform:
```bash
dx serve --platform web
```
To run for a different platform, use the `--platform platform` flag. E.g.
```bash
dx serve --platform desktop
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -0,0 +1,107 @@
/* App-wide styling */
body {
background-color: #0f1116;
color: #ffffff;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 20px;
}
#hero {
margin: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
#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 0px;
border: white 1px solid;
border-radius: 5px;
padding: 10px;
}
#links a:hover {
background-color: #1f1f1f;
cursor: pointer;
}
#header {
max-width: 1200px;
}
/* Navbar */
#navbar {
display: flex;
flex-direction: row;
}
#navbar a {
color: #ffffff;
margin-right: 20px;
text-decoration: none;
transition: color 0.2s ease;
}
#navbar a:hover {
cursor: pointer;
color: #91a4d2;
}
/* Blog page */
#blog {
margin-top: 50px;
}
#blog a {
color: #ffffff;
margin-top: 50px;
}
/* Echo */
#echo {
width: 360px;
margin-left: auto;
margin-right: auto;
margin-top: 50px;
background-color: #1e222d;
padding: 20px;
border-radius: 10px;
}
#echo>h4 {
margin: 0px 0px 15px 0px;
}
#echo>input {
border: none;
border-bottom: 1px white solid;
background-color: transparent;
color: #ffffff;
transition: border-bottom-color 0.2s ease;
outline: none;
display: block;
padding: 0px 0px 5px 0px;
width: 100%;
}
#echo>input:focus {
border-bottom-color: #6d85c6;
}
#echo>p {
margin: 20px 0px 0px auto;
}

121
dioxus_template/src/main.rs Normal file
View File

@ -0,0 +1,121 @@
use dioxus::prelude::*;
#[derive(Debug, Clone, Routable, PartialEq)]
#[rustfmt::skip]
enum Route {
#[layout(Navbar)]
#[route("/")]
Home {},
#[route("/blog/:id")]
Blog { id: i32 },
}
const FAVICON: Asset = asset!("/assets/favicon.ico");
const MAIN_CSS: Asset = asset!("/assets/main.css");
const HEADER_SVG: Asset = asset!("/assets/header.svg");
fn main() {
launch(App);
}
#[component]
fn App() -> Element {
rsx! {
document::Link { rel: "icon", href: FAVICON }
document::Link { rel: "stylesheet", href: MAIN_CSS }
Router::<Route> {}
}
}
#[component]
pub fn Hero() -> Element {
rsx! {
div { id: "hero",
img { src: HEADER_SVG, id: "header" }
div { id: "links",
a { href: "https://dioxuslabs.com/learn/0.6/", "📚 Learn Dioxus" }
a { href: "https://dioxuslabs.com/awesome", "🚀 Awesome Dioxus" }
a { href: "https://github.com/dioxus-community/", "📡 Community Libraries" }
a { href: "https://github.com/DioxusLabs/sdk", "⚙️ Dioxus Development Kit" }
a { href: "https://marketplace.visualstudio.com/items?itemName=DioxusLabs.dioxus",
"💫 VSCode Extension"
}
a { href: "https://discord.gg/XgGxMSkvUM", "👋 Community Discord" }
}
}
}
}
/// Home page
#[component]
fn Home() -> Element {
rsx! {
Hero {}
Echo {}
}
}
/// Blog page
#[component]
pub fn Blog(id: i32) -> Element {
rsx! {
div { id: "blog",
// Content
h1 { "This is blog #{id}!" }
p {
"In blog #{id}, we show how the Dioxus router works and how URL parameters can be passed as props to our route components."
}
// Navigation links
Link { to: Route::Blog { id: id - 1 }, "Previous" }
span { " <---> " }
Link { to: Route::Blog { id: id + 1 }, "Next" }
}
}
}
/// Shared navbar component.
#[component]
fn Navbar() -> Element {
rsx! {
div { id: "navbar",
Link { to: Route::Home {}, "Home" }
Link { to: Route::Blog { id: 1 }, "Blog" }
}
Outlet::<Route> {}
}
}
/// Echo component that demonstrates fullstack server functions.
#[component]
fn Echo() -> Element {
let mut response = use_signal(|| String::new());
rsx! {
div { id: "echo",
h4 { "ServerFn Echo" }
input {
placeholder: "Type here to echo...",
oninput: move |event| async move {
let data = echo_server(event.value()).await.unwrap();
response.set(data);
},
}
if !response().is_empty() {
p {
"Server echoed: "
i { "{response}" }
}
}
}
}
}
/// Echo the user input on the server.
#[server(EchoServer)]
async fn echo_server(input: String) -> Result<String, ServerFnError> {
Ok(input)
}

View File

@ -8,7 +8,8 @@ fn main() -> Result<(), String> {
let out_dir = env::var_os("TRUNK_STAGING_DIR").unwrap_or("target/default_configs".into());
fs::create_dir_all(&out_dir).map_err(|e| format!("failed to create target directory: {e}"))?;
create_default_config::<SessionConfig, _>("session_config", &out_dir).map_err(|e| format!("Failed to create session_config: {e}"))?;
create_default_config::<SessionConfig, _>("session_config", &out_dir)
.map_err(|e| format!("Failed to create session_config: {e}"))?;
Ok(())
}

View File

@ -6,7 +6,9 @@ use serde::{Deserialize, Serialize};
use session_iter::day::Day;
use session_iter::session::iter::{DatedSession, DatedSessionIter};
use session_iter::session::rule::WeekdayOfMonth;
use session_iter::session::{Alternation, Cancellation, Dated, ExtraSession, RegularSession, Session, WithNote};
use session_iter::session::{
Alternation, Cancellation, Dated, ExtraSession, RegularSession, Session, WithNote,
};
#[component]
pub fn App() -> impl IntoView {
@ -188,7 +190,12 @@ impl Default for SessionConfig {
.except(
NEXT_SUN_SESSION,
Alternation {
new_day: Some(NEXT_SUN_SESSION.checked_sub_days(Days::new(1)).unwrap().into()),
new_day: Some(
NEXT_SUN_SESSION
.checked_sub_days(Days::new(1))
.unwrap()
.into(),
),
..Default::default()
},
)

View File

@ -2,4 +2,3 @@ pub mod day;
pub mod session;
#[cfg(test)]
mod test_util;

View File

@ -17,7 +17,7 @@ impl DatedSessionIter {
pub fn new<D, S>(start_date: D, sessions: S) -> DatedSessionIter
where
D: Into<Day>,
S: IntoIterator<Item=Session>,
S: IntoIterator<Item = Session>,
{
let current_date = start_date.into();

View File

@ -50,7 +50,7 @@ pub struct SessionDayIter<R> {
impl<R, S> Iterator for SessionDayIter<R>
where
R: Deref<Target=S>,
R: Deref<Target = S>,
S: SessionRuleLike,
{
type Item = Day;
@ -67,7 +67,7 @@ where
impl<R> SessionDayIter<R>
where
R: Deref<Target=SessionRule>,
R: Deref<Target = SessionRule>,
{
pub fn to_owned(&self) -> SessionDayIter<SessionRule> {
SessionDayIter {