public static function build($config) { $type = $config['type']; $target = $config['target']; $createTitle = isset($config['createTitle']) ? $config['createTitle'] : null; if ($type == 'create' && is_null($createTitle)) { dd('Action component not configured properly - create requires title'); } $string = ''; if ($type == 'create') { $string .= '<a href="' . $target . '">'; $string .= Label::build(['title' => 'New ' . $createTitle, 'icon' => 'create', 'moreClass' => 'usa-action-horizontal']); $string .= '</a>'; } elseif (array_key_exists($type, Action::icons())) { if ($type == 'delete') { $string .= '<div class="usa-action-container delete">'; } else { $string .= '<div class="usa-action-container">'; } $string .= '<span><a href="' . $target . '">'; $string .= Icon::build($type); $string .= ucfirst($type); $string .= '</a>'; $string .= '</span>'; $string .= '</div>'; } return $string; }
/** * To allow the greatest flexibility in the definition of this element, * a keyed array is passed. * * Required keys * * **title:** The text to display within the label. * * Optional keys * * **big:** true|false Whether to use the "big" label from USWDS or not (default is false). * * **moreClass:** Extra classes to add to the label span. * * **background:** Class name for background color. * * **icon:** Approved font-awesome icon to include. See Icon. * * **surround:** HTML string, separated by a vertical bar to wrap the label span in. * * @param [type] $config [description] * @return [type] [description] */ public static function label($config) { return Label::build($config); }