Skip to content
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
File renamed without changes.
46 changes: 16 additions & 30 deletions .github/workflows/everything.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,51 +38,38 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Run cargo clippy
run: cargo clippy --all --all-features
run: cargo clippy --all --features parser,yew_integration,yew_use_media_query,yew_use_style,ssr,hydration
env:
RUSTFLAGS: '--cfg releasing'

test-native-stable:
name: Run Native Tests (Stable)
test-native:
name: Run Native Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
- 1.76.0
- stable
- nightly
steps:
- name: Checkout Project
uses: actions/checkout@v4

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy

- name: Restore Rust Cache
uses: Swatinem/rust-cache@v2

- name: Run cargo test
run: cargo test --all-features --all
env:
RUSTFLAGS: '--cfg releasing'

test-native-msrv:
name: Run Native Tests (MSRV)
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4

- name: Setup Rust
uses: dtolnay/[email protected]
with:
components: rustfmt, clippy

- name: Restore Rust Cache
uses: Swatinem/rust-cache@v2

# We only run tests on core packages, examples can be upgraded to be incompatible of msrv.
- name: Run cargo test
run: |
cargo test --all-features --package stylist-core
cargo test --all-features --package stylist-macros
cargo test --all-features --package stylist
cargo test -p stylist --all-features
cargo test -p stylist-core --all-features
cargo test -p stylist-macros --all-features
env:
RUSTFLAGS: '--cfg releasing'

Expand All @@ -107,7 +94,7 @@ jobs:
with:
version: 'latest'

