Skip to content

Commit

Permalink
fix for PDF printing and bump version to re-publish
Browse files Browse the repository at this point in the history
  • Loading branch information
mhfan committed Dec 17, 2024
1 parent 1d718a2 commit 4201616
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[package]
edition = "2021"
name = "inperiod"
version = "0.1.3"
version = "0.1.6"
license = "MIT OR Apache-2.0"
authors = ["MeiHui FAN <mhfan@ustc.edu>"]
homepage = "https://mhfan.github.io/inperiod"
Expand Down
15 changes: 4 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@
<body id="main"> <!--div id="main"></div-->
<script>
const isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
if (isChrome) { document.body.style.zoom = '0.5'; } else {
/* if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) */
/* const elem = document.documentElement; <html> */
const elem = document.body;
const scale = 0.5;
const width = scale * elem.offsetWidth;
const height = scale * elem.offsetHeight;
elem.style.transform = `scale(${scale})`;
elem.style.transformOrigin = '0 0';
elem.style.width = width + 'px';
elem.style.height = height + 'px';
if (isChrome) { document.body.style = "zoom: 0.5; width: fit-content"; } else {
//if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent))
document.body.style = //document.documentElement.style = // <html>
"transform: scale(0.5); transform-origin: 0px 0px; width: 0px; height: 0px;";

const style = document.createElement('style');
style.innerHTML = `
Expand Down
12 changes: 7 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fn App() -> Element {
@page { size: A4 landscape; margin: 0; } /* 设置页面的方向为横向并清除默认页边距 */
body { width: 297mm; margin: auto; } /* 设置主体样式以适应横向打印 */
.non-printable { display: none; } /* 隐藏非打印元素 */
select { appearance: none; background: transparent; }
}";

use dioxus::document::{Link, Title, Style/*, Script, Meta*/};
Expand Down Expand Up @@ -169,7 +170,7 @@ fn PeriodicTable() -> Element {
}
div { class: "self-end ml-6 text-lg/6", PhysConsts {} }
}
p { class: "absolute right-0 mt-1", style: wm_vert,
p { class: "absolute right-0 mt-1 text-nowrap", style: wm_vert,
{tr!(lang, "metal - nonmetal divider")}
}
}
Expand Down Expand Up @@ -313,7 +314,7 @@ static COLORING_ORIGINS: [(&str, &str); CosmicOrigin::MAX as usize] = [ // stric

let metal_bound = match ordinal {
1 => "shadow-black-b", 118 => "shadow-black-l", 4 => "shadow-[0_-2px_black]",
21|39|71 => "shadow-spread-2 shadow-amber-300", // rare earth metals indication
21|39|71 => "border-amber-300", // rare earth metals indication
2 => "shadow-[0_2px_#fca5a5]", // indicate He is of s-block, shadow-red-300
5|14|33|52|85 => "shadow-black-bl", _ => "",
};
Expand Down Expand Up @@ -414,9 +415,10 @@ static COLORING_ORIGINS: [(&str, &str); CosmicOrigin::MAX as usize] = [ // stric
}
div { class: "text-right ml-1 relative",
div { class: "absolute w-full h-full group font-bold leading-tight",
for os in os_main.iter().rev() { pre { { format!("{}{os}",
match *os { x if 0 < x => "+", 0 => " ", _ => "" })
} } }
style: if 7 < os_main.len() { "line-height: 1;" } else { "" },
for os in os_main.iter().rev() { pre {
{format!("{}{os}", match *os { x if 0 < x => "+", 0 => " ", _ => "" })}
} }
if os_main.len() < os_all.len() { div { class: "absolute hidden
left-full -top-2 ml-1.5 p-1 text-lg/5 font-normal rounded
border border-orange-600 bg-white group-hover:block z-10",
Expand Down

0 comments on commit 4201616

Please sign in to comment.