Skip to content

Commit

Permalink
feat: tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
atty303 committed Jan 21, 2024
1 parent 9f93d11 commit c2bf47e
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 34 deletions.
6 changes: 3 additions & 3 deletions gen/src/skill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn process_skill_mode(

if mode_row.use_init {
Token::NewLine.write(out);
terms.get_tips("WD_UseInit", "TIPS_UseInit").write(out);
terms.get_tips("NM-TIPS_UseInit", "TIPS_UseInit").write(out);
}

tail
Expand Down Expand Up @@ -289,7 +289,7 @@ fn act_node_formatter(
} else {
Token::Indent.write(out);
terms
.get("DC-SkillNodeDesc-CritRate")
.get_tips("DC-SkillNodeDesc-CritRate", "TIPS_SCritRate")
.map_var_1(|out| Token::Text(row.crit_rate.to_string()).write(out))
.write(out);
}
Expand Down Expand Up @@ -327,7 +327,7 @@ fn act_node_formatter(
//let pair = row.inc_relate.split(':').collect::<Vec<_>>();
let key = &row.inc_relate;
match terms.try_get(&format!("NM-{}", key)) {
Some(s) => terms
Some(_) => terms
.get_tips(&format!("NM-{}", key), &format!("{}", key))
.write(out),
None => match terms.try_get(&format!("DC-SkillNodeDesc-Relate-{}", key)) {
Expand Down
Binary file modified public/i18n/de/database.msgpack
Binary file not shown.
Binary file modified public/i18n/en/database.msgpack
Binary file not shown.
Binary file modified public/i18n/es/database.msgpack
Binary file not shown.
Binary file modified public/i18n/fr/database.msgpack
Binary file not shown.
Binary file modified public/i18n/it/database.msgpack
Binary file not shown.
Binary file modified public/i18n/ja/database.msgpack
Binary file not shown.
Binary file modified public/i18n/ko/database.msgpack
Binary file not shown.
Binary file modified public/i18n/pt-BR/database.msgpack
Binary file not shown.
Binary file modified public/i18n/pt/database.msgpack
Binary file not shown.
Binary file modified public/i18n/ru/database.msgpack
Binary file not shown.
Binary file modified public/i18n/zh-CN/database.msgpack
Binary file not shown.
Binary file modified public/i18n/zh-TW/database.msgpack
Binary file not shown.
55 changes: 25 additions & 30 deletions src/components/skill_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ use dioxus::html::geometry::euclid::Rect;
use dioxus::prelude::*;
use dioxus_router::prelude::Link;
use dioxus_signals::{use_selector, use_signal, Signal};
use dioxus_web::WebEventExt;
use fermi::use_read;

use crate::atoms::DATABASE;
use data::token::{Token, Tokens};

use crate::atoms::DATABASE;
use crate::components::{Rarity, SpriteIcon};
use crate::pages::Route;

#[component]
pub fn SkillView(cx: Scope, skill: Signal<data::skill::Skill>) -> Element {
pub fn SkillView(
cx: Scope,
skill: Signal<data::skill::Skill>,
#[props(default = false)] debug: bool,
) -> Element {
render! {
div {
class: "flex flex-col border-solid border border-base-300 rounded-md my-2",
Expand All @@ -34,7 +37,7 @@ pub fn SkillView(cx: Scope, skill: Signal<data::skill::Skill>) -> Element {
div { class: "flex flex-row flex-wrap gap-2 p-2",
for mode in skill.read().modes.iter().filter(|_m| true) {
div { class: "flex-1 min-w-48",
SkillMode { mode: Signal::new(mode.clone()) }
SkillMode { mode: Signal::new(mode.clone()), debug: *debug }
}
}
}
Expand All @@ -43,34 +46,21 @@ pub fn SkillView(cx: Scope, skill: Signal<data::skill::Skill>) -> Element {
}

#[component]
pub fn SkillMode(cx: Scope, mode: Signal<data::skill::SkillMode>) -> Element {
pub fn SkillMode(
cx: Scope,
mode: Signal<data::skill::SkillMode>,
#[props(default = false)] debug: bool,
) -> Element {
render! {
div { class: "flex flex-col gap-2 bg-base-200 text-base-content rounded-md p-2",
div { class: "flex flex-row items-center gap-2",
SpriteIcon { class: "rounded-md", sprite: Signal::new(mode.read().icon.clone()), size: 32 }
div { class: "flex-grow",
"{mode.read().name}"
}
// div { class: "dropdown",
// div { class: "btn btn-ghost btn-circle btn-sm",
// tabindex: 0,
// role: "button",
// dangerous_inner_html: r#"<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" d="M6.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM12.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM18.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Z" /></svg>"#,
// }
// ul { class: "menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52",
// tabindex: 0,
// li {
// button {
// class: "btn btn-ghost btn-sm justify-start",
// onclick: move |_| log::info!("{:#?}", mode),
// "Dump"
// }
// }
// }
// }
}
div { class: "bg-base-100 p-2",
Description { tokens: mode.read().format() }
Description { tokens: mode.read().format(), debug: *debug }
}
}
}
Expand Down Expand Up @@ -126,7 +116,7 @@ fn to_nodes(tokens: &Tokens) -> Vec<Node> {
}

#[component]
fn RenderNode(cx: Scope, node: Node, #[props(default = true)] debug: bool) -> Element {
fn RenderNode(cx: Scope, node: Node, #[props(default = false)] debug: bool) -> Element {
match node {
Node::Text(text) => render! { "{text}" },
Node::NewLine => render! { br {} },
Expand Down Expand Up @@ -158,7 +148,7 @@ fn RenderNode(cx: Scope, node: Node, #[props(default = true)] debug: bool) -> El
span { class: "text-primary",
title: "{title}",
for node in &children {
RenderNode { node: node.clone() }
RenderNode { node: node.clone(), debug: *debug }
}
}
}
Expand All @@ -181,18 +171,23 @@ fn RenderNode(cx: Scope, node: Node, #[props(default = true)] debug: bool) -> El
}

#[component]
pub fn Description(cx: Scope, tokens: Tokens) -> Element {
pub fn Description(cx: Scope, tokens: Tokens, #[props(default = false)] debug: bool) -> Element {
let nodes = to_nodes(tokens);

render! {
for node in &nodes {
RenderNode { node: node.clone() }
RenderNode { node: node.clone(), debug: *debug }
}
}
}

#[component]
pub fn Tooltip<'a>(cx: Scope<'a>, name: String, children: Element<'a>) -> Element {
pub fn Tooltip<'a>(
cx: Scope<'a>,
name: String,
#[props(default = false)] debug: bool,
children: Element<'a>,
) -> Element {
let db = use_read(cx, &DATABASE);

let title = db.term.get(&format!("NM-{}", name));
Expand Down Expand Up @@ -230,9 +225,9 @@ pub fn Tooltip<'a>(cx: Scope<'a>, name: String, children: Element<'a>) -> Elemen
},
div { class: "card-body",
span { class: "font-bold",
Description { tokens: title }
Description { tokens: title, debug: *debug }
}
Description { tokens: body }
Description { tokens: body, debug: *debug }
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::components::Footer;
use crate::components::NavBar;
use crate::pages::skill::SkillListQuery;
use home::Home;
use skill::{SkillListPage, SkillPage};
use skill::{SkillDebugPage, SkillListPage, SkillPage};

/// An enum of all of the possible routes in the app.
#[derive(Routable, Clone)]
Expand All @@ -20,6 +20,8 @@ pub enum Route {
Home {},
#[route("/skill?:query")]
SkillListPage { query: SkillListQuery },
#[route("/skill/_debug")]
SkillDebugPage {},
#[route("/skill/:skill_id")]
SkillPage { skill_id: String },
#[route("/:..route")]
Expand Down
2 changes: 2 additions & 0 deletions src/pages/skill.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
pub use debug::*;
pub use list::*;
pub use view::*;

mod debug;
mod list;
mod view;
17 changes: 17 additions & 0 deletions src/pages/skill/debug.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use dioxus::prelude::*;
use dioxus_signals::Signal;
use fermi::use_read;

use crate::atoms::DATABASE;
use crate::components::SkillView;

#[component]
pub fn SkillDebugPage(cx: Scope) -> Element {
let db = use_read(cx, &DATABASE);

render! {
for skill in db.skill.iter() {
SkillView { skill: Signal::new(skill.clone()), debug: true }
}
}
}

0 comments on commit c2bf47e

Please sign in to comment.