JavaScript
All JavaScript helpers can be imported from the @eightshift/frontend-libs/scripts folder, so you don’t need to think about the internal folder structure of Eightshift Frontend Libs. If you want multiple functions imported just concatenate them in the import like this:
import { camelize, checkAttr, props, ...} from '@eightshift/frontend-libs/scripts';All of these helpers are generally only used in the Block Editor.
All UI icons.
illustrations
Section titled “illustrations”Illustrations for helper modals.
blockIcons
Section titled “blockIcons”Block icons, primarily used in block manifests.
getActions
Section titled “getActions”Create attributes actions from blocks manifest.json. This helper is deprecated and should not be used anymore.
getOption
Section titled “getOption”Provides ability to override component options from the parent block/component.
getOptionColors
Section titled “getOptionColors”Use this hook to filter the global colors out of the component or block manifest. This function is deprecated and getOption should be used.
getOptions
Section titled “getOptions”Combines two objects of options, one from current component and the other from the parent component.
getPaletteColors
Section titled “getPaletteColors”Use this hook to read editor-color-palette colors directly from WP built in store.
inserter
Section titled “inserter”Development inserter made to insert one or multiple blocks in the dom using console.
outputCssVariablesGlobal
Section titled “outputCssVariablesGlobal”Get Global manifest.json and return global variables as CSS variables.
outputCssVariables
Section titled “outputCssVariables”Get component/block options and process them in CSS variables.
getUnique
Section titled “getUnique”Returns a unique ID generally used for css variables.
overrideInnerBlockAttributes
Section titled “overrideInnerBlockAttributes”Used to set attributes on all innerBlocks. This value will be stored in the block editor store and set to a block.
overrideInnerBlockSimpleWrapperAttributes
Section titled “overrideInnerBlockSimpleWrapperAttributes”Used to set attributes on all innerBlocks preset only for simple wrapper setup. This value will be stored in the block editor store and set to a block.
pasteInto
Section titled “pasteInto”Paste event handler.
Output only attributes that are used in the component and remove everything else.
getAttributes
Section titled “getAttributes”Get Block attributes combined in one: “shared, global, wrapper, components, block”.
getExample
Section titled “getExample”Get Block example attributes combined in one: “components and block”.
registerBlocks
Section titled “registerBlocks”Register all Block Editor blocks using WP registerBlockType method.
registerVariations
Section titled “registerVariations”Register all Variations Editor blocks using WP registerBlockVariation method.
ucfirst
Section titled “ucfirst”Convert the first letter of a string to uppercase.
These are all helpers generally used anywhere.
camelize
Section titled “camelize”Returns a camelCase-formatted string.
checkAttr
Section titled “checkAttr”Check if attribute exist in attributes list and add default value if not.
checkAttrResponsive
Section titled “checkAttrResponsive”Map and check attributes for responsive object.
cookies
Section titled “cookies”Helper to set and unset cookies.
debounce
Section titled “debounce”Debounces the provided function.
devices
Section titled “devices”Detect a certain device, so specific functionality can be implemented for it.
dynamicImport
Section titled “dynamicImport”Loop all paths required using require.context method.
elementChildrenHeight
Section titled “elementChildrenHeight”Returns height of the element measured by height of its children.
escape-string
Section titled “escape-string”Takes the provided string and removes special characters
navigator
Section titled “navigator”The Navigator.vibrate() method pulses the vibration hardware on the device, if such hardware exists.
responsiveSelectors
Section titled “responsiveSelectors”Create responsive selectors used for responsive attributes.
selector
Section titled “selector”Returns BEM selector for HTML class and checks if the condition part is set.
truncateMiddle
Section titled “truncateMiddle”Slices the string and inputs the provided separator after the specified characters.
These are all helpers generally only in specific plugins.
yoastSeo
Section titled “yoastSeo”This helper will search all blocks and components manifests and find attributes that have “seo”: “true” key. This key will be added in to the content and proceed by the YoastSeo Analysis plugin.