mirror of
https://github.com/yewprint/yewprint
synced 2024-11-22 11:33:04 +00:00
Remove Boolinator (#88)
* Remove use statement for boolinator * Replace boolinator as_some method by bool then method * Replace boolinator and_option method by bool then method
This commit is contained in:
parent
1f94b2821d
commit
70d9a394a9
16 changed files with 43 additions and 60 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -795,7 +795,6 @@ dependencies = [
|
||||||
name = "yewprint"
|
name = "yewprint"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"boolinator",
|
|
||||||
"heck",
|
"heck",
|
||||||
"id_tree",
|
"id_tree",
|
||||||
"regex",
|
"regex",
|
||||||
|
|
|
@ -20,9 +20,6 @@ yew = { git = "https://github.com/yewstack/yew.git", rev = "db3170f629f" }
|
||||||
web-sys = "0.3"
|
web-sys = "0.3"
|
||||||
id_tree = { version = "1.7", optional = true }
|
id_tree = { version = "1.7", optional = true }
|
||||||
yewtil = { git = "https://github.com/yewstack/yew.git", rev = "db3170f629f", features = ["pure"] }
|
yewtil = { git = "https://github.com/yewstack/yew.git", rev = "db3170f629f", features = ["pure"] }
|
||||||
# NOTE: this dependency needs to be removed when the feature bool_to_option lands in stable
|
|
||||||
# https://github.com/rust-lang/rust/issues/64260
|
|
||||||
boolinator = "2.4.0"
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
regex = { version = "1", default-features = false, features = ["std", "unicode-perl"] }
|
regex = { version = "1", default-features = false, features = ["std", "unicode-perl"] }
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use boolinator::Boolinator;
|
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
pub struct ButtonGroup {
|
pub struct ButtonGroup {
|
||||||
|
@ -47,10 +46,10 @@ impl Component for ButtonGroup {
|
||||||
<div
|
<div
|
||||||
class=classes!(
|
class=classes!(
|
||||||
"bp3-button-group",
|
"bp3-button-group",
|
||||||
self.props.minimal.as_some("bp3-minimal"),
|
self.props.minimal.then(|| "bp3-minimal"),
|
||||||
self.props.fill.as_some("bp3-fill"),
|
self.props.fill.then(|| "bp3-fill"),
|
||||||
self.props.large.as_some("bp3-large"),
|
self.props.large.then(|| "bp3-large"),
|
||||||
self.props.vertical.as_some("bp3-vertical"),
|
self.props.vertical.then(|| "bp3-vertical"),
|
||||||
)
|
)
|
||||||
style?=self.props.style.clone()
|
style?=self.props.style.clone()
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::{Icon, IconName, Intent};
|
use crate::{Icon, IconName, Intent};
|
||||||
use boolinator::Boolinator;
|
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
pub struct Button {
|
pub struct Button {
|
||||||
|
@ -54,9 +53,9 @@ impl Component for Button {
|
||||||
<button
|
<button
|
||||||
class=classes!(
|
class=classes!(
|
||||||
"bp3-button",
|
"bp3-button",
|
||||||
self.props.fill.as_some("bp3-fill"),
|
self.props.fill.then(|| "bp3-fill"),
|
||||||
self.props.minimal.as_some("bp3-minimal"),
|
self.props.minimal.then(|| "bp3-minimal"),
|
||||||
self.props.disabled.as_some("bp3-disabled"),
|
self.props.disabled.then(|| "bp3-disabled"),
|
||||||
self.props.intent,
|
self.props.intent,
|
||||||
self.props.class.clone(),
|
self.props.class.clone(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::Elevation;
|
use crate::Elevation;
|
||||||
use boolinator::Boolinator;
|
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Properties)]
|
#[derive(Clone, PartialEq, Properties)]
|
||||||
|
@ -46,7 +45,7 @@ impl Component for Card {
|
||||||
"bp3-card",
|
"bp3-card",
|
||||||
self.props.class.clone(),
|
self.props.class.clone(),
|
||||||
self.props.elevation,
|
self.props.elevation,
|
||||||
self.props.interactive.as_some("bp3-interactive"),
|
self.props.interactive.then(|| "bp3-interactive"),
|
||||||
)
|
)
|
||||||
onclick={self.props.onclick.clone()}>
|
onclick={self.props.onclick.clone()}>
|
||||||
{self.props.children.clone()}
|
{self.props.children.clone()}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use boolinator::Boolinator;
|
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
pub struct ControlGroup {
|
pub struct ControlGroup {
|
||||||
|
@ -41,8 +40,8 @@ impl Component for ControlGroup {
|
||||||
<div
|
<div
|
||||||
class=classes!(
|
class=classes!(
|
||||||
"bp3-control-group",
|
"bp3-control-group",
|
||||||
self.props.fill.as_some("bp3-fill"),
|
self.props.fill.then(|| "bp3-fill"),
|
||||||
self.props.vertical.as_some("bp3-vertical"),
|
self.props.vertical.then(|| "bp3-vertical"),
|
||||||
)
|
)
|
||||||
>
|
>
|
||||||
{self.props.children.clone()}
|
{self.props.children.clone()}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use boolinator::Boolinator;
|
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
pub struct Divider {
|
pub struct Divider {
|
||||||
|
@ -39,7 +38,7 @@ impl Component for Divider {
|
||||||
<span
|
<span
|
||||||
class=classes!(
|
class=classes!(
|
||||||
"bp3-divider",
|
"bp3-divider",
|
||||||
self.props.vertical.as_some("bp3-vertical"),
|
self.props.vertical.then(|| "bp3-vertical"),
|
||||||
)
|
)
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::{Icon, IconName};
|
use crate::{Icon, IconName};
|
||||||
use boolinator::Boolinator;
|
|
||||||
use std::collections::hash_map::DefaultHasher;
|
use std::collections::hash_map::DefaultHasher;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
@ -91,10 +90,10 @@ impl<T: Clone + PartialEq + Hash + 'static> Component for HtmlSelect<T> {
|
||||||
<div
|
<div
|
||||||
class=classes!(
|
class=classes!(
|
||||||
"bp3-html-select",
|
"bp3-html-select",
|
||||||
self.props.minimal.as_some("bp3-minimal"),
|
self.props.minimal.then(|| "bp3-minimal"),
|
||||||
self.props.large.as_some("bp3-large"),
|
self.props.large.then(|| "bp3-large"),
|
||||||
self.props.fill.as_some("bp3-fill"),
|
self.props.fill.then(|| "bp3-fill"),
|
||||||
self.props.disabled.as_some("bp3-disabled"),
|
self.props.disabled.then(|| "bp3-disabled"),
|
||||||
)
|
)
|
||||||
>
|
>
|
||||||
<select
|
<select
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::{Icon, IconName};
|
use crate::{Icon, IconName};
|
||||||
use boolinator::Boolinator;
|
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
pub struct InputGroup {
|
pub struct InputGroup {
|
||||||
|
@ -95,11 +94,11 @@ impl Component for InputGroup {
|
||||||
<div
|
<div
|
||||||
class=classes!(
|
class=classes!(
|
||||||
"bp3-input-group",
|
"bp3-input-group",
|
||||||
self.props.disabled.as_some("bp3-disabled"),
|
self.props.disabled.then(|| "bp3-disabled"),
|
||||||
self.props.fill.as_some("bp3-fill"),
|
self.props.fill.then(|| "bp3-fill"),
|
||||||
self.props.large.as_some("bp3-large"),
|
self.props.large.then(|| "bp3-large"),
|
||||||
self.props.small.as_some("bp3-small"),
|
self.props.small.then(|| "bp3-small"),
|
||||||
self.props.round.as_some("bp3-round"),
|
self.props.round.then(|| "bp3-round"),
|
||||||
self.props.placeholder.clone()
|
self.props.placeholder.clone()
|
||||||
)
|
)
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::{Icon, IconName, Intent, H6};
|
use crate::{Icon, IconName, Intent, H6};
|
||||||
use boolinator::Boolinator;
|
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
pub struct Menu {
|
pub struct Menu {
|
||||||
|
@ -43,7 +42,7 @@ impl Component for Menu {
|
||||||
<ul
|
<ul
|
||||||
class=classes!(
|
class=classes!(
|
||||||
"bp3-menu",
|
"bp3-menu",
|
||||||
self.props.large.as_some("bp3-large"),
|
self.props.large.then(|| "bp3-large"),
|
||||||
self.props.class.clone(),
|
self.props.class.clone(),
|
||||||
)
|
)
|
||||||
ref={self.props.r#ref.clone()}
|
ref={self.props.r#ref.clone()}
|
||||||
|
@ -114,14 +113,14 @@ impl Component for MenuItem {
|
||||||
<a
|
<a
|
||||||
class=classes!(
|
class=classes!(
|
||||||
"bp3-menu-item",
|
"bp3-menu-item",
|
||||||
self.props.active.as_some("bp3-active"),
|
self.props.active.then(|| "bp3-active"),
|
||||||
self.props.disabled.as_some("bp3-disabled"),
|
self.props.disabled.then(|| "bp3-disabled"),
|
||||||
self.props.intent
|
self.props.intent
|
||||||
.or_else(|| self.props.active.as_some(Intent::Primary)),
|
.or_else(|| self.props.active.then(|| Intent::Primary)),
|
||||||
self.props.class.clone(),
|
self.props.class.clone(),
|
||||||
)
|
)
|
||||||
href?={(!self.props.disabled).and_option(self.props.href.clone())}
|
href?={(!self.props.disabled).then(|| self.props.href.clone())}.flatten()
|
||||||
tabIndex?={(!self.props.disabled).as_some(0)}
|
tabIndex?={(!self.props.disabled).then(|| 0)}
|
||||||
onclick={self.props.onclick.clone()}
|
onclick={self.props.onclick.clone()}
|
||||||
>
|
>
|
||||||
<Icon icon={self.props.icon} />
|
<Icon icon={self.props.icon} />
|
||||||
|
@ -143,6 +142,7 @@ impl Component for MenuItem {
|
||||||
html!()
|
html!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::Intent;
|
use crate::Intent;
|
||||||
use boolinator::Boolinator;
|
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
pub struct ProgressBar {
|
pub struct ProgressBar {
|
||||||
|
@ -53,8 +52,8 @@ impl Component for ProgressBar {
|
||||||
class=classes!(
|
class=classes!(
|
||||||
"bp3-progress-bar",
|
"bp3-progress-bar",
|
||||||
self.props.intent,
|
self.props.intent,
|
||||||
(!self.props.animate).as_some("bp3-no-animation"),
|
(!self.props.animate).then(|| "bp3-no-animation"),
|
||||||
(!self.props.stripes).as_some("bp3-no-stripes")
|
(!self.props.stripes).then(|| "bp3-no-stripes")
|
||||||
)
|
)
|
||||||
>
|
>
|
||||||
<div class=classes!("bp3-progress-meter") style={{width}}/>
|
<div class=classes!("bp3-progress-meter") style={{width}}/>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use boolinator::Boolinator;
|
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
pub struct Switch {
|
pub struct Switch {
|
||||||
|
@ -48,9 +47,9 @@ impl Component for Switch {
|
||||||
class=classes!(
|
class=classes!(
|
||||||
"bp3-control",
|
"bp3-control",
|
||||||
"bp3-switch",
|
"bp3-switch",
|
||||||
self.props.disabled.as_some("bp3-disabled"),
|
self.props.disabled.then(|| "bp3-disabled"),
|
||||||
self.props.inline.as_some("bp3-inline"),
|
self.props.inline.then(|| "bp3-inline"),
|
||||||
self.props.large.as_some("bp3-large"),
|
self.props.large.then(|| "bp3-large"),
|
||||||
)
|
)
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use boolinator::Boolinator;
|
|
||||||
use std::collections::{hash_map::DefaultHasher, HashMap};
|
use std::collections::{hash_map::DefaultHasher, HashMap};
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use web_sys::HtmlElement;
|
use web_sys::HtmlElement;
|
||||||
|
@ -93,14 +92,14 @@ impl<T: Clone + PartialEq + Hash + 'static> Component for Tabs<T> {
|
||||||
<div
|
<div
|
||||||
class=classes!(
|
class=classes!(
|
||||||
"bp3-tabs",
|
"bp3-tabs",
|
||||||
self.props.vertical.as_some("bp3-vertical"),
|
self.props.vertical.then(|| "bp3-vertical"),
|
||||||
self.props.class.clone(),
|
self.props.class.clone(),
|
||||||
)
|
)
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class=classes!(
|
class=classes!(
|
||||||
"bp3-tab-list",
|
"bp3-tab-list",
|
||||||
self.props.large.as_some("bp3-large"),
|
self.props.large.then(|| "bp3-large"),
|
||||||
)
|
)
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::{if_html, Icon, IconName, Intent, Text};
|
use crate::{if_html, Icon, IconName, Intent, Text};
|
||||||
use boolinator::Boolinator;
|
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
pub struct Tag {
|
pub struct Tag {
|
||||||
|
@ -74,7 +73,7 @@ impl Component for Tag {
|
||||||
<button
|
<button
|
||||||
class=classes!("bp3-tag-remove")
|
class=classes!("bp3-tag-remove")
|
||||||
onclick={callback}
|
onclick={callback}
|
||||||
tabindex?={self.props.interactive.as_some(0)}
|
tabindex?={self.props.interactive.then(|| 0)}
|
||||||
>
|
>
|
||||||
<Icon icon=IconName::SmallCross />
|
<Icon icon=IconName::SmallCross />
|
||||||
</button>
|
</button>
|
||||||
|
@ -86,12 +85,12 @@ impl Component for Tag {
|
||||||
class=classes!(
|
class=classes!(
|
||||||
"bp3-tag",
|
"bp3-tag",
|
||||||
self.props.intent,
|
self.props.intent,
|
||||||
self.props.active.as_some("bp3-active"),
|
self.props.active.then(|| "bp3-active"),
|
||||||
self.props.fill.as_some("bp3-fill"),
|
self.props.fill.then(|| "bp3-fill"),
|
||||||
self.props.interactive.as_some("bp3-interactive"),
|
self.props.interactive.then(|| "bp3-interactive"),
|
||||||
self.props.large.as_some("bp3-large"),
|
self.props.large.then(|| "bp3-large"),
|
||||||
self.props.minimal.as_some("bp3-minimal"),
|
self.props.minimal.then(|| "bp3-minimal"),
|
||||||
self.props.round.as_some("bp3-round"),
|
self.props.round.then(|| "bp3-round"),
|
||||||
self.props.class.clone(),
|
self.props.class.clone(),
|
||||||
)
|
)
|
||||||
onclick={self.props.onclick.clone()}
|
onclick={self.props.onclick.clone()}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use boolinator::Boolinator;
|
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
pub struct Text {
|
pub struct Text {
|
||||||
|
@ -46,7 +45,7 @@ impl Component for Text {
|
||||||
<@{if self.props.inline { "span" } else { "div"}}
|
<@{if self.props.inline { "span" } else { "div"}}
|
||||||
class=classes!(
|
class=classes!(
|
||||||
self.props.class.clone(),
|
self.props.class.clone(),
|
||||||
self.props.ellipsize.as_some("bp3-text-overflow-ellipsis"),
|
self.props.ellipsize.then (|| "bp3-text-overflow-ellipsis"),
|
||||||
)
|
)
|
||||||
title?=self.props.title.clone()
|
title?=self.props.title.clone()
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::collapse::Collapse;
|
use crate::collapse::Collapse;
|
||||||
use crate::icon::{Icon, IconName};
|
use crate::icon::{Icon, IconName};
|
||||||
use crate::Intent;
|
use crate::Intent;
|
||||||
use boolinator::Boolinator;
|
|
||||||
use id_tree::*;
|
use id_tree::*;
|
||||||
use std::cell::{Ref, RefCell, RefMut};
|
use std::cell::{Ref, RefCell, RefMut};
|
||||||
use std::collections::hash_map::DefaultHasher;
|
use std::collections::hash_map::DefaultHasher;
|
||||||
|
@ -312,7 +311,7 @@ impl Component for TreeNode {
|
||||||
html! {
|
html! {
|
||||||
<li class=classes!(
|
<li class=classes!(
|
||||||
"bp3-tree-node",
|
"bp3-tree-node",
|
||||||
self.props.is_selected.as_some("bp3-tree-node-selected")
|
self.props.is_selected.then(|| "bp3-tree-node-selected")
|
||||||
)>
|
)>
|
||||||
<div
|
<div
|
||||||
class="bp3-tree-node-content"
|
class="bp3-tree-node-content"
|
||||||
|
|
Loading…
Reference in a new issue