Updated dioxus version and lots of css changes

master
Wynd 2025-06-14 18:33:30 +03:00
parent 6fff9e4450
commit c8b87b88b5
5 changed files with 80 additions and 111 deletions

View File

@ -7,7 +7,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus = { version = "0.6.0", features = [] } dioxus = { version = "0.6.3", features = [] }
toml = { version = "0.8" } toml = { version = "0.8" }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
rand = { version = "0.9" } rand = { version = "0.9" }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 23 KiB

View File

@ -3,88 +3,70 @@ html {
} }
body { body {
background-color: #0f1116; background-color: #0f1116;
color: #ffffff; color: #ffffff;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
margin: 20px; margin: 20px;
} }
form { form {
width: 100%; width: 100%;
text-align: center; text-align: center;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
font-size: 24px; font-size: 24px;
user-select: none; user-select: none;
> div { > div {
width: 100%; width: 100%;
height: 80px; height: 80px;
display: flex; display: flex;
margin-top: 10px; margin-top: 10px;
align-items: center; align-items: center;
align-self: center; align-self: center;
box-sizing: border-box; box-sizing: border-box;
border: solid 2px unset; border: solid 2px unset;
&.selected { &.selected {
border: solid 2px goldenrod; border: solid 2px goldenrod;
} }
&:hover:not(.selected) { &:hover:not(.selected) {
border: solid 1px gray; border: solid 1px gray;
} }
> input[type="checkbox"] { > input[type="checkbox"] {
display: none; display: none;
scale: 1.5; scale: 1.5;
margin-right: 10px; margin-right: 10px;
} }
> label { > label {
flex-grow: 1; flex-grow: 1;
} }
}
> input[type="submit"] { &:hover,
margin-top: 40px; > *:hover {
height: 70px; cursor: pointer;
background-color: transparent; }
border: none; }
color: white;
font-size: 42px;
&:hover { > input[type="submit"] {
font-size: 48px; margin-top: 40px;
color: goldenrod; height: 70px;
} background-color: transparent;
} border: none;
} color: white;
font-size: 42px;
#links {
width: 400px; &:hover {
text-align: left; font-size: 48px;
font-size: x-large; color: goldenrod;
color: white; cursor: pointer;
display: flex; }
flex-direction: column;
} &:focus {
outline: none;
#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;
} }

View File

@ -1,19 +1,21 @@
use std::{ use std::{
collections::HashMap,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
sync::LazyLock, sync::LazyLock,
}; };
use dioxus::prelude::*; use dioxus::{
desktop::{Config, WindowBuilder},
prelude::*,
};
use rand::seq::SliceRandom; use rand::seq::SliceRandom;
use serde::Deserialize; use serde::Deserialize;
const FAVICON: Asset = asset!("/assets/favicon.ico"); // const FAVICON: Asset = asset!("/assets/favicon.ico");
const MAIN_CSS: Asset = asset!("/assets/main.css"); const MAIN_CSS: Asset = asset!("/assets/main.css");
const HEADER_SVG: Asset = asset!("/assets/header.svg"); // const HEADER_SVG: Asset = asset!("/assets/header.svg");
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
struct Questions { pub struct Questions {
questions: Vec<Question>, questions: Vec<Question>,
} }
@ -32,13 +34,13 @@ impl DerefMut for Questions {
} }
#[derive(Debug, Clone, PartialEq, Deserialize)] #[derive(Debug, Clone, PartialEq, Deserialize)]
struct Question { pub struct Question {
message: String, message: String,
answers: Vec<Answer>, answers: Vec<Answer>,
} }
#[derive(Debug, Clone, PartialEq, Deserialize)] #[derive(Debug, Clone, PartialEq, Deserialize)]
struct Answer { pub struct Answer {
message: String, message: String,
#[serde(default)] #[serde(default)]
@ -75,13 +77,21 @@ fn get_questions() -> Vec<Question> {
} }
fn main() { fn main() {
dioxus::launch(App); dioxus::LaunchBuilder::new()
.with_cfg(
Config::default().with_menu(None).with_window(
WindowBuilder::new()
.with_maximized(true)
.with_title("Flashcards"),
),
)
.launch(App)
} }
#[component] #[component]
fn App() -> Element { fn App() -> Element {
rsx! { rsx! {
document::Link { rel: "icon", href: FAVICON } // document::Link { rel: "icon", href: FAVICON }
document::Link { rel: "stylesheet", href: MAIN_CSS } document::Link { rel: "stylesheet", href: MAIN_CSS }
QuestionPrompt {} QuestionPrompt {}
} }
@ -139,15 +149,12 @@ pub fn QuestionPrompt() -> Element {
} }
} }
}, },
onkeydown: move |event| {
dbg!(event.key());
if event.key() == Key::Enter {
dbg!("enter pressed");
}
},
h1 { "{current().message}" } h1 { "{current().message}" }
{ answer_buttons } { answer_buttons }
input { type: "submit" } input {
type: "submit",
}
} }
} }
} }