Add a little documentation to the Button class.

This commit is contained in:
Nate 2019-10-21 10:23:58 -06:00
parent 784aabca7e
commit 30bd7f8ff8
1 changed files with 35 additions and 4 deletions

View File

@ -46,7 +46,9 @@ if (!class_exists('button')) {
$button .= ">";
//icon
if ($array['icon'] && (
$button_icons != 'never' ||
$button_icons == 'only' ||
$button_icons == 'always' ||
$button_icons == 'auto' ||
!$array['label']
)) {
$icon_class = is_array($array['icon']) ? $array['icon']['text'] : 'fas fa-'.$array['icon'];
@ -58,7 +60,7 @@ if (!class_exists('button')) {
!$array['icon'] ||
$array['class'] == 'link'
)) {
$hide_class = $array['icon'] && $button_icons != 'always' && $button_icons != 'never' ? 'hide-md-dn' : null;
$hide_class = $array['icon'] && $button_icons != 'always' && $button_icons != 'never' ? 'hide-sm' : null;
$pad_class = $array['icon'] ? 'pad' : null;
$button .= "<span class='button-label ".$hide_class." ".$pad_class."'>".$array['label']."</span>";
}
@ -76,9 +78,38 @@ if (!class_exists('button')) {
}
/*
//usage example (all possible options)
//usage
echo button::create(['type'=>'button','label'=>$label,'icon'=>'icon','name'=>'btn','id'=>'btn','value'=>'value','link'=>'url','target'=>'_blank','onclick'=>'action','class'=>'name','style'=>'css','title'=>'title']);
echo button::create(['type'=>'button','label'=>$text['button-label'],'icon'=>'icon','name'=>'btn','id'=>'btn','value'=>'value','link'=>'url','target'=>'_blank','onclick'=>'javascript','class'=>'name','style'=>'css','title'=>$text['button-label']]);
echo button::create([
'type'=>'button',
'label'=>$text['button-label'],
'icon'=>'icon',
'name'=>'btn',
'id'=>'btn',
'value'=>'value',
'link'=>'url',
'target'=>'_blank',
'onclick'=>'javascript',
'class'=>'name',
'style'=>'css',
'title'=>$text['button-label']
]);
//options
note: all are parameters are optional, but at least set a value for label or icon
type 'button' (default) | 'submit' | 'link'
label button text
icon name without vendor prefix (e.g. 'user' instead of 'fa-user')
value submitted value (if type is also set to 'submit')
target '_blank' | '_self' (default) | etc
onclick javascript
class css class[es]
style css style[s]
title tooltip text (if not set, defaults to value of label)
*/