Skip to content

Commit

Permalink
Publish v0.10.0-alpha.5
Browse files Browse the repository at this point in the history
  • Loading branch information
matthunz committed Jan 8, 2024
1 parent c1c963b commit 27535d4
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "viewbuilder"
version = "0.10.0-alpha.4"
version = "0.10.0-alpha.5"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Cross-platform UI framework"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -22,7 +22,7 @@

A cross-platform user interface framework for Rust.

Viewbuilder is a moduler GUI library that can be used as an entire framework, or with individual parts.
Viewbuilder is a modular GUI library that can be used as an entire framework, or with individual parts.

```rust
use viewbuilder::{
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
@@ -1,6 +1,6 @@
//! A high performance UI framework.
//!
//! Viewbuilder is a moduler GUI library that can be used as an entire framework,
//! Viewbuilder is a modular GUI library that can be used as an entire framework,
//! or with individual parts.
//!
//! ## Features
Expand Down Expand Up @@ -61,7 +61,7 @@ pub trait Model<M> {
}

#[cfg(feature = "tracing")]
#[cfg_attr(docsrs, doc_cfg(feature = "tracing"))]
#[cfg_attr(docsrs, doc(cfg(feature = "tracing")))]
#[macro_export]
macro_rules! build_span {
($name:tt) => {
Expand All @@ -70,7 +70,7 @@ macro_rules! build_span {
}

#[cfg(feature = "tracing")]
#[cfg_attr(docsrs, doc_cfg(feature = "tracing"))]
#[cfg_attr(docsrs, doc(cfg(feature = "tracing")))]
#[macro_export]
macro_rules! rebuild_span {
($name:tt) => {
Expand All @@ -79,7 +79,7 @@ macro_rules! rebuild_span {
}

#[cfg(feature = "tracing")]
#[cfg_attr(docsrs, doc_cfg(feature = "tracing"))]
#[cfg_attr(docsrs, doc(cfg(feature = "tracing")))]
#[macro_export]
macro_rules! remove_span {
($name:tt) => {
Expand All @@ -88,7 +88,7 @@ macro_rules! remove_span {
}

#[cfg(feature = "tracing")]
#[cfg_attr(docsrs, doc_cfg(feature = "tracing"))]
#[cfg_attr(docsrs, doc(cfg(feature = "tracing")))]
#[macro_export]
macro_rules! span {
($method:tt, $name:tt) => {
Expand Down
44 changes: 44 additions & 0 deletions src/web/html.rs
Expand Up @@ -167,6 +167,7 @@ where
_tree: &mut HtmlAttributes,
_element: &mut Self::Element,
) {

}

fn remove(
Expand Down Expand Up @@ -266,3 +267,46 @@ where

fn remove(&mut self, _cx: &mut Context<M>, _state: &mut StyleTree, _element: Self::Element) {}
}

pub fn class<T>(name: T) -> Class<T>
where
T: AsRef<str> + PartialEq+ Clone,
{
Class { name }
}

pub struct Class<T> {
name: T,
}

impl<M, T> View<HtmlAttributes, M> for Class<T>
where
T: AsRef<str> + PartialEq + Clone,
{
type Element = T;

fn build(&mut self, cx: &mut Context<M>, tree: &mut HtmlAttributes) -> Self::Element {
tree.element.set_class_name(self.name.as_ref());
self.name.clone()
}

fn rebuild(
&mut self,
_cx: &mut Context<M>,
tree: &mut HtmlAttributes,
element: &mut Self::Element,
) {
if &self.name != &*element {
*element = self.name.clone();
tree.element.set_class_name(self.name.as_ref());
}
}

fn remove(
&mut self,
_cx: &mut Context<M>,
_state: &mut HtmlAttributes,
_element: Self::Element,
) {
}
}

0 comments on commit 27535d4

Please sign in to comment.