[Fix] replaced existentioal type to Box
This commit is contained in:
parent
f4862fefde
commit
f5ce2c9564
@ -2,12 +2,6 @@ use crate::engine::Engine;
|
||||
use crate::renderable::Renderable;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! children {
|
||||
($w:expr) => ($w);
|
||||
($w1:expr, $($rest:tt)*) => (Children2::new($w1, children!($($rest)*)));
|
||||
}
|
||||
|
||||
pub struct Children2<E, CH0, CH1>
|
||||
where E: Engine,
|
||||
CH0: Renderable<E>,
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![feature(associated_type_defaults, never_type, unsize, specialization)]
|
||||
#![feature(proc_macro, associated_type_defaults, never_type, unsize, specialization)]
|
||||
|
||||
pub mod convert;
|
||||
pub mod engine;
|
||||
@ -6,12 +6,17 @@ pub mod context;
|
||||
pub mod callback;
|
||||
pub mod component;
|
||||
|
||||
#[macro_use]
|
||||
pub mod children;
|
||||
pub mod renderable;
|
||||
pub mod node;
|
||||
pub mod view;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! children {
|
||||
($w:expr) => ($w);
|
||||
($w1:expr, $($rest:tt)*) => (Children2::new($w1, children!($($rest)*)));
|
||||
}
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::convert::{MyFrom, MyInto};
|
||||
pub use crate::engine::Engine;
|
||||
|
@ -94,8 +94,8 @@ impl Component for Tabs {
|
||||
}
|
||||
|
||||
pub struct Header {
|
||||
props: HeaderProps,
|
||||
tabs_ctx: Option<TabsContext<DefaultContext>>
|
||||
pub props: HeaderProps,
|
||||
pub tabs_ctx: Option<TabsContext<DefaultContext>>
|
||||
}
|
||||
|
||||
pub enum HeaderEvent {
|
||||
@ -136,7 +136,7 @@ impl Component for Header {
|
||||
}
|
||||
|
||||
pub struct Body {
|
||||
props: BodyProps
|
||||
pub props: BodyProps
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@ -151,7 +151,7 @@ impl Component for Body {
|
||||
}
|
||||
|
||||
pub struct Tab {
|
||||
props: TabProps
|
||||
pub props: TabProps
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
3
maple-stdweb-ui/.gitignore
vendored
3
maple-stdweb-ui/.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
@ -1,14 +0,0 @@
|
||||
cargo-features = ["edition"]
|
||||
|
||||
[package]
|
||||
name = "maple-stdweb-ui"
|
||||
version = "0.1.0"
|
||||
authors = ["Andrey Tkachenko <andreytkachenko64@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
maple-core = {path = "../maple-core"}
|
||||
maple-stdweb = {path = "../maple-stdweb"}
|
||||
maple-stdui = {path = "../maple-stdui"}
|
||||
maple-macro = {path = "../maple-macro"}
|
||||
maple-stdweb-ui = {path = "../maple-stdweb-ui"}
|
@ -1,9 +0,0 @@
|
||||
#![feature(proc_macro_non_items, existential_type)]
|
||||
|
||||
pub mod panel;
|
||||
pub mod tabs;
|
||||
|
||||
pub use self::panel::*;
|
||||
pub use self::tabs::*;
|
||||
|
||||
pub use maple_stdweb_ui::HtmlEngine;
|
@ -1,30 +0,0 @@
|
||||
use maple_core::prelude::*;
|
||||
use super::HtmlEngine;
|
||||
use maple_macro::view;
|
||||
use maple_stdweb::*;
|
||||
use maple_stdui::prelude::Panel;
|
||||
|
||||
impl View for Panel {
|
||||
type InputContext = DefaultContext;
|
||||
type OutputContext = DefaultContext;
|
||||
|
||||
fn receive_context(&mut self, ctx: Self::InputContext) -> Self::OutputContext {
|
||||
ctx
|
||||
}
|
||||
}
|
||||
|
||||
impl ViewX for Panel {
|
||||
type Engine = HtmlEngine;
|
||||
type ChildrenEngine = HtmlEngine;
|
||||
existential type Renderable: Renderable<Engine = HtmlEngine>;
|
||||
|
||||
fn build<C>(self, children: Option<C>) -> Self::Renderable
|
||||
where C: Renderable<Engine = Self::ChildrenEngine> + 'static
|
||||
{
|
||||
view! {
|
||||
<Div class="panel">
|
||||
{ ...children }
|
||||
</Div>
|
||||
}
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
use maple_core::prelude::*;
|
||||
use maple_macro::view;
|
||||
use maple_stdweb::*;
|
||||
use maple_stdui::prelude::tabs::*;
|
||||
use super::HtmlEngine;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use std::cell::RefCell;
|
||||
|
||||
|
||||
|
||||
impl View for Tabs {
|
||||
type InputContext = DefaultContext;
|
||||
type OutputContext = TabsContext<DefaultContext>;
|
||||
|
||||
fn receive_context(&mut self, ctx: Self::InputContext) -> Self::OutputContext {
|
||||
TabsContext::wrap(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
impl Tabs {
|
||||
pub fn build<C>(self, children: Option<C>) -> impl Renderable<Engine = HtmlEngine>
|
||||
where C: Renderable<Engine = HtmlEngine> + 'static
|
||||
{
|
||||
view! {
|
||||
<Div class="tabs">
|
||||
{ ... children }
|
||||
</Div>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl View for Header {
|
||||
type InputContext = TabsContext<DefaultContext>;
|
||||
type OutputContext = DefaultContext;
|
||||
|
||||
fn receive_context(&mut self, ctx: Self::InputContext) -> Self::OutputContext {
|
||||
self.tabs_ctx = Some(ctx.clone());
|
||||
|
||||
ctx.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl Header {
|
||||
pub fn build<C>(self, _children: Option<C>) -> impl Renderable<Engine = HtmlEngine>
|
||||
where C: Renderable<Engine = HtmlEngine> + 'static
|
||||
{
|
||||
let tabs = self.tabs_ctx.map(|ctx|
|
||||
ctx.get_tabs()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, tab)| view! {
|
||||
<Span class="tab-title" click={move |_| HeaderEvent::Click(i)}>
|
||||
{match tab {
|
||||
Some(val) => val,
|
||||
None => "<No title>"
|
||||
}}
|
||||
</Span>
|
||||
})
|
||||
.collect::<Vec<_>>());
|
||||
|
||||
view! {
|
||||
<Div class="tabs-header">
|
||||
{ ...tabs }
|
||||
</Div>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl View for Body {
|
||||
type InputContext = TabsContext<DefaultContext>;
|
||||
type OutputContext = TabsBodyContext<DefaultContext>;
|
||||
|
||||
fn receive_context(&mut self, ctx: Self::InputContext) -> Self::OutputContext {
|
||||
TabsBodyContext::wrap(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
impl Body {
|
||||
pub fn build<C>(self, children: Option<C>) -> impl Renderable<Engine = HtmlEngine>
|
||||
where C: Renderable<Engine = HtmlEngine> + 'static
|
||||
{
|
||||
view! {
|
||||
<Div class="tab">
|
||||
{ ... children }
|
||||
</Div>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl View for Tab {
|
||||
type InputContext = TabsBodyContext<DefaultContext>;
|
||||
type OutputContext = DefaultContext;
|
||||
|
||||
fn receive_context(&mut self, ctx: Self::InputContext) -> Self::OutputContext {
|
||||
ctx.add_tab(self.props.title);
|
||||
ctx.unwrap().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
pub fn build<C>(self, children: Option<C>) -> impl Renderable<Engine = HtmlEngine>
|
||||
where C: Renderable<Engine = HtmlEngine> + 'static
|
||||
{
|
||||
view! {
|
||||
<Div class="tab">
|
||||
{ ... children }
|
||||
</Div>
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user