Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 /**
  * To allow the greatest flexibility in the definition of this element,
  * a keyed array is passed.
  *
  * Required keys
  * * **type:** See Icon.
  * * **target:** Anchor href target for the cancel link.
  *
  * Create type required keys
  * * **createTitle:** Required if type is "create".
  * 
  * @param  [type] $config Array of key-value pairs.
  * @return [type]        [description]
  */
 public static function action($config)
 {
     return Action::build($config);
 }