0 follower

Final Class Yiisoft\Yii\Bulma\ProgressBar

InheritanceYiisoft\Yii\Bulma\ProgressBar » Yiisoft\Widget\Widget

Progress Bar widget.

Native HTML progress bar.

echo ProgressBar::widget()->value(75);

Public Methods

Hide inherited methods

Method Description Defined By
attributes() Returns a new instance with the specified HTML attributes for widget. Yiisoft\Yii\Bulma\ProgressBar
autoIdPrefix() Returns a new instance with the specified prefix to the automatically generated widget IDs. Yiisoft\Yii\Bulma\ProgressBar
color() Returns a new instance with the specified progress bar color. Yiisoft\Yii\Bulma\ProgressBar
id() Returns a new instance with the specified ID of the widget. Yiisoft\Yii\Bulma\ProgressBar
maxValue() Returns a new instance with the specified maximum progress value. Yiisoft\Yii\Bulma\ProgressBar
render() Yiisoft\Yii\Bulma\ProgressBar
size() Returns a new instance with the specified progress bar size class. Yiisoft\Yii\Bulma\ProgressBar
value() Returns a new instance with the specified value of the progress. Yiisoft\Yii\Bulma\ProgressBar

Constants

Hide inherited constants

Constant Value Description Defined By
COLOR_ALL [ self::COLOR_PRIMARY, self::COLOR_LINK, self::COLOR_INFO, self::COLOR_SUCCESS, self::COLOR_WARNING, self::COLOR_DANGER, self::COLOR_DARK, ] Yiisoft\Yii\Bulma\ProgressBar
COLOR_DANGER 'is-danger' Yiisoft\Yii\Bulma\ProgressBar
COLOR_DARK 'is-dark' Yiisoft\Yii\Bulma\ProgressBar
COLOR_INFO 'is-info' Yiisoft\Yii\Bulma\ProgressBar
COLOR_PRIMARY 'is-primary' Yiisoft\Yii\Bulma\ProgressBar
COLOR_SUCCESS 'is-success' Yiisoft\Yii\Bulma\ProgressBar
COLOR_WARNING 'is-warning' Yiisoft\Yii\Bulma\ProgressBar
SIZE_ALL [ self::SIZE_SMALL, self::SIZE_MEDIUM, self::SIZE_LARGE, ] Yiisoft\Yii\Bulma\ProgressBar
SIZE_LARGE 'is-large' Yiisoft\Yii\Bulma\ProgressBar
SIZE_MEDIUM 'is-medium' Yiisoft\Yii\Bulma\ProgressBar
SIZE_SMALL 'is-small' Yiisoft\Yii\Bulma\ProgressBar

Method Details

Hide inherited methods

attributes() public method

Returns a new instance with the specified HTML attributes for widget.

public attributes( array $values ): self
$values array

Attribute values indexed by attribute names.

\Yiisoft\Html\Html::renderTagAttributes() For details on how attributes are being rendered.

                public function attributes(array $values): self
{
    $new = clone $this;
    $new->attributes = $values;
    return $new;
}

            
autoIdPrefix() public method

Returns a new instance with the specified prefix to the automatically generated widget IDs.

public autoIdPrefix( string $value ): self
$value string

The prefix to the automatically generated widget IDs.

                public function autoIdPrefix(string $value): self
{
    $new = clone $this;
    $new->autoIdPrefix = $value;
    return $new;
}

            
color() public method

Returns a new instance with the specified progress bar color.

public color( string $value ): self
$value string

The progress bar color. By default there is no color. Possible values: ProgressBar::COLOR_PRIMARY, ProgressBar::COLOR_LINK, ProgressBar::COLOR_INFO, ProgressBar::COLOR_SUCCESS, ProgressBar::COLOR_WARNING, ProgressBar::COLOR_DANGER, ProgressBar::COLOR_DARK.

                public function color(string $value): self
{
    if (!in_array($value, self::COLOR_ALL, true)) {
        $values = implode('", "', self::COLOR_ALL);
        throw new InvalidArgumentException("Invalid color. Valid values are: \"$values\".");
    }
    $new = clone $this;
    $new->color = $value;
    return $new;
}

            
id() public method

Returns a new instance with the specified ID of the widget.

public id( string $value ): self
$value string

The ID of the widget.

                public function id(string $value): self
{
    $new = clone $this;
    $new->attributes['id'] = $value;
    return $new;
}

            
maxValue() public method

Returns a new instance with the specified maximum progress value.

public maxValue( integer|null $value ): self
$value integer|null

Maximum progress value. Set 0 for no maximum.

                public function maxValue(?int $value): self
{
    if ($value < 0 || $value > 100) {
        throw new InvalidArgumentException('Invalid max value. It must be between 0 and 100.');
    }
    $new = clone $this;
    $new->attributes['max'] = $value;
    return $new;
}

            
render() public method

public render( ): string

                public function render(): string
{
    $attributes = $this->build($this->attributes);
    $content = '';
    if (array_key_exists('value', $attributes)) {
        /** @var float|null */
        $attributes['value'] = $attributes['value'] === 0.0 ? null : $attributes['value'];
        $content = $attributes['value'] > 0 ? $attributes['value'] . '%' : '';
    }
    return CustomTag::name('progress')
        ->attributes($attributes)
        ->content($content)
        ->render();
}

            
size() public method

Returns a new instance with the specified progress bar size class.

public size( string $value ): self
$value string

The progress bar size class. Default setting is "normal". Possible values: ProgressBar::SIZE_SMALL, ProgressBar::SIZE_MEDIUM, Model::SIZE_LARGE.

                public function size(string $value): self
{
    if (!in_array($value, self::SIZE_ALL, true)) {
        $values = implode('", "', self::SIZE_ALL);
        throw new InvalidArgumentException("Invalid size. Valid values are: \"$values\".");
    }
    $new = clone $this;
    $new->size = $value;
    return $new;
}

            
value() public method

Returns a new instance with the specified value of the progress.

public value( float|null $value ): self
$value float|null

The value of the progress. Set 0 to display loading animation.

                public function value(?float $value): self
{
    if ($value < 0 || $value > 100) {
        throw new InvalidArgumentException('Invalid value. It must be between 0 and 100.');
    }
    $new = clone $this;
    $new->attributes['value'] = $value;
    return $new;
}