Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use yew with version 0.18.0 #37

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Cargo.lock
# VSCode
*.code-workspace

# CLion
.idea

# MacOS
## General
.DS_Store
Expand Down
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "css-in-rust"
version = "0.5.0"
name = "css-in-rust-next"
version = "0.8.0"
license = "MIT"
repository = "https://github.com/lukidoescode/css-in-rust"
authors = [
Expand All @@ -17,16 +17,16 @@ keywords = [
categories = ["wasm", "web-programming"]
readme = "README.md"
homepage = "https://crates.io/crates/css-in-rust"

resolver = "2"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
nom = "^5.1.1"
nom = "5.1.1"
lazy_static = "^1.4.0"
yew = {version = "^0.17.2", features=["web_sys"], optional = true}
seed = {version = "^0.6.0", optional = true}
yew = {version = "0.21.0", optional = true}
seed = {version = "0.9.0", optional = true}

[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys]
version = "^0.3"
Expand All @@ -40,7 +40,7 @@ features = [
]

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
rand = { version = "^0.7.0", features = ["small_rng"]}
rand = { version = "^0.8.0", features = ["small_rng"]}

# Changes here must be reflected in `build.rs`
[target.'cfg(all(target_arch = "wasm32", not(target_os="wasi"), not(cargo_web)))'.dependencies]
Expand Down
4 changes: 2 additions & 2 deletions src/bindings/yew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
extern crate yew;

use super::super::style::Style;
use yew::virtual_dom::Classes;
use yew::prelude::Classes;

impl From<Style> for Classes {
fn from(style: Style) -> Self {
let mut classes = Self::new();
classes.push(style.get_class_name().as_str());
classes.push(style.get_class_name());
classes
}
}
2 changes: 1 addition & 1 deletion src/style/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl ToCss for Block {
if condition.contains('&') {
format!(
"{} {{{}\n}}",
condition.replace("&", format!(".{}", class_name).as_str()),
condition.replace('&', format!(".{}", class_name).as_str()),
style_property_css
)
} else {
Expand Down
14 changes: 4 additions & 10 deletions src/style/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,11 @@ extern "C" {

/// The style registry is just a global struct that makes sure no style gets lost.
/// Every style automatically registers with the style registry.
#[derive(Debug, Clone)]
#[derive(Clone, Debug, Default)]
struct StyleRegistry {
styles: HashMap<String, Style>,
}

impl Default for StyleRegistry {
fn default() -> Self {
Self {
styles: HashMap::new(),
}
}
}

unsafe impl Send for StyleRegistry {}
unsafe impl Sync for StyleRegistry {}

Expand All @@ -57,6 +49,7 @@ pub struct Style {
}

#[cfg(not(target_arch = "wasm32"))]
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct Style {
/// The designated class name of this style
Expand Down Expand Up @@ -170,6 +163,7 @@ impl Style {
small_rng
.sample_iter(Alphanumeric)
.take(30)
.map(|number| number.to_string())
.collect::<String>()
),
// TODO log out an error
Expand All @@ -180,7 +174,7 @@ impl Style {
Ok(guard) => guard,
Err(poisoned) => poisoned.into_inner(),
};
(*style_registry)
style_registry
.styles
.insert(new_style.class_name.clone(), new_style.clone());
Ok(new_style)
Expand Down