bevy_pages 0.2.0

A lightweight and elegant framework to upgrade your Bevy UI experience.
Documentation
use crate::element::{ElementProps, ElementWidget};
use crate::widgets::Widget;
use bevy::asset::AssetServer;
use bevy::prelude::{Component, Entity, EntityCommands};
use roxmltree::Node;

/// A node widget. Equivalent to `<div></div>` in HTML.
///
/// ## XML Usage
///
/// Build a node widget using the `<Node></Node>` tag.
///
/// The node widget does not introduce any new attributes.
///
/// ## Logic
///
/// This widget does not have any special code logic.
/// Use element events to implement custom behavior.
#[derive(Clone, Debug, Component)]
pub struct NodeWidget;

impl Widget for NodeWidget {
    fn spawn(&self, commands: &mut EntityCommands, _: &AssetServer) -> Entity {
        commands.id()
    }

    fn parse(_: &Node, _: Option<&str>, _: Option<&ElementWidget>) -> Result<Self, String>
    where
        Self: Sized,
    {
        Ok(Self)
    }

    fn apply_defaults(_: &Node, _: &mut ElementProps, _: &mut ElementProps, _: &mut ElementProps) {}
}