The reactor starter theme comes with a component framework and library.
Overview of components
This list will reflect the components that are currently available in the reactor theme, and the features they support.
Render functions
There are several functions that come with this library, here is how and when to use which function.
fuse( $components, $args )
The fuse command is used to start rendering a compontent. The first paramater $components is the name of the component, while $args passes the arguments – these are the options for the component will be rendered with.
Args can in theory be any type, but not all types will be supported. However, any argument can be a function.
fuse_html( $content )
Deprecated functions:
The framework has been refactored, fuse, fuse_get and fuse_child now all perform the same action and should no longer be used. Outputting a component is now done by using echo in front of it, or by using the fuse_print function
This is a shorthand function for fuse( ‘html’, $content )
Component setup
Components are located in /partials/components/. Each component has its own folder with an identically named php file inside. In addition, a file with the suffix -config.php can be added to add additional configuration of the arguments that the element supports. The following methods can used on the $args object in the -config.php file.
mark_as_option( $key )
Marks an argument as an option, which means that this won’t be converted to a attribute in the outer html element of the component.
add_default( $key, $value )
Provides a default value for an attribute.
add_option_default( $key, $value )
Provides a default value for an attribute, and marks it as an option, which means that this option won’t be converted to a attribute in the outer html element of the component.
add_default_class( $class )
Appends a default class (string or array) to the list of classes that will be added to the component regardless of the class argument provided by the fuse function.
get( $key )
Retrieves the value of an argument if available, the default will be returned if none is set and an empty string if no default is provided.
has( $key )
Checks if a value or default value is provided for an argument.
empty( $key )
Checks if an argument returns an empty value.
is( $key, $value )
Checks if an argument returns a value of a specific value
fuse( $component, $key )
Rendres a single child based on an argument. Passes on the parents arguments to allow components to «inherit» values.
fuse_children( $key )
Renders a list of children based on an argument. Passes on the parents arguments to allow components to «inherit» values.