-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathmod.rs
More file actions
58 lines (54 loc) · 1.49 KB
/
mod.rs
File metadata and controls
58 lines (54 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018, the Perspective Authors.
//
// This file is part of the Perspective library, distributed under the terms
// of the Apache License 2.0. The full license can be found in the LICENSE
// file.
//! A micro-framework for associating local CSS snippets with `yew::Component`s
//! in a Custom Element's `ShadowRoot`. Embedding a `<LocalStyle>` element
//! will only create the underlying `<style>` tag once (when `Component::view()`
//! is called the first time), even if multiple copies of the `Component`
//! exist in the tree.
//!
//! # Example
//! ```
//! html! {
//! <StyleProvider>
//! <LocalStyle href={ css!("my-style") } />
//! <h1>{ "I am styled!" }</h1>
//! </StyleProvider>
//! }
//! ```
mod local_style;
mod style_cache;
mod style_provider;
pub use local_style::LocalStyle;
pub use style_provider::StyleProvider;
#[macro_export]
macro_rules! css {
($name:expr) => {{
(
$name,
include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/target/css/",
$name,
".css"
)),
)
}};
($path:expr, $name:expr) => {{
(
$name,
include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/",
$path,
"/",
$name,
".css"
)),
)
}};
}