freya_html/lib.rs
1//! Render inline or remote HTML and CSS in a Freya component using Blitz.
2//!
3//! ```rust,no_run
4//! # use freya::prelude::*;
5//! use freya_html::prelude::*;
6//!
7//! # fn app() -> impl IntoElement {
8//! let handle = use_html(|| HtmlSource::html("<h1>Hello!</h1>"));
9//! HtmlViewer::new(handle).expanded()
10//! # }
11//! ```
12//!
13//! Configure inline documents with [`HtmlContent`], including a validated
14//! base URL through [`HtmlContent::with_base_url`].
15//!
16//! Use [`HtmlSource::url`] to load a remote page. Add local fonts with
17//! [`HtmlViewer::font`]. On web, provide a font for inline documents or load one
18//! through CSS `@font-face`.
19//!
20//! For HTTP requests outside the viewer,
21//! enable Freya's `remote-asset` feature and use [`freya_components::http::fetch`]:
22//!
23//! ```rust,no_run
24//! # async fn load() -> Result<(), Box<dyn std::error::Error>> {
25//! let url = freya_components::Url::parse("https://example.com")?;
26//! let bytes = freya_components::http::fetch(url).await?;
27//! # Ok(())
28//! # }
29//! ```
30
31#[doc(hidden)]
32pub mod anyrender;
33mod cache;
34mod component;
35mod content;
36mod element;
37mod fonts;
38mod handle;
39mod net;
40mod state;
41
42pub use cache::ResourceCache;
43pub use component::HtmlViewer;
44pub use content::HtmlContent;
45pub use handle::{
46 ElementHit,
47 HtmlHandle,
48 HtmlSource,
49 use_html,
50};
51
52pub mod prelude {
53 pub use crate::{
54 cache::ResourceCache,
55 component::HtmlViewer,
56 content::HtmlContent,
57 handle::{
58 ElementHit,
59 HtmlHandle,
60 HtmlSource,
61 use_html,
62 },
63 };
64}