12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- //! Example: README.md showcase
- //!
- //! The example from the README.md.
- use dioxus::{
- core::{exports::bumpalo::Bump, Attribute, HasAttributesBox},
- html::{ExtendedGlobalAttributesMarker, GlobalAttributesExtension},
- prelude::*,
- };
- fn main() {
- dioxus_desktop::launch(app);
- }
- fn app(cx: Scope) -> Element {
- cx.render(::dioxus::core::LazyNodes::new(
- move |__cx: &::dioxus::core::ScopeState| -> ::dioxus::core::VNode {
- static TEMPLATE: ::dioxus::core::Template = ::dioxus::core::Template {
- name: "src/main.rs:15:15:289",
- roots: &[::dioxus::core::TemplateNode::Dynamic { id: 0usize }],
- node_paths: &[&[0u8]],
- attr_paths: &[],
- };
- ::dioxus::core::VNode {
- parent: None,
- key: None,
- template: std::cell::Cell::new(TEMPLATE),
- root_ids: dioxus::core::exports::bumpalo::collections::Vec::with_capacity_in(
- 1usize,
- __cx.bump(),
- )
- .into(),
- dynamic_nodes: __cx.bump().alloc([__cx.component(
- Component,
- Props {
- bump: __cx.bump(),
- attributes: Vec::new(),
- }
- .width("hello"),
- "Component",
- )]),
- dynamic_attrs: __cx.bump().alloc([]),
- }
- },
- ))
- }
- #[derive(Props)]
- struct Props<'a> {
- bump: &'a Bump,
- attributes: Vec<Attribute<'a>>,
- }
- impl<'a> HasAttributesBox<'a, Props<'a>> for Props<'a> {
- fn push_attribute(
- mut self,
- name: &'a str,
- ns: Option<&'static str>,
- attr: impl IntoAttributeValue<'a>,
- volatile: bool,
- ) -> Self {
- self.attributes.push(Attribute {
- name,
- namespace: ns,
- value: attr.into_value(self.bump),
- volatile,
- });
- self
- }
- }
- impl ExtendedGlobalAttributesMarker for Props<'_> {}
- fn Component<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> {
- todo!()
- }
|