💥 Rename Veck to LisComponents
This commit is contained in:
parent
24f2f0d765
commit
66117992c1
7 changed files with 47 additions and 43 deletions
|
|
@ -26,7 +26,7 @@ pub struct MegaMenu {
|
|||
weight : Weight,
|
||||
renderable: Renderable,
|
||||
id : IdentifierValue,
|
||||
items : VeckComponents<MegaItem>,
|
||||
items : LisComponents<MegaItem>,
|
||||
theme : MegaMenuTheme,
|
||||
}
|
||||
|
||||
|
|
@ -153,12 +153,12 @@ impl MegaMenu {
|
|||
}
|
||||
|
||||
pub fn with_item(mut self, item: MegaItem) -> Self {
|
||||
self.items.alter(VeckOp::Add(ComponentOne::with(item)));
|
||||
self.items.alter(LisOp::Add(ComponentOne::with(item)));
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_items(&mut self, op: VeckOp<MegaItem>) -> &mut Self {
|
||||
pub fn alter_items(&mut self, op: LisOp<MegaItem>) -> &mut Self {
|
||||
self.items.alter(op);
|
||||
self
|
||||
}
|
||||
|
|
@ -171,7 +171,7 @@ impl MegaMenu {
|
|||
|
||||
// MegaMenu GETTERS.
|
||||
|
||||
pub fn items(&self) -> &VeckComponents<MegaItem> {
|
||||
pub fn items(&self) -> &LisComponents<MegaItem> {
|
||||
&self.items
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub struct Container {
|
|||
renderable: Renderable,
|
||||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
items : VeckComponents<flex::Item>,
|
||||
items : LisComponents<flex::Item>,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -83,12 +83,12 @@ impl Container {
|
|||
}
|
||||
|
||||
pub fn with_item(mut self, item: flex::Item) -> Self {
|
||||
self.items.alter(VeckOp::Add(ComponentOne::with(item)));
|
||||
self.items.alter(LisOp::Add(ComponentOne::with(item)));
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_items(&mut self, op: VeckOp<flex::Item>) -> &mut Self {
|
||||
pub fn alter_items(&mut self, op: LisOp<flex::Item>) -> &mut Self {
|
||||
self.items.alter(op);
|
||||
self
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ impl Container {
|
|||
&self.classes
|
||||
}
|
||||
|
||||
pub fn items(&self) -> &VeckComponents<flex::Item> {
|
||||
pub fn items(&self) -> &LisComponents<flex::Item> {
|
||||
&self.items
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub struct Row {
|
|||
renderable: Renderable,
|
||||
id : IdentifierValue,
|
||||
classes : Classes,
|
||||
columns : VeckComponents<grid::Column>,
|
||||
columns : LisComponents<grid::Column>,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -83,12 +83,12 @@ impl Row {
|
|||
}
|
||||
|
||||
pub fn with_column(mut self, column: grid::Column) -> Self {
|
||||
self.columns.alter(VeckOp::Add(ComponentOne::with(column)));
|
||||
self.columns.alter(LisOp::Add(ComponentOne::with(column)));
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_columns(&mut self, op: VeckOp<grid::Column>) -> &mut Self {
|
||||
pub fn alter_columns(&mut self, op: LisOp<grid::Column>) -> &mut Self {
|
||||
self.columns.alter(op);
|
||||
self
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ impl Row {
|
|||
&self.classes
|
||||
}
|
||||
|
||||
pub fn columns(&self) -> &VeckComponents<grid::Column> {
|
||||
pub fn columns(&self) -> &LisComponents<grid::Column> {
|
||||
&self.columns
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ mod context;
|
|||
pub use context::{Context, ContextOp};
|
||||
pub type FnContextualPath = fn(cx: &Context) -> &str;
|
||||
|
||||
mod definition;
|
||||
pub use definition::{component_as_mut, component_as_ref, ComponentBase, ComponentTrait};
|
||||
|
||||
mod renderable;
|
||||
pub use renderable::{FnIsRenderable, Renderable};
|
||||
|
||||
mod definition;
|
||||
pub use definition::{component_as_mut, component_as_ref, ComponentBase, ComponentTrait};
|
||||
|
||||
mod arc;
|
||||
pub use arc::ComponentArc;
|
||||
|
||||
|
|
@ -17,8 +17,8 @@ pub use mix::{MixComponents, MixOp};
|
|||
mod one;
|
||||
pub use one::ComponentOne;
|
||||
|
||||
mod veck;
|
||||
pub use veck::{VeckComponents, VeckOp};
|
||||
mod lis;
|
||||
pub use lis::{LisComponents, LisOp};
|
||||
|
||||
pub mod html;
|
||||
pub mod l10n;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@ impl ComponentArc {
|
|||
ComponentArc(Arc::new(RwLock::new(component)))
|
||||
}
|
||||
|
||||
pub fn set(&mut self, component: impl ComponentTrait) {
|
||||
self.0 = Arc::new(RwLock::new(component));
|
||||
}
|
||||
|
||||
pub(crate) fn handle(&self) -> Handle {
|
||||
self.0.read().unwrap().handle()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::core::component::{ComponentOne, ComponentTrait, Context};
|
|||
use crate::html::{html, Markup};
|
||||
use crate::Handle;
|
||||
|
||||
pub enum VeckOp<T: ComponentTrait + Default> {
|
||||
pub enum LisOp<T: ComponentTrait + Default> {
|
||||
Add(ComponentOne<T>),
|
||||
AddAfterId(&'static str, ComponentOne<T>),
|
||||
AddBeforeId(&'static str, ComponentOne<T>),
|
||||
|
|
@ -13,43 +13,43 @@ pub enum VeckOp<T: ComponentTrait + Default> {
|
|||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct VeckComponents<T: ComponentTrait + Default>(Vec<ComponentOne<T>>);
|
||||
pub struct LisComponents<T: ComponentTrait + Default>(Vec<ComponentOne<T>>);
|
||||
|
||||
impl<T: ComponentTrait + Default> VeckComponents<T> {
|
||||
impl<T: ComponentTrait + Default> LisComponents<T> {
|
||||
pub fn new() -> Self {
|
||||
VeckComponents::<T>::default()
|
||||
LisComponents::<T>::default()
|
||||
}
|
||||
|
||||
pub fn with(one: ComponentOne<T>) -> Self {
|
||||
let mut veck = VeckComponents::new();
|
||||
veck.alter(VeckOp::Add(one));
|
||||
veck
|
||||
let mut components = LisComponents::new();
|
||||
components.alter(LisOp::Add(one));
|
||||
components
|
||||
}
|
||||
|
||||
// VeckComponents BUILDER.
|
||||
// LisComponents BUILDER.
|
||||
|
||||
pub fn alter(&mut self, op: VeckOp<T>) -> &mut Self {
|
||||
pub fn alter(&mut self, op: LisOp<T>) -> &mut Self {
|
||||
match op {
|
||||
VeckOp::Add(one) => self.0.push(one),
|
||||
VeckOp::AddAfterId(id, one) => {
|
||||
LisOp::Add(one) => self.0.push(one),
|
||||
LisOp::AddAfterId(id, one) => {
|
||||
match self.0.iter().position(|c| c.id().as_deref() == Some(id)) {
|
||||
Some(index) => self.0.insert(index + 1, one),
|
||||
_ => self.0.push(one),
|
||||
}
|
||||
}
|
||||
VeckOp::AddBeforeId(id, one) => {
|
||||
LisOp::AddBeforeId(id, one) => {
|
||||
match self.0.iter().position(|c| c.id().as_deref() == Some(id)) {
|
||||
Some(index) => self.0.insert(index, one),
|
||||
_ => self.0.insert(0, one),
|
||||
}
|
||||
}
|
||||
VeckOp::AddFirst(one) => self.0.insert(0, one),
|
||||
VeckOp::RemoveById(id) => {
|
||||
LisOp::AddFirst(one) => self.0.insert(0, one),
|
||||
LisOp::RemoveById(id) => {
|
||||
if let Some(index) = self.0.iter().position(|c| c.id().as_deref() == Some(id)) {
|
||||
self.0.remove(index);
|
||||
}
|
||||
}
|
||||
VeckOp::ReplaceById(id, one) => {
|
||||
LisOp::ReplaceById(id, one) => {
|
||||
for c in self.0.iter_mut() {
|
||||
if c.id().as_deref() == Some(id) {
|
||||
*c = one;
|
||||
|
|
@ -57,12 +57,12 @@ impl<T: ComponentTrait + Default> VeckComponents<T> {
|
|||
}
|
||||
}
|
||||
}
|
||||
VeckOp::Reset => self.0.clear(),
|
||||
LisOp::Reset => self.0.clear(),
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
// VeckComponents GETTERS.
|
||||
// LisComponents GETTERS.
|
||||
|
||||
pub fn get_by_id(&self, id: &'static str) -> Option<&ComponentOne<T>> {
|
||||
self.0.iter().find(|&c| c.id().as_deref() == Some(id))
|
||||
|
|
@ -76,7 +76,7 @@ impl<T: ComponentTrait + Default> VeckComponents<T> {
|
|||
self.0.iter().filter(move |&c| c.handle() == handle)
|
||||
}
|
||||
|
||||
// VeckComponents PREPARE.
|
||||
// LisComponents PREPARE.
|
||||
|
||||
pub fn prepare(&self, cx: &mut Context) -> Markup {
|
||||
let mut components = self.0.clone();
|
||||
|
|
@ -21,17 +21,17 @@ impl MixComponents {
|
|||
}
|
||||
|
||||
pub fn with(arc: ComponentArc) -> Self {
|
||||
let mut pack = MixComponents::new();
|
||||
pack.alter(MixOp::Add(arc));
|
||||
pack
|
||||
let mut components = MixComponents::new();
|
||||
components.alter(MixOp::Add(arc));
|
||||
components
|
||||
}
|
||||
|
||||
pub(crate) fn merge(packs: &[Option<&MixComponents>]) -> Self {
|
||||
let mut pack = MixComponents::default();
|
||||
for p in packs.iter().flatten() {
|
||||
pack.0.append(&mut p.0.clone());
|
||||
pub(crate) fn merge(mixes: &[Option<&MixComponents>]) -> Self {
|
||||
let mut components = MixComponents::default();
|
||||
for m in mixes.iter().flatten() {
|
||||
components.0.append(&mut m.0.clone());
|
||||
}
|
||||
pack
|
||||
components
|
||||
}
|
||||
|
||||
// MixComponents BUILDER.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue