pub struct BrowserFrame { /* private fields */ }
Available on crate feature
yew
only.Expand description
BrowserFrame Component
A Yew component that emulates a browser window, complete with customizable controls (close, minimize, maximize), an address bar, and optional custom buttons. It wraps its child components in a browser-like interface and provides various hooks for interaction events such as focus, hover, and clicks.
§Features
- Configurable address bar and controls (show/hide, read-only).
- Fully customizable styling and classes for different parts of the frame.
- Emits callbacks for URL changes and control interactions (close, minimize, maximize).
- Supports additional custom buttons and slots for user-defined functionality.
- Keyboard navigation support (Escape to close).
§Examples
§Basic Usage
use yew::prelude::*;
use browser_rs::yew::BrowserFrame;
#[function_component(App)]
pub fn app() -> Html {
let on_close = Callback::from(|_| log::info!("Browser closed"));
html! {
<BrowserFrame
url={"https://opensass.org".to_string()}
on_close={on_close}
>
<p>{ "Your embedded content here." }</p>
</BrowserFrame>
}
}
§With Custom Buttons
use yew::prelude::*;
use browser_rs::yew::BrowserFrame;
#[function_component(App)]
pub fn app() -> Html {
let custom_button = html! {
<button>{ "Custom Button" }</button>
};
html! {
<BrowserFrame
url={"https://opensass.org".to_string()}
custom_buttons={vec![custom_button]}
>
<p>{ "Custom button in the header!" }</p>
</BrowserFrame>
}
}
§Styling and Class Customization
use yew::prelude::*;
use browser_rs::yew::BrowserFrame;
#[function_component(App)]
pub fn app() -> Html {
html! {
<BrowserFrame
url={"https://opensass.org".to_string()}
class={"rounded-xl shadow-xl"}
input_class={"bg-gray-200 text-gray-900"}
container_class={"flex-1 mx-4"}
>
<p>{ "Styled browser frame!" }</p>
</BrowserFrame>
}
}
§Behavior
- The
BrowserFrame
uses aBrowserHeader
subcomponent for controls and an address bar, and aBrowserContent
subcomponent for rendering child content. - The
on_url_change
callback is called when the address bar’s URL changes. - Control buttons (close, minimize, maximize) emit their respective callbacks when interacted with.
- Keyboard navigation is enabled: Escape key triggers the
on_close
callback.
§Notes
- Supports both light and dark themes through provided classes and styles.
- Default styling can be customized via
class
,style
, and other related props. - Accessibility attributes (
aria-*
) are provided.
Trait Implementations§
Source§impl BaseComponent for BrowserFramewhere
Self: 'static,
impl BaseComponent for BrowserFramewhere
Self: 'static,
Source§type Properties = BrowserFrameProps
type Properties = BrowserFrameProps
The Component’s Properties.
Source§fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool
fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool
Updates component’s internal state.
Source§fn changed(
&mut self,
_ctx: &Context<Self>,
_old_props: &Self::Properties,
) -> bool
fn changed( &mut self, _ctx: &Context<Self>, _old_props: &Self::Properties, ) -> bool
React to changes of component properties.
Source§fn view(&self, ctx: &Context<Self>) -> HtmlResult
fn view(&self, ctx: &Context<Self>) -> HtmlResult
Returns a component layout to be rendered.
Source§fn rendered(&mut self, _ctx: &Context<Self>, _first_render: bool)
fn rendered(&mut self, _ctx: &Context<Self>, _first_render: bool)
Notified after a layout is rendered.
Source§fn prepare_state(&self) -> Option<String>
fn prepare_state(&self) -> Option<String>
Prepares the server-side state.
Source§impl Debug for BrowserFrame
impl Debug for BrowserFrame
Source§impl FunctionProvider for BrowserFrame
impl FunctionProvider for BrowserFrame
Source§type Properties = BrowserFrameProps
type Properties = BrowserFrameProps
Properties for the Function Component.
Source§fn run(ctx: &mut HookContext, props: &Self::Properties) -> HtmlResult
fn run(ctx: &mut HookContext, props: &Self::Properties) -> HtmlResult
Auto Trait Implementations§
impl !Freeze for BrowserFrame
impl !RefUnwindSafe for BrowserFrame
impl !Send for BrowserFrame
impl !Sync for BrowserFrame
impl Unpin for BrowserFrame
impl !UnwindSafe for BrowserFrame
Blanket Implementations§
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
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self
to a value of a Properties
struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self
to a value of a Properties
struct.Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.