pub struct JsStyle { /* private fields */ }Expand description
JavaScript-friendly wrapper for Style.
This provides a chainable API suitable for JavaScript usage, with methods that return a new JsStyle for method chaining.
Implementations§
Source§impl JsStyle
impl JsStyle
Sourcepub fn foreground(self, color: &str) -> JsStyle
pub fn foreground(self, color: &str) -> JsStyle
Set the foreground color using a hex string (e.g., “#ff00ff”).
Sourcepub fn background(self, color: &str) -> JsStyle
pub fn background(self, color: &str) -> JsStyle
Set the background color using a hex string (e.g., “#1a1a1a”).
Sourcepub fn strikethrough(self) -> JsStyle
pub fn strikethrough(self) -> JsStyle
Enable strikethrough text.
Sourcepub fn padding_all(self, value: u16) -> JsStyle
pub fn padding_all(self, value: u16) -> JsStyle
Set padding on all sides.
Can be called with:
- 1 argument: all sides
- 2 arguments: vertical, horizontal
- 4 arguments: top, right, bottom, left
Sourcepub fn padding_vh(self, vertical: u16, horizontal: u16) -> JsStyle
pub fn padding_vh(self, vertical: u16, horizontal: u16) -> JsStyle
Set padding with vertical and horizontal values.
Sourcepub fn padding(self, top: u16, right: u16, bottom: u16, left: u16) -> JsStyle
pub fn padding(self, top: u16, right: u16, bottom: u16, left: u16) -> JsStyle
Set padding for all four sides individually.
Sourcepub fn margin_all(self, value: u16) -> JsStyle
pub fn margin_all(self, value: u16) -> JsStyle
Set margin on all sides.
Sourcepub fn margin_vh(self, vertical: u16, horizontal: u16) -> JsStyle
pub fn margin_vh(self, vertical: u16, horizontal: u16) -> JsStyle
Set margin with vertical and horizontal values.
Sourcepub fn margin(self, top: u16, right: u16, bottom: u16, left: u16) -> JsStyle
pub fn margin(self, top: u16, right: u16, bottom: u16, left: u16) -> JsStyle
Set margin for all four sides individually.
Sourcepub fn border_style(self, style: &str) -> JsStyle
pub fn border_style(self, style: &str) -> JsStyle
Set the border style.
Available styles: “normal”, “rounded”, “thick”, “double”, “hidden”, “ascii”
Sourcepub fn border_all(self) -> JsStyle
pub fn border_all(self) -> JsStyle
Enable border on all sides.
Sourcepub fn border_top(self) -> JsStyle
pub fn border_top(self) -> JsStyle
Enable border on top.
Sourcepub fn border_bottom(self) -> JsStyle
pub fn border_bottom(self) -> JsStyle
Enable border on bottom.
Sourcepub fn border_left(self) -> JsStyle
pub fn border_left(self) -> JsStyle
Enable border on left.
Sourcepub fn border_right(self) -> JsStyle
pub fn border_right(self) -> JsStyle
Enable border on right.
Sourcepub fn align_horizontal(self, value: f64) -> JsStyle
pub fn align_horizontal(self, value: f64) -> JsStyle
Set horizontal alignment.
Values: 0.0 = left, 0.5 = center, 1.0 = right
Sourcepub fn align_vertical(self, value: f64) -> JsStyle
pub fn align_vertical(self, value: f64) -> JsStyle
Set vertical alignment.
Values: 0.0 = top, 0.5 = center, 1.0 = bottom
Sourcepub fn align_left(self) -> JsStyle
pub fn align_left(self) -> JsStyle
Align content to the left.
Sourcepub fn align_center(self) -> JsStyle
pub fn align_center(self) -> JsStyle
Align content to the center.
Sourcepub fn align_right(self) -> JsStyle
pub fn align_right(self) -> JsStyle
Align content to the right.
Sourcepub fn render(&self, content: &str) -> String
pub fn render(&self, content: &str) -> String
Render content with this style as HTML.
Returns an HTML string with inline styles or CSS classes.
Sourcepub fn render_ansi(&self, content: &str) -> String
pub fn render_ansi(&self, content: &str) -> String
Render content with this style as ANSI escape sequences.
This is useful for terminal-like displays in web applications.
Trait Implementations§
Source§impl FromWasmAbi for JsStyle
impl FromWasmAbi for JsStyle
Source§impl IntoWasmAbi for JsStyle
impl IntoWasmAbi for JsStyle
Source§impl LongRefFromWasmAbi for JsStyle
impl LongRefFromWasmAbi for JsStyle
Source§impl OptionFromWasmAbi for JsStyle
impl OptionFromWasmAbi for JsStyle
Source§impl OptionIntoWasmAbi for JsStyle
impl OptionIntoWasmAbi for JsStyle
Source§impl RefFromWasmAbi for JsStyle
impl RefFromWasmAbi for JsStyle
Source§type Anchor = RcRef<JsStyle>
type Anchor = RcRef<JsStyle>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§unsafe fn ref_from_abi(
js: <JsStyle as RefFromWasmAbi>::Abi,
) -> <JsStyle as RefFromWasmAbi>::Anchor
unsafe fn ref_from_abi( js: <JsStyle as RefFromWasmAbi>::Abi, ) -> <JsStyle as RefFromWasmAbi>::Anchor
Source§impl RefMutFromWasmAbi for JsStyle
impl RefMutFromWasmAbi for JsStyle
Source§impl TryFromJsValue for JsStyle
impl TryFromJsValue for JsStyle
Source§impl VectorFromWasmAbi for JsStyle
impl VectorFromWasmAbi for JsStyle
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi( js: <JsStyle as VectorFromWasmAbi>::Abi, ) -> Box<[JsStyle]>
Source§impl VectorIntoWasmAbi for JsStyle
impl VectorIntoWasmAbi for JsStyle
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi( vector: Box<[JsStyle]>, ) -> <JsStyle as VectorIntoWasmAbi>::Abi
Auto Trait Implementations§
impl Freeze for JsStyle
impl !RefUnwindSafe for JsStyle
impl Send for JsStyle
impl Sync for JsStyle
impl Unpin for JsStyle
impl !UnwindSafe for JsStyle
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.