public function progress_bar()
{
return _class('html')->progress_bar([
'35',
[
'val' => '20',
'type' => 'warning',
],
[
'val' => '10',
'type' => 'info',
],
], ['type' => 'success']);
}
public function progress_bar($data = [], $extra = [])
{
$extra['id'] = $extra['id'] ?: __FUNCTION__ . '_' . ++$this->_ids[__FUNCTION__];
$items = [];
foreach ((array) $data as $v) {
if ( ! is_array($v)) {
$val = $v;
$v = [];
} else {
$val = $v['val'];
}
$type = $v['type'] ?: $extra['type'];
$class_item = $v['class_item'] ?: $extra['class_item'];
$items[] = '<div class="progress-bar bar bar-' . $type . ' progress-bar-' . $type . ($class_item ? ' ' . $class_item : '')
. '" style="width: ' . $val . '%;' . ($v['style'] ? ' ' . $v['style'] : '') . '" role="progressbar"></div>';
}
return '<div class="progress' . ($extra['class'] ? ' ' . $extra['class'] : '') . '" id="' . $extra['id'] . '">' . implode(PHP_EOL, (array) $items) . '</div>';
}