pub struct BottomButtonProps<F>{
pub text: Signal<String>,
pub color: Option<Signal<String>>,
pub text_color: Option<Signal<String>>,
pub on_click: Option<F>,
pub button: BottomButton,
}leptos only.Expand description
Props for the BottomButton component.
Leptos component that controls a Telegram bottom button.
The component shows the selected bottom button and keeps its text and colors in sync with the provided reactive signals. An optional click callback can be registered and is automatically removed when the component unmounts.
§Examples
use leptos::prelude::*;
use telegram_webapp_sdk::{
leptos::{BottomButton, provide_telegram_context},
webapp::{BottomButton as Btn, TelegramWebApp}
};
#[component]
fn App() -> impl IntoView {
provide_telegram_context().expect("context");
let (text, _set_text) = signal("Send".to_owned());
view! {
<BottomButton
button=Btn::Main
text
on_click=move || {
if let Some(app) = TelegramWebApp::instance() {
let _ = app.send_data("clicked");
}
}
/>
}
}§Required Props
- text:
impl Into<Signal<String>>- Reactive text label displayed on the button.
§Optional Props
- color:
impl Into<Signal<String>>- Optional reactive background color as a
#RRGGBBhex string.
- Optional reactive background color as a
- text_color:
impl Into<Signal<String>>- Optional reactive text color as a
#RRGGBBhex string.
- Optional reactive text color as a
- on_click: [
F]- Optional callback invoked when the button is clicked.
- button:
WebBottomButton- Which bottom button to control; defaults to the main button.
Fields§
§text: Signal<String>Reactive text label displayed on the button.
color: Option<Signal<String>>Optional reactive background color as a #RRGGBB hex string.
text_color: Option<Signal<String>>Optional reactive text color as a #RRGGBB hex string.
on_click: Option<F>Optional callback invoked when the button is clicked.
Which bottom button to control; defaults to the main button.
Implementations§
Source§impl<F> BottomButtonProps<F>
impl<F> BottomButtonProps<F>
Sourcepub fn builder() -> BottomButtonPropsBuilder<F, ((), (), (), (), ())>
pub fn builder() -> BottomButtonPropsBuilder<F, ((), (), (), (), ())>
Create a builder for building BottomButtonProps.
On the builder, call .text(...), .color(...)(optional), .text_color(...)(optional), .on_click(...)(optional), .button(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of BottomButtonProps.
Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for BottomButtonProps<F>where
F: Freeze,
impl<F> RefUnwindSafe for BottomButtonProps<F>where
F: RefUnwindSafe,
impl<F> Send for BottomButtonProps<F>where
F: Send,
impl<F> Sync for BottomButtonProps<F>where
F: Sync,
impl<F> Unpin for BottomButtonProps<F>where
F: Unpin,
impl<F> UnsafeUnpin for BottomButtonProps<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for BottomButtonProps<F>where
F: UnwindSafe,
Blanket Implementations§
impl<Token, Builder, How> AllPropsFor<Builder, How> for Tokenwhere
Builder: Buildable<Token>,
<Builder as Buildable<Token>>::WrappedToken: HasAllProps<<Builder as Buildable<Token>>::Output, How>,
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
impl<T> HasAllProps<(), T> for T
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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>
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
self to a value of a Properties struct.