🔌
Utility
This page provides a set of utility functions used by the Email Builder module.
These functions include methods for creating CSS styles based on various interface objects such as borders, padding and margin. Additionally, there are functions for merging objects, cloning objects, and debouncing a function.
The utility functions also include methods for generating random unique strings and manipulating browser cookies.
These utility functions provide a valuable set of tools for developers building email templates with the Email Builder module.
border
: Partial<IBorder> - The border object containing border color, style, width, and radius.rule
(optional): string - The CSS rule to apply the border styles. The default value is "border".
- An object containing CSS border styles and border-radius.
padding
: IPadding - The padding object containing padding values for each side.rule
(optional):"padding" | "margin"
- The CSS rule to apply the styles. The default value is "padding".
- An object containing CSS padding styles.
margin
: IMargin - The margin object containing margin values for the top and bottom.
- An object containing CSS margin styles.
font
: IFont - The font object containing font family, size, style, and weight.
- An object containing CSS font styles.
lineHeight
: ILineHeight - The line-height object containing the line-height value and unit.
- An object containing CSS line-height styles.
background
: Partial<IBackground> - The background object containing background color, url, and repeat.
- A string containing CSS background styles.
widthHeight
: Partial<IWidthHeight> - The width or height object containing value, unit, and auto boolean.
- A string containing CSS width or height styles.
Deep merge two objects. Use it at your own risk.
current
: Record<string, any> - The original object to merge into.updates
: Record<string, any> - The new object to merge from.
- The merged object.
An alternative to the lodash
defaultsDeep
function. Use it at your own risk.to
: Record<string, any> - The object to apply default properties to.sources
: Record<string, any>[] - An array of objects containing default properties.
- The object with default properties is applied.
An alternative to the lodash
cloneDeep
function. Use it at your own risk.obj
(optional): Object - The object to clone. Default is an empty object.
- The cloned object.
Debounce a function based on delay.
callback
: (...args: any[]) => T - The function to debounce.delay
(optional): number - The delay time in milliseconds. The default value is 1000.
- A function that debounces the original function.
Generate a random string.
from
(optional): number - The starting index for the random string. The default is 10.to
(optional): number - The length of the random string. The default is 5.
- A random string.
Create a cookie with the provided name and value, which will persist for a specified number of days.
name
- The name of the cookie.value
- The value of the cookie.days
(optional) - The number of days the cookie should persist. The default is 7.
Read a cookie with the provided name.
name
- The name of the cookie to retrieve.
Last modified 5mo ago