- name: Run cargo build --all --target=wasm32-unknown-unknown
- name: Build WASM
run: cargo build --all --target=wasm32-unknown-unknown
env:
RUSTFLAGS: '--cfg releasing'
Expand All @@ -126,8 +113,7 @@ jobs:
needs:
- lint
- rustfmt
- test-native-stable
- test-native-msrv
- test-native
- test-web
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
steps:
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,30 @@ This is a fork of [css-in-rust](https://github.com/lukidoescode/css-in-rust).

## Install

Add the following to your `Cargo.toml`:
Add the following to your `Cargo.toml` if you want to use it in a browser environment:

```toml
stylist = "0.13"
```

Maybe you want to use `yew` integration:

```toml
stylist = { version = "0.13", features = ["yew_integration"]}
```

If you want to render styles on the server side, use `ssr` and `hydration` features:

```toml
stylist = { version = "0.13", features = ["yew_integration", "ssr", "hydration"]}
```

If you want to run inside a non-web WASM environment, such as [Cloudflare Worker](https://workers.cloudflare.com), use `not_browser_env` feature:

```toml
stylist = { version = "0.13", features = ["not_browser_env"]}
```

## Usage

For detailed usage, please see
Expand Down
4 changes: 2 additions & 2 deletions examples/benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ stylist = { path = "../../packages/stylist", features = [
"yew_integration",
"parser",
] }
web-sys = { version = "0.3.60", features = ["Window", "Performance"] }
gloo = "0.10.0"
web-sys = { version = "0.3.70", features = ["Window", "Performance"] }
gloo = "0.11.0"
22 changes: 11 additions & 11 deletions examples/benchmarks/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,47 +251,47 @@ impl Component for Benchmarks {
<tbody>
<tr>
<th>{"Parse Simple (10,000,000 iterations): "}</th>
<th>{self.parse_simple.map(|m| {format!("{:.0}ms", m)}).unwrap_or_else(|| "".to_string())}</th>
<th>{self.parse_simple.map(|m| {format!("{:.0}ms", m)}).unwrap_or_default()}</th>
</tr>
<tr>
<th>{"Macro (Literal) Simple (10,000,000 iterations): "}</th>
<th>{self.macro_simple.map(|m| {format!("{:.0}ms", m)}).unwrap_or_else(|| "".to_string())}</th>
<th>{self.macro_simple.map(|m| {format!("{:.0}ms", m)}).unwrap_or_default()}</th>
</tr>
<tr>
<th>{"Macro (Inline) Simple (10,000,000 iterations): "}</th>
<th>{self.macro_inline_simple.map(|m| {format!("{:.0}ms", m)}).unwrap_or_else(|| "".to_string())}</th>
<th>{self.macro_inline_simple.map(|m| {format!("{:.0}ms", m)}).unwrap_or_default()}</th>
</tr>
<tr>
<th>{"Parse Simple, No Cache (100,000 iterations): "}</th>
<th>{self.parse_simple_no_cache.map(|m| {format!("{:.0}ms", m)}).unwrap_or_else(|| "".to_string())}</th>
<th>{self.parse_simple_no_cache.map(|m| {format!("{:.0}ms", m)}).unwrap_or_default()}</th>
</tr>
<tr>
<th>{"Parse Complex (1,000,000 iterations): "}</th>
<th>{self.parse_complex.map(|m| {format!("{:.0}ms", m)}).unwrap_or_else(|| "".to_string())}</th>
<th>{self.parse_complex.map(|m| {format!("{:.0}ms", m)}).unwrap_or_default()}</th>
</tr>
<tr>
<th>{"Macro (Literal) Complex (1,000,000 iterations): "}</th>
<th>{self.macro_complex.map(|m| {format!("{:.0}ms", m)}).unwrap_or_else(|| "".to_string())}</th>
<th>{self.macro_complex.map(|m| {format!("{:.0}ms", m)}).unwrap_or_default()}</th>
</tr>
<tr>
<th>{"Macro (Inline) Complex (1,000,000 iterations): "}</th>
<th>{self.macro_inline_complex.map(|m| {format!("{:.0}ms", m)}).unwrap_or_else(|| "".to_string())}</th>
<th>{self.macro_inline_complex.map(|m| {format!("{:.0}ms", m)}).unwrap_or_default()}</th>
</tr>
<tr>
<th>{"Parse Complex, No Cache (100,000 iterations): "}</th>
<th>{self.parse_complex_no_cache.map(|m| {format!("{:.0}ms", m)}).unwrap_or_else(|| "".to_string())}</th>
<th>{self.parse_complex_no_cache.map(|m| {format!("{:.0}ms", m)}).unwrap_or_default()}</th>
</tr>
<tr>
<th>{"Cached Lookup (1,000,000 iterations): "}</th>
<th>{self.cached_lookup.map(|m| {format!("{:.0}ms", m)}).unwrap_or_else(|| "".to_string())}</th>
<th>{self.cached_lookup.map(|m| {format!("{:.0}ms", m)}).unwrap_or_default()}</th>
</tr>
<tr>
<th>{"Cached Lookup, Big Sheet (100,000 iterations): "}</th>
<th>{self.cached_lookup_big_sheet.map(|m| {format!("{:.0}ms", m)}).unwrap_or_else(|| "".to_string())}</th>
<th>{self.cached_lookup_big_sheet.map(|m| {format!("{:.0}ms", m)}).unwrap_or_default()}</th>
</tr>
<tr>
<th>{"Mounting (2,000 iterations): "}</th>
<th>{self.mounting.map(|m| {format!("{:.0}ms", m)}).unwrap_or_else(|| "".to_string())}</th>
<th>{self.mounting.map(|m| {format!("{:.0}ms", m)}).unwrap_or_default()}</th>
</tr>
</tbody>
</table>
Expand Down
4 changes: 2 additions & 2 deletions examples/use-media-query/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ stylist = { path = "../../packages/stylist", features = [
[dev-dependencies]
gloo-utils = "0.2.0"
wasm-bindgen-test = "0.3.33"
wasm-bindgen = "0.2.83"
wasm-bindgen = "0.2.93"

[dev-dependencies.web-sys]
version = "0.3.60"
version = "0.3.70"
features = [
"Window",
"Document",
Expand Down
4 changes: 2 additions & 2 deletions examples/yew-integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ stylist = { path = "../../packages/stylist", features = ["yew_integration"] }
gloo-utils = "0.2.0"
gloo-timers = { version = "0.3.0", features = ["futures"] }
wasm-bindgen-test = "0.3.33"
wasm-bindgen = "0.2.83"
wasm-bindgen = "0.2.93"

[dev-dependencies.web-sys]
version = "0.3.60"
version = "0.3.70"
features = [
"Window",
"Document",
Expand Down
4 changes: 2 additions & 2 deletions examples/yew-proc-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ stylist = { path = "../../packages/stylist", default-features = false, features
[dev-dependencies]
gloo-utils = "0.2.0"
wasm-bindgen-test = "0.3.33"
wasm-bindgen = "0.2.83"
wasm-bindgen = "0.2.93"

[dev-dependencies.web-sys]
version = "0.3.60"
version = "0.3.70"
features = [
"Window",
"Document",
Expand Down
2 changes: 1 addition & 1 deletion examples/yew-shadow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ stylist = { path = "../../packages/stylist", features = ["yew_integration"] }
once_cell = "1.16.0"

[dependencies.web-sys]
version = "0.3.60"
version = "0.3.70"
features = [
"Window",
"Document",
Expand Down
8 changes: 4 additions & 4 deletions examples/yew-ssr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ console_log = { version = "1.0.0", features = ["color"] }
yew = { version = "0.21" }
stylist = { path = "../../packages/stylist", features = ["yew_integration"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
[target.'cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))'.dependencies]
tokio = { version = "1.22.0", features = ["full"] }
env_logger = "0.10"
env_logger = "0.11"
clap = { version = "4.0.29", features = ["derive"] }
warp = "0.3"

[dev-dependencies]
gloo-utils = "0.2.0"
gloo-timers = { version = "0.3.0", features = ["futures"] }
wasm-bindgen-test = "0.3.33"
wasm-bindgen = "0.2.83"
wasm-bindgen = "0.2.93"
yew = { version = "0.21", features = ["csr", "ssr", "hydration"] }
stylist = { path = "../../packages/stylist", features = [
"yew_integration",
Expand All @@ -38,7 +38,7 @@ stylist = { path = "../../packages/stylist", features = [
] }

[dev-dependencies.web-sys]
version = "0.3.60"
version = "0.3.70"
features = [
"Window",
"Document",
Expand Down
4 changes: 2 additions & 2 deletions examples/yew-theme-context/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ once_cell = "1.16.0"
[dev-dependencies]
gloo-utils = "0.2.0"
wasm-bindgen-test = "0.3.33"
wasm-bindgen = "0.2.83"
wasm-bindgen = "0.2.93"

[dev-dependencies.web-sys]
version = "0.3.60"
version = "0.3.70"
features = [
"Window",
"Document",
Expand Down
4 changes: 2 additions & 2 deletions examples/yew-theme-hooks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ once_cell = "1.16.0"
[dev-dependencies]
gloo-utils = "0.2.0"
wasm-bindgen-test = "0.3.33"
wasm-bindgen = "0.2.83"
wasm-bindgen = "0.2.93"

[dev-dependencies.web-sys]
version = "0.3.60"
version = "0.3.70"
features = [
"Window",
"Document",
Expand Down
6 changes: 3 additions & 3 deletions packages/stylist-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ categories = ["wasm", "web-programming"]
readme = "README.md"
homepage = "https://github.com/futursolo/stylist-rs"
resolver = "2"
rust-version = "1.66.0"
rust-version = "1.67.0"

[dependencies]
nom = { version = "7.1.1", optional = true }
thiserror = "1.0.37"
wasm-bindgen = "0.2.83"
wasm-bindgen = "^0.2.88"
once_cell = "1.16.0"
serde = { version = "1", features = ["derive"] }

[dev-dependencies]
log = "0.4.17"
env_logger = "0.10.0"

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dev-dependencies]
wasm-bindgen-test = "0.3.33"

[features]
Expand Down
1 change: 0 additions & 1 deletion packages/stylist-core/src/ast/sheet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ impl ToStyleStr for Sheet {
}
}

#[cfg_attr(documenting, doc(cfg(feature = "parser")))]
#[cfg(feature = "parser")]
mod feat_parser {
use once_cell::sync::Lazy;
Expand Down
1 change: 0 additions & 1 deletion packages/stylist-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type JsValue = ();
#[derive(Debug, Error, PartialEq)]
pub enum Error {
/// Failed to parse CSS.
#[cfg_attr(documenting, doc(cfg(feature = "parser")))]
#[cfg(feature = "parser")]
#[error("Failed to Parse CSS, due to:\n{}", .reason)]
Parse {
Expand Down
4 changes: 1 addition & 3 deletions packages/stylist-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
#![deny(unsafe_code)]
#![deny(non_snake_case)]
#![deny(clippy::cognitive_complexity)]
#![cfg_attr(documenting, feature(doc_cfg))]
#![cfg_attr(any(releasing, not(debug_assertions)), deny(dead_code, unused_imports))]
#![cfg_attr(any(doc, not(debug_assertions)), deny(dead_code, unused_imports))]

mod error;
pub use error::{Error, Result, ResultDisplay};
pub mod ast;
pub mod bow;

#[cfg_attr(documenting, doc(cfg(feature = "parser")))]
#[cfg(feature = "parser")]
mod parser;

Expand Down
6 changes: 3 additions & 3 deletions packages/stylist-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ categories = ["wasm", "web-programming"]
readme = "README.md"
homepage = "https://github.com/futursolo/stylist-rs"
resolver = "2"
rust-version = "1.66.0"
rust-version = "1.67.0"

[lib]
proc-macro = true
Expand All @@ -29,13 +29,13 @@ syn = { version = "2", features = ["full", "extra-traits"] }
itertools = "0.11.0"
log = "0.4.17"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
[target.'cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))'.dependencies]
stylist-core = { path = "../stylist-core", version = "0.13", features = [
"parser",
"__proc_macro_workaround",
] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies]
stylist-core = { path = "../stylist-core", version = "0.13", features = [
"parser",
] }
Expand Down
2 changes: 1 addition & 1 deletion packages/stylist-macros/src/inline/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod rule;
mod scope;
mod scope_content;

pub use attribute::{CssAttribute, CssAttributeName, CssAttributeValue};
pub use attribute::CssAttribute;
pub use block::CssQualifiedRule;
pub use qualifier::CssBlockQualifier;
pub use root::CssRootNode;
Expand Down
Loading