main
Elnu 11 months ago
parent d29f3aabca
commit 81d2626a35

@ -1,5 +1,5 @@
pub mod svg;
mod render; mod render;
pub mod svg;
use sycamore::prelude::*; use sycamore::prelude::*;
@ -13,13 +13,18 @@ fn Slider<G: Html>(cx: Scope) -> View<G> {
} }
fn main() { fn main() {
sycamore::render_to(|cx| view! { cx, sycamore::render_to(
|cx| {
view! { cx,
Slider Slider
Slider Slider
Slider Slider
}, { }
},
{
let window = web_sys::window().unwrap(); let window = web_sys::window().unwrap();
let document = window.document().unwrap(); let document = window.document().unwrap();
&document.query_selector("main").unwrap().unwrap() &document.query_selector("main").unwrap().unwrap()
}); },
);
} }

@ -31,7 +31,10 @@ mod filters {
use crate::svg::{SVGMeasure, SVGUnit}; use crate::svg::{SVGMeasure, SVGUnit};
pub fn kle_font_units(kle_font_units: &usize) -> askama::Result<SVGMeasure> { pub fn kle_font_units(kle_font_units: &usize) -> askama::Result<SVGMeasure> {
Ok(SVGMeasure::new((6 + kle_font_units * 2) as f64, SVGUnit::Pixel)) Ok(SVGMeasure::new(
(6 + kle_font_units * 2) as f64,
SVGUnit::Pixel,
))
} }
} }
@ -45,8 +48,14 @@ pub enum Error {
pub type Result<T> = std::result::Result<T, Error>; pub type Result<T> = std::result::Result<T, Error>;
pub fn render_file<P, Q>(input_path: P, output_path: Q) -> Result<()> pub fn render_file<P, Q>(input_path: P, output_path: Q) -> Result<()>
where P: AsRef<Path>, Q: AsRef<Path> { where
use std::{fs::{self, OpenOptions}, io::Write}; P: AsRef<Path>,
Q: AsRef<Path>,
{
use std::{
fs::{self, OpenOptions},
io::Write,
};
let mut file = OpenOptions::new() let mut file = OpenOptions::new()
.write(true) .write(true)
.truncate(true) .truncate(true)

Loading…
Cancel
Save