Skip to content

Commit

Permalink
refactor: remove cfg-if
Browse files Browse the repository at this point in the history
  • Loading branch information
brofrain committed Jul 31, 2024
1 parent 539164c commit 3fc917b
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 57 deletions.
7 changes: 4 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"rust-analyzer.check.command": "clippy",
"rust-analyzer.check.targets": [
"wasm32-unknown-unknown",
"x86_64-unknown-linux-gnu"
],
"rust-analyzer.cargo.target": "wasm32-unknown-unknown",
"rust-analyzer.diagnostics.enable": false,
"rust-analyzer.procMacro.ignored": {
"leptos_macro": ["component"]
},
"rust-analyzer.rustfmt.overrideCommand": ["leptosfmt", "--stdin", "--rustfmt"]
}
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ description = "<AnimatedFor /> component utilizing FLIP position transitions for
keywords = ["leptos", "animations", "dom", "web", "wasm"]

[dependencies]
cfg-if = "1.0.0"
futures = "0.3.30"
leptos = { version = "0.6.13" }
wasm-bindgen = { version = "0.2.92" }
Expand Down
1 change: 0 additions & 1 deletion examples/csr/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion examples/ssr/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ fmt-check-examples:
# Lints source with Clippy
lint:
cargo clippy -- -D warnings
cargo clippy --lib -- -D warnings
cargo clippy --lib --target wasm32-unknown-unknown -- -D warnings

# Lints examples with Clippy
lint-examples:
#!/usr/bin/env sh
# FIXME: as of Leptos 0.6.9, `#[component]` macro triggers `clippy::empty_docs`
(cd examples/csr && cargo clippy -- -D warnings -A clippy::empty_docs)
(cd examples/ssr && cargo clippy --features ssr -- -D warnings -A clippy::empty_docs)
(cd examples/ssr && cargo clippy --lib --features hydrate -- -D warnings -A clippy::empty_docs)
(cd examples/csr && cargo clippy)
(cd examples/ssr && cargo clippy --features ssr)
(cd examples/ssr && cargo clippy --lib --features hydrate)
ci:
just fmt-check
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "nightly-2024-07-29"
components = ["rustfmt", "clippy"]
targets = ["wasm32-unknown-unknown"]
targets = ["wasm32-unknown-unknown", "x86_64-unknown-linux-gnu"]
profile = "minimal"
90 changes: 46 additions & 44 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
cfg_if::cfg_if! {
if #[cfg(target_arch = "wasm32")] {
mod animated_el;
mod animator;
mod untracked_classes;
mod utils;

use std::{
collections::{HashMap, HashSet},
hash::Hash,
};
mod animated_el;
mod animator;
mod untracked_classes;

use leptos::{
component,
leptos_dom::Each,
spawn_local,
update,
with,
IntoView,
MaybeProp,
StoredValue,
View,
};
use web_sys::DomRect;

use crate::{
animator::Animator,
utils::{
check_if_moved_and_lock_previous_position,
extract_el_from_view,
force_reflow,
next_tick,
prepare_leave,
},
};
} else {
use std::hash::Hash;

use leptos::{
component,
leptos_dom::Each,
IntoView,
MaybeProp,
};
}
#[cfg(target_arch = "wasm32")]
mod utils;

#[cfg(target_arch = "wasm32")]
mod prelude {

pub use std::{
collections::{HashMap, HashSet},
hash::Hash,
};

pub use leptos::{
component,
leptos_dom::Each,
spawn_local,
update,
with,
IntoView,
MaybeProp,
StoredValue,
View,
};
pub use web_sys::DomRect;

pub use crate::{
animator::Animator,
utils::{
check_if_moved_and_lock_previous_position,
extract_el_from_view,
force_reflow,
next_tick,
prepare_leave,
},
};
}

#[cfg(not(target_arch = "wasm32"))]
mod prelude {
pub use std::hash::Hash;

pub use leptos::{component, leptos_dom::Each, IntoView, MaybeProp};
}

use prelude::*;

#[cfg(target_arch = "wasm32")]
fn use_entering_children<Item, ChildFn, Child, KeyFn, Key>(
key_fn: StoredValue<KeyFn>,
Expand Down

0 comments on commit 3fc917b

Please sign in to comment.