mirror of
https://github.com/yewprint/yewprint
synced 2024-11-22 03:23:03 +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"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"boolinator",
|
||||
"heck",
|
||||
"id_tree",
|
||||
"regex",
|
||||
|
|
|
@ -20,9 +20,6 @@ yew = { git = "https://github.com/yewstack/yew.git", rev = "db3170f629f" }
|
|||
web-sys = "0.3"
|
||||
id_tree = { version = "1.7", optional = true }
|
||||
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]
|
||||
regex = { version = "1", default-features = false, features = ["std", "unicode-perl"] }
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use boolinator::Boolinator;
|
||||
use yew::prelude::*;
|
||||
|
||||
pub struct ButtonGroup {
|
||||
|
@ -47,10 +46,10 @@ impl Component for ButtonGroup {
|
|||
<div
|
||||
class=classes!(
|
||||
"bp3-button-group",
|
||||
self.props.minimal.as_some("bp3-minimal"),
|
||||
self.props.fill.as_some("bp3-fill"),
|
||||
self.props.large.as_some("bp3-large"),
|
||||
self.props.vertical.as_some("bp3-vertical"),
|
||||
self.props.minimal.then(|| "bp3-minimal"),
|
||||
self.props.fill.then(|| "bp3-fill"),
|
||||
self.props.large.then(|| "bp3-large"),
|
||||
self.props.vertical.then(|| "bp3-vertical"),
|
||||
)
|
||||
style?=self.props.style.clone()
|
||||
>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::{Icon, IconName, Intent};
|
||||
use boolinator::Boolinator;
|
||||
use yew::prelude::*;
|
||||
|
||||
pub struct Button {
|
||||
|
@ -54,9 +53,9 @@ impl Component for Button {
|
|||
<button
|
||||
class=classes!(
|
||||
"bp3-button",
|
||||
self.props.fill.as_some("bp3-fill"),
|
||||
self.props.minimal.as_some("bp3-minimal"),
|
||||
self.props.disabled.as_some("bp3-disabled"),
|
||||
self.props.fill.then(|| "bp3-fill"),
|
||||
self.props.minimal.then(|| "bp3-minimal"),
|
||||
self.props.disabled.then(|| "bp3-disabled"),
|
||||
self.props.intent,
|
||||
self.props.class.clone(),
|
||||
)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::Elevation;
|
||||
use boolinator::Boolinator;
|
||||
use yew::prelude::*;
|
||||
|
||||
#[derive(Clone, PartialEq, Properties)]
|
||||
|
@ -46,7 +45,7 @@ impl Component for Card {
|
|||
"bp3-card",
|
||||
self.props.class.clone(),
|
||||
self.props.elevation,
|
||||
self.props.interactive.as_some("bp3-interactive"),
|
||||
self.props.interactive.then(|| "bp3-interactive"),
|
||||
)
|
||||
onclick={self.props.onclick.clone()}>
|
||||
{self.props.children.clone()}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use boolinator::Boolinator;
|
||||
use yew::prelude::*;
|
||||
|
||||
pub struct ControlGroup {
|
||||
|
@ -41,8 +40,8 @@ impl Component for ControlGroup {
|
|||
<div
|
||||
class=classes!(
|
||||
"bp3-control-group",
|
||||
self.props.fill.as_some("bp3-fill"),
|
||||
self.props.vertical.as_some("bp3-vertical"),
|
||||
self.props.fill.then(|| "bp3-fill"),
|
||||
self.props.vertical.then(|| "bp3-vertical"),
|
||||
)
|
||||
>
|
||||
{self.props.children.clone()}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use boolinator::Boolinator;
|
||||
use yew::prelude::*;
|
||||
|
||||
pub struct Divider {
|
||||
|
@ -39,7 +38,7 @@ impl Component for Divider {
|
|||
<span
|
||||
class=classes!(
|
||||
"bp3-divider",
|
||||
self.props.vertical.as_some("bp3-vertical"),
|
||||
self.props.vertical.then(|| "bp3-vertical"),
|
||||
)
|
||||
/>
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::{Icon, IconName};
|
||||
use boolinator::Boolinator;
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use yew::prelude::*;
|
||||
|
@ -91,10 +90,10 @@ impl<T: Clone + PartialEq + Hash + 'static> Component for HtmlSelect<T> {
|
|||
<div
|
||||
class=classes!(
|
||||
"bp3-html-select",
|
||||
self.props.minimal.as_some("bp3-minimal"),
|
||||
self.props.large.as_some("bp3-large"),
|
||||
self.props.fill.as_some("bp3-fill"),
|
||||
self.props.disabled.as_some("bp3-disabled"),
|
||||
self.props.minimal.then(|| "bp3-minimal"),
|
||||
self.props.large.then(|| "bp3-large"),
|
||||
self.props.fill.then(|| "bp3-fill"),
|
||||
self.props.disabled.then(|| "bp3-disabled"),
|
||||
)
|
||||
>
|
||||
<select
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::{Icon, IconName};
|
||||
use boolinator::Boolinator;
|
||||
use yew::prelude::*;
|
||||
|
||||
pub struct InputGroup {
|
||||
|
@ -95,11 +94,11 @@ impl Component for InputGroup {
|
|||
<div
|
||||
class=classes!(
|
||||
"bp3-input-group",
|
||||
self.props.disabled.as_some("bp3-disabled"),
|
||||
self.props.fill.as_some("bp3-fill"),
|
||||
self.props.large.as_some("bp3-large"),
|
||||
self.props.small.as_some("bp3-small"),
|
||||
self.props.round.as_some("bp3-round"),
|
||||
self.props.disabled.then(|| "bp3-disabled"),
|
||||
self.props.fill.then(|| "bp3-fill"),
|
||||
self.props.large.then(|| "bp3-large"),
|
||||
self.props.small.then(|| "bp3-small"),
|
||||
self.props.round.then(|| "bp3-round"),
|
||||
self.props.placeholder.clone()
|
||||
)
|
||||
>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::{Icon, IconName, Intent, H6};
|
||||
use boolinator::Boolinator;
|
||||
use yew::prelude::*;
|
||||
|
||||
pub struct Menu {
|
||||
|
@ -43,7 +42,7 @@ impl Component for Menu {
|
|||
<ul
|
||||
class=classes!(
|
||||
"bp3-menu",
|
||||
self.props.large.as_some("bp3-large"),
|
||||
self.props.large.then(|| "bp3-large"),
|
||||
self.props.class.clone(),
|
||||
)
|
||||
ref={self.props.r#ref.clone()}
|
||||
|
@ -114,14 +113,14 @@ impl Component for MenuItem {
|
|||
<a
|
||||
class=classes!(
|
||||
"bp3-menu-item",
|
||||
self.props.active.as_some("bp3-active"),
|
||||
self.props.disabled.as_some("bp3-disabled"),
|
||||
self.props.active.then(|| "bp3-active"),
|
||||
self.props.disabled.then(|| "bp3-disabled"),
|
||||
self.props.intent
|
||||
.or_else(|| self.props.active.as_some(Intent::Primary)),
|
||||
.or_else(|| self.props.active.then(|| Intent::Primary)),
|
||||
self.props.class.clone(),
|
||||
)
|
||||
href?={(!self.props.disabled).and_option(self.props.href.clone())}
|
||||
tabIndex?={(!self.props.disabled).as_some(0)}
|
||||
href?={(!self.props.disabled).then(|| self.props.href.clone())}.flatten()
|
||||
tabIndex?={(!self.props.disabled).then(|| 0)}
|
||||
onclick={self.props.onclick.clone()}
|
||||
>
|
||||
<Icon icon={self.props.icon} />
|
||||
|
@ -143,6 +142,7 @@ impl Component for MenuItem {
|
|||
html!()
|
||||
}
|
||||
}
|
||||
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::Intent;
|
||||
use boolinator::Boolinator;
|
||||
use yew::prelude::*;
|
||||
|
||||
pub struct ProgressBar {
|
||||
|
@ -53,8 +52,8 @@ impl Component for ProgressBar {
|
|||
class=classes!(
|
||||
"bp3-progress-bar",
|
||||
self.props.intent,
|
||||
(!self.props.animate).as_some("bp3-no-animation"),
|
||||
(!self.props.stripes).as_some("bp3-no-stripes")
|
||||
(!self.props.animate).then(|| "bp3-no-animation"),
|
||||
(!self.props.stripes).then(|| "bp3-no-stripes")
|
||||
)
|
||||
>
|
||||
<div class=classes!("bp3-progress-meter") style={{width}}/>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use boolinator::Boolinator;
|
||||
use yew::prelude::*;
|
||||
|
||||
pub struct Switch {
|
||||
|
@ -48,9 +47,9 @@ impl Component for Switch {
|
|||
class=classes!(
|
||||
"bp3-control",
|
||||
"bp3-switch",
|
||||
self.props.disabled.as_some("bp3-disabled"),
|
||||
self.props.inline.as_some("bp3-inline"),
|
||||
self.props.large.as_some("bp3-large"),
|
||||
self.props.disabled.then(|| "bp3-disabled"),
|
||||
self.props.inline.then(|| "bp3-inline"),
|
||||
self.props.large.then(|| "bp3-large"),
|
||||
)
|
||||
>
|
||||
<input
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use boolinator::Boolinator;
|
||||
use std::collections::{hash_map::DefaultHasher, HashMap};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use web_sys::HtmlElement;
|
||||
|
@ -93,14 +92,14 @@ impl<T: Clone + PartialEq + Hash + 'static> Component for Tabs<T> {
|
|||
<div
|
||||
class=classes!(
|
||||
"bp3-tabs",
|
||||
self.props.vertical.as_some("bp3-vertical"),
|
||||
self.props.vertical.then(|| "bp3-vertical"),
|
||||
self.props.class.clone(),
|
||||
)
|
||||
>
|
||||
<div
|
||||
class=classes!(
|
||||
"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 boolinator::Boolinator;
|
||||
use yew::prelude::*;
|
||||
|
||||
pub struct Tag {
|
||||
|
@ -74,7 +73,7 @@ impl Component for Tag {
|
|||
<button
|
||||
class=classes!("bp3-tag-remove")
|
||||
onclick={callback}
|
||||
tabindex?={self.props.interactive.as_some(0)}
|
||||
tabindex?={self.props.interactive.then(|| 0)}
|
||||
>
|
||||
<Icon icon=IconName::SmallCross />
|
||||
</button>
|
||||
|
@ -86,12 +85,12 @@ impl Component for Tag {
|
|||
class=classes!(
|
||||
"bp3-tag",
|
||||
self.props.intent,
|
||||
self.props.active.as_some("bp3-active"),
|
||||
self.props.fill.as_some("bp3-fill"),
|
||||
self.props.interactive.as_some("bp3-interactive"),
|
||||
self.props.large.as_some("bp3-large"),
|
||||
self.props.minimal.as_some("bp3-minimal"),
|
||||
self.props.round.as_some("bp3-round"),
|
||||
self.props.active.then(|| "bp3-active"),
|
||||
self.props.fill.then(|| "bp3-fill"),
|
||||
self.props.interactive.then(|| "bp3-interactive"),
|
||||
self.props.large.then(|| "bp3-large"),
|
||||
self.props.minimal.then(|| "bp3-minimal"),
|
||||
self.props.round.then(|| "bp3-round"),
|
||||
self.props.class.clone(),
|
||||
)
|
||||
onclick={self.props.onclick.clone()}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use boolinator::Boolinator;
|
||||
use yew::prelude::*;
|
||||
|
||||
pub struct Text {
|
||||
|
@ -46,7 +45,7 @@ impl Component for Text {
|
|||
<@{if self.props.inline { "span" } else { "div"}}
|
||||
class=classes!(
|
||||
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()
|
||||
>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::collapse::Collapse;
|
||||
use crate::icon::{Icon, IconName};
|
||||
use crate::Intent;
|
||||
use boolinator::Boolinator;
|
||||
use id_tree::*;
|
||||
use std::cell::{Ref, RefCell, RefMut};
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
|
@ -312,7 +311,7 @@ impl Component for TreeNode {
|
|||
html! {
|
||||
<li class=classes!(
|
||||
"bp3-tree-node",
|
||||
self.props.is_selected.as_some("bp3-tree-node-selected")
|
||||
self.props.is_selected.then(|| "bp3-tree-node-selected")
|
||||
)>
|
||||
<div
|
||||
class="bp3-tree-node-content"
|
||||
|
|
Loading…
Reference in a new issue