-
Notifications
You must be signed in to change notification settings - Fork 0
/
Button.php
68 lines (67 loc) · 1.73 KB
/
Button.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace makroxyz\materializecss;
/**
* Description of Button
*
* @author marco
*/
class Button extends Widget
{
/**
* @var string the tag to use to render the button
*/
public $tagName = 'button';
/**
* @var bool button css class type
* @see http://materializecss.com/buttons.html#flat
*/
public $flat = false;
/**
* @var string the button label
*/
public $label = 'Button';
/**
* @var boolean whether the label should be HTML-encoded.
*/
public $encodeLabel = true;
/**
* @var string wave effect color
*/
public $waveColor = Waves::WAVE_LIGHT;
/**
* @var string|null optional wave effect form, default to ripple
*/
public $waveFrom;
/**
* @var string|null
*/
public $iconName;
/**
* @var string|null name-value pairs that will be used to initialize the Icon properties
*/
public $iconConfig;
/**
* Initializes the widget.
* If you override this method, make sure you call the parent implementation first.
*/
public function init()
{
parent::init();
$this->clientOptions = false;
Html::addCssClass($this->options, $this->flat ? 'btn-flat' : 'btn');
Waves::addWaveEffect($this->options, $this->waveColor, $this->waveFrom);
}
/**
* Renders the widget.
*/
public function run()
{
$content = '';
if ($this->iconName !== null) {
$this->iconConfig['name'] = $this->iconName;
$content .= Icon::widget($this->iconConfig);
}
$content .= $this->encodeLabel ? Html::encode($this->label) : $this->label;
return Html::tag($this->tagName, $content, $this->options);
}
}