Skip to content

Commit

Permalink
create a graph component (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
dqnykamp authored Jul 9, 2024
1 parent 5cde7f4 commit 20df92e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub use super::doenet::_fragment::_Fragment;
pub use super::doenet::boolean::Boolean;
pub use super::doenet::division::Division;
pub use super::doenet::document::Document;
pub use super::doenet::graph::Graph;
pub use super::doenet::li::Li;
pub use super::doenet::math::Math;
pub use super::doenet::ol::Ol;
Expand Down Expand Up @@ -46,6 +47,7 @@ pub enum ComponentEnum {
Ol(Ol),
Ul(Ul),
Li(Li),
Graph(Graph),
_Error(_Error),
_External(_External),
_Fragment(_Fragment),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use crate::components::prelude::*;
use crate::general_prop::RenderedChildrenPassthroughProp;
use crate::props::UpdaterObject;

#[component(name = Graph)]
mod component {

use crate::general_prop::BooleanProp;

enum Props {
/// Whether the `<graph>` should be hidden.
#[prop(value_type = PropValueType::Boolean, profile = PropProfile::Hidden)]
Hidden,
#[prop(value_type = PropValueType::AnnotatedContentRefs, profile = PropProfile::RenderedChildren)]
RenderedChildren,
}

enum Attributes {
/// Whether the `<graph>` should be hidden.
#[attribute(prop = BooleanProp, default = false)]
Hide,
}
}

pub use component::Graph;
pub use component::GraphActions;
pub use component::GraphAttributes;
pub use component::GraphProps;

impl PropGetUpdater for GraphProps {
fn get_updater(&self) -> UpdaterObject {
match self {
GraphProps::Hidden => as_updater_object::<_, component::props::types::Hidden>(
component::attrs::Hide::get_prop_updater(),
),
GraphProps::RenderedChildren => as_updater_object::<
_,
component::props::types::RenderedChildren,
>(RenderedChildrenPassthroughProp::new()),
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod _fragment;
pub mod boolean;
pub mod division;
pub mod document;
pub mod graph;
pub mod li;
pub mod math;
pub mod ol;
Expand Down

0 comments on commit 20df92e

Please sign in to comment.