pub struct Bubbable {
    component: Vec<String>,
    pub attached_build: String,
    pub library: Library,
    pub style: String,
    pub translation: HashMap<String, String>,
    variables: HashMap<String, HashMap<String, Value>>,
}
Expand description

Support bubbable renderable with specific fields and process.

Fields§

§component: Vec<String>§attached_build: String

Render @attached for HTML head.

§library: Library

Manage libraries defined by the component, the payload and default.

§style: String

Render @variables for HTML style.

§translation: HashMap<String, String>

Collect translation to be used in templates with filter |t.

§variables: HashMap<String, HashMap<String, Value>>

Implementations§

source§

impl Bubbable

source

pub fn new() -> Self

source

fn add_library_css(&mut self, css: String)

source

fn add_library_js(&mut self, key: String, value: Value)

source

pub fn render_variables(&mut self)

Render @variables bubbable and attach to the ‘style’ field.

This iterates through the variables field, which contains scoped variable definitions. For each scope, it starts a CSS scope block. Then it iterates through the variable definitions, checking if the variable name exists in the global DEFINITION.variables config. If so, it renders the variable and value as CSS custom properties and adds them to the style field.

The end result is that any @variables defined in the input data are rendered to CSS custom properties and included in the output.

source

pub fn collect(&mut self, data: &Value)

Collect bubabble properties from a serde_json::Value.

This recursively traverses the provided data value to find and collect any bubbable properties like components, variables, etc. It checks for specific property keys starting with the KEY_PREFIX and calls handler methods for each bubbable type.

For Object values, it iterates through each key/value pair and checks the key before recurring or calling a handler.

For Array values, it simply recurs on each element.

Arguments
  • data - The serde_json Value to collect bubbable from.
source

fn handle_component(&mut self, value: &Value, map: &Map<String, Value>)

source

fn handle_attached(&mut self, value: &Value)

source

fn handle_variables(&mut self, value: &Value)

source

fn handle_library(&mut self, value: &Value)

source

fn handle_trans(&mut self, value: &Value)

source

fn build_library_dependencies(&mut self, name: &str)

source

fn build_component_library_component(&mut self, value: &str)

source

fn build_component_library_dependencies(&mut self, value: &str)

source

fn get_component_name_from_data( &mut self, name: &str, data: &Map<String, Value> ) -> String

Get component name from variant and data if defined in Design system definition components_variant_template.

Trait Implementations§

source§

impl Clone for Bubbable

source§

fn clone(&self) -> Bubbable

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Bubbable

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Bubbable

source§

fn default() -> Bubbable

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V