Feat: WIP ctx

This commit is contained in:
Jonathan Kelley committed 2021-02-20 21:59:16 -05:00
1 parent b3e6886351
commit 7a6aabe4f3
18 files changed
+430 -99

No files matched your search

+25 -22
View File
@@ -2,44 +2,47 @@
//! for components to be used within Nodes.
//!
use std::fmt::Debug;
use crate::innerlude::*;
/// The `Component` trait refers to any struct or funciton that can be used as a component
/// We automatically implement Component for FC<T>
pub trait Component {
type Props: Properties;
fn builder(&'static self) -> Self::Props;
}
// pub trait Component {
// type Props: Properties<'static>;
// fn builder(&'static self) -> Self::Props;
// }
// Auto implement component for a FC
// Calling the FC is the same as "rendering" it
impl<P: Properties> Component for FC<P> {
type Props = P;
// // Auto implement component for a FC
// // Calling the FC is the same as "rendering" it
// impl<P: Properties<'static>> Component for FC<P> {
// type Props = P;
fn builder(&self) -> Self::Props {
todo!()
}
}
// fn builder(&self) -> Self::Props {
// todo!()
// }
// }
/// The `Properties` trait defines any struct that can be constructed using a combination of default / optional fields.
/// Components take a "properties" object
pub trait Properties // where
// Self: Sized,
{
fn call(&self, ptr: *const ()) {}
}
// pub trait Properties<'a>
// where
// Self: Debug,
// {
// fn call(&self, ptr: *const ()) {}
// }
// Auto implement for no-prop components
impl Properties for () {
fn call(&self, ptr: *const ()) {}
}
// // Auto implement for no-prop components
// impl<'a> Properties<'a> for () {
// fn call(&self, ptr: *const ()) {}
// }
#[cfg(test)]
mod tests {
use super::*;
use crate::prelude::bumpalo::Bump;
fn test_static_fn<'a, P: Properties>(b: &'a Bump, r: FC<P>) -> VNode<'a> {
fn test_static_fn<'a, P>(b: &'a Bump, r: FC<P>) -> VNode<'a> {
todo!()
}