pub struct Button {
pub text: String,
pub variant: ButtonVariant,
pub disabled: bool,
pub size: ButtonSize,
pub on_click: Option<fn()>,
/* private fields */
}
Expand description
Button component that follows Orbit’s design system
§Examples
<template>
<Button
variant="primary"
size="medium"
@click="handle_click"
>
Click me
</Button>
</template>
<code lang="rust">
fn handle_click() {
log::info!("Button clicked!");
}
</code>
Fields§
§text: String
Text content of the button
variant: ButtonVariant
Visual style variant of the button
disabled: bool
Whether the button is disabled
size: ButtonSize
Size variant of the button
on_click: Option<fn()>
Click event handler
Trait Implementations§
Source§impl Component for Button
impl Component for Button
Source§type Props = ButtonProps
type Props = ButtonProps
The props type for this component
Source§fn component_id(&self) -> ComponentId
fn component_id(&self) -> ComponentId
Get unique component ID for debugging and tracking
Source§fn create(props: Self::Props, _context: Context) -> Self
fn create(props: Self::Props, _context: Context) -> Self
Create a new component instance with enhanced tracking
Source§fn update(&mut self, props: Self::Props) -> Result<(), ComponentError>
fn update(&mut self, props: Self::Props) -> Result<(), ComponentError>
Update component with new props
Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Convert to mutable Any for downcasting
Source§fn initialize(&mut self) -> Result<(), ComponentError>
fn initialize(&mut self) -> Result<(), ComponentError>
Initialize the component - called immediately after creation
Use this for setting up initial state and registering lifecycle hooks
Source§fn mount(&mut self) -> Result<(), ComponentError>
fn mount(&mut self) -> Result<(), ComponentError>
Mount component - called when component is first added to the tree
Automatic state change detection and update scheduling is enabled after this point
Source§fn on_mount(&mut self, _context: &MountContext) -> Result<(), ComponentError>
fn on_mount(&mut self, _context: &MountContext) -> Result<(), ComponentError>
Enhanced lifecycle hook - called when component is mounted with context
Source§fn before_mount(&mut self) -> Result<(), ComponentError>
fn before_mount(&mut self) -> Result<(), ComponentError>
Enhanced lifecycle hook - called before mount for initialization
Source§fn after_mount(&mut self) -> Result<(), ComponentError>
fn after_mount(&mut self) -> Result<(), ComponentError>
Enhanced lifecycle hook - called after mount for post-initialization
Source§fn state_changed(&mut self, _state_key: &str) -> Result<(), ComponentError>
fn state_changed(&mut self, _state_key: &str) -> Result<(), ComponentError>
Called when component state changes and updates are needed
Source§fn on_update(&mut self, _changes: &StateChanges) -> Result<(), ComponentError>
fn on_update(&mut self, _changes: &StateChanges) -> Result<(), ComponentError>
Enhanced lifecycle hook - called when state changes are detected
Source§fn request_update(&mut self) -> Result<(), ComponentError>
fn request_update(&mut self) -> Result<(), ComponentError>
Request that this component be re-rendered
Source§fn should_update(&self, _new_props: &Self::Props) -> bool
fn should_update(&self, _new_props: &Self::Props) -> bool
Check if component should update given new props
Override for performance optimization
Source§fn before_update(
&mut self,
_new_props: &Self::Props,
) -> Result<(), ComponentError>
fn before_update( &mut self, _new_props: &Self::Props, ) -> Result<(), ComponentError>
Called before component updates with new props
Source§fn after_update(&mut self) -> Result<(), ComponentError>
fn after_update(&mut self) -> Result<(), ComponentError>
Called after the component has updated
Source§fn before_unmount(&mut self) -> Result<(), ComponentError>
fn before_unmount(&mut self) -> Result<(), ComponentError>
Called before component is unmounted
Automatic cleanup of state subscriptions happens after this
Source§fn on_unmount(
&mut self,
_context: &UnmountContext,
) -> Result<(), ComponentError>
fn on_unmount( &mut self, _context: &UnmountContext, ) -> Result<(), ComponentError>
Enhanced lifecycle hook - called when component is unmounted with context
Source§fn after_unmount(&mut self) -> Result<(), ComponentError>
fn after_unmount(&mut self) -> Result<(), ComponentError>
Enhanced lifecycle hook - called after unmount for final cleanup
Source§fn unmount(&mut self) -> Result<(), ComponentError>
fn unmount(&mut self) -> Result<(), ComponentError>
Unmount component - called when component is removed from the tree
Source§fn cleanup(&mut self) -> Result<(), ComponentError>
fn cleanup(&mut self) -> Result<(), ComponentError>
Perform automatic cleanup (called by framework)
Source§fn lifecycle_phase(&self) -> LifecyclePhase
fn lifecycle_phase(&self) -> LifecyclePhase
Get current lifecycle phase
Auto Trait Implementations§
impl Freeze for Button
impl RefUnwindSafe for Button
impl Send for Button
impl Sync for Button
impl Unpin for Button
impl UnwindSafe for Button
Blanket Implementations§
Source§impl<T> AnyComponent for Twhere
T: Component,
impl<T> AnyComponent for Twhere
T: Component,
Source§fn component_id(&self) -> ComponentId
fn component_id(&self) -> ComponentId
Get unique component ID for debugging and tracking
Source§fn lifecycle_phase(&self) -> LifecyclePhase
fn lifecycle_phase(&self) -> LifecyclePhase
Get current lifecycle phase
Source§fn set_lifecycle_phase(&mut self, _phase: LifecyclePhase)
fn set_lifecycle_phase(&mut self, _phase: LifecyclePhase)
Set lifecycle phase (framework internal)
Source§fn request_update(&mut self) -> Result<(), ComponentError>
fn request_update(&mut self) -> Result<(), ComponentError>
Request that this component be re-rendered
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert to mutable Any for downcasting
Source§fn any_initialize(&mut self) -> Result<(), ComponentError>
fn any_initialize(&mut self) -> Result<(), ComponentError>
Initialize the component (post-creation)
Source§fn any_mount(&mut self) -> Result<(), ComponentError>
fn any_mount(&mut self) -> Result<(), ComponentError>
Mount component - called when component is first added to the tree
Source§fn any_before_update(
&mut self,
props: Box<dyn Props>,
) -> Result<(), ComponentError>
fn any_before_update( &mut self, props: Box<dyn Props>, ) -> Result<(), ComponentError>
Called before component updates with new props
Source§fn any_update(&mut self, props: Box<dyn Props>) -> Result<(), ComponentError>
fn any_update(&mut self, props: Box<dyn Props>) -> Result<(), ComponentError>
Update component with new props (type-erased)
Source§fn any_after_update(&mut self) -> Result<(), ComponentError>
fn any_after_update(&mut self) -> Result<(), ComponentError>
Called after the component has updated
Source§fn any_before_unmount(&mut self) -> Result<(), ComponentError>
fn any_before_unmount(&mut self) -> Result<(), ComponentError>
Called before component is unmounted
Source§fn any_unmount(&mut self) -> Result<(), ComponentError>
fn any_unmount(&mut self) -> Result<(), ComponentError>
Unmount component - called when component is removed from the tree
Source§fn any_on_mount(&mut self, context: &MountContext) -> Result<(), ComponentError>
fn any_on_mount(&mut self, context: &MountContext) -> Result<(), ComponentError>
Enhanced mount with context
Source§fn any_before_mount(&mut self) -> Result<(), ComponentError>
fn any_before_mount(&mut self) -> Result<(), ComponentError>
Before mount hook
Source§fn any_after_mount(&mut self) -> Result<(), ComponentError>
fn any_after_mount(&mut self) -> Result<(), ComponentError>
After mount hook
Source§fn any_on_update(
&mut self,
changes: &StateChanges,
) -> Result<(), ComponentError>
fn any_on_update( &mut self, changes: &StateChanges, ) -> Result<(), ComponentError>
Enhanced update with state changes
Source§fn any_on_unmount(
&mut self,
context: &UnmountContext,
) -> Result<(), ComponentError>
fn any_on_unmount( &mut self, context: &UnmountContext, ) -> Result<(), ComponentError>
Enhanced unmount with context
Source§fn any_after_unmount(&mut self) -> Result<(), ComponentError>
fn any_after_unmount(&mut self) -> Result<(), ComponentError>
After unmount hook
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more