Add attribute brandImageOptions to NavBar (#79)
* Add attribute brandImageOptions to NavBar * add Changelog message --------- Co-authored-by: Max Kirmair <max.kirmair@waki-software.de>
This commit is contained in:
parent
cf7807d3c6
commit
1a4f4d66c9
@ -4,10 +4,12 @@ Yii Framework 2 bootstrap5 extension Change Log
|
|||||||
2.0.5 under development
|
2.0.5 under development
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
- Enh #78: Navbar has new attribute `brandImageOptions` (EvilKarter)
|
||||||
- Bug #74: Bootstrap5 Button is not registering clientEvents (simialbi)
|
- Bug #74: Bootstrap5 Button is not registering clientEvents (simialbi)
|
||||||
- Bug #72: Nav::isItemActive(): Return value must be of type bool, int returned (hirenbhut93)
|
- Bug #72: Nav::isItemActive(): Return value must be of type bool, int returned (hirenbhut93)
|
||||||
- Bug #62: Navbar can now accept `collapseOptions` to be `false` (theblindfrog)
|
- Bug #62: Navbar can now accept `collapseOptions` to be `false` (theblindfrog)
|
||||||
|
|
||||||
|
|
||||||
2.0.4 November 30, 2022
|
2.0.4 November 30, 2022
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
@ -75,6 +75,12 @@ class NavBar extends Widget
|
|||||||
* @since 2.0.8
|
* @since 2.0.8
|
||||||
*/
|
*/
|
||||||
public $brandImage = false;
|
public $brandImage = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array the HTML attributes of the brand image.
|
||||||
|
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
|
||||||
|
*/
|
||||||
|
public $brandImageOptions = [];
|
||||||
/**
|
/**
|
||||||
* @var array|string|bool $url the URL for the brand's hyperlink tag. This parameter will be processed by [[\yii\helpers\Url::to()]]
|
* @var array|string|bool $url the URL for the brand's hyperlink tag. This parameter will be processed by [[\yii\helpers\Url::to()]]
|
||||||
* and will be used for the "href" attribute of the brand link. Default value is false that means
|
* and will be used for the "href" attribute of the brand link. Default value is false that means
|
||||||
@ -144,7 +150,7 @@ class NavBar extends Widget
|
|||||||
$this->offcanvasOptions['id'] = "{$this->options['id']}-offcanvas";
|
$this->offcanvasOptions['id'] = "{$this->options['id']}-offcanvas";
|
||||||
}
|
}
|
||||||
if ($this->brandImage !== false) {
|
if ($this->brandImage !== false) {
|
||||||
$this->brandLabel = Html::img($this->brandImage);
|
$this->brandLabel = Html::img($this->brandImage, $this->brandImageOptions);
|
||||||
}
|
}
|
||||||
if ($this->brandLabel !== false) {
|
if ($this->brandLabel !== false) {
|
||||||
Html::addCssClass($this->brandOptions, ['widget' => 'navbar-brand']);
|
Html::addCssClass($this->brandOptions, ['widget' => 'navbar-brand']);
|
||||||
|
@ -49,6 +49,17 @@ EXPECTED;
|
|||||||
$this->assertContains('<a class="navbar-brand" href="/"><img src="/images/test.jpg" alt=""></a>', $out);
|
$this->assertContains('<a class="navbar-brand" href="/"><img src="/images/test.jpg" alt=""></a>', $out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testBrandImageOptions()
|
||||||
|
{
|
||||||
|
$out = NavBar::widget([
|
||||||
|
'brandImage' => '/images/test.jpg',
|
||||||
|
'brandImageOptions' => ['alt' => 'test image'],
|
||||||
|
'brandUrl' => '/',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertContains('<a class="navbar-brand" href="/"><img src="/images/test.jpg" alt="test image"></a>', $out);
|
||||||
|
}
|
||||||
|
|
||||||
public function testBrandLink()
|
public function testBrandLink()
|
||||||
{
|
{
|
||||||
$out = NavBar::widget([
|
$out = NavBar::widget([
|
||||||
|
Loading…
Reference in New Issue
Block a user