Skip to content

Commit 24726cc

Browse files
authored
Merge pull request #3 from ricgrangeia/main
Add BS4 support and ID to CardWidget
2 parents 7eee6c3 + ec4cb6b commit 24726cc

9 files changed

+23
-10
lines changed

docs/CardWidget.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This is the basic class. It uses [CardToolsSupport](CardToolsSupportTrait.md), [
44

55
## Public properties, its types and default values
66

7+
- `string $id = ''` - id of a card
78
- `string $title = ''` - title of a card
89
- `bool $outline = false` - makes an outlined card
910
- `bool $background = false` - makes a colored card, uses $color property ([Bootstrap 4 colors](https://getbootstrap.com/docs/4.6/utilities/colors/) or additional [colors of AdminLTE](https://adminlte.io/docs/3.1//layout.html))
@@ -16,6 +17,7 @@ This is the basic class. It uses [CardToolsSupport](CardToolsSupportTrait.md), [
1617

1718
```php
1819
<?php CardWidget::begin([
20+
'id' => 'some-id', // id of a card
1921
'title' => 'Some title', // title of a card
2022
'color' => 'dark', // bootstrap color name 'success', 'danger' еtс.
2123
'gradient' => true, // use gradient background

src/CardToolsSupportTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace co0lc0der\Lte3Widgets;
44

5-
use yii\bootstrap\Html;
5+
use yii\bootstrap4\Html;
66

77
/**
88
* Trait CardToolsSupportTrait

src/CardWidget.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace co0lc0der\Lte3Widgets;
44

5-
use yii\bootstrap\Html;
5+
use yii\bootstrap4\Html;
66
use yii\web\View;
77

88
/**
@@ -17,7 +17,13 @@ class CardWidget extends \yii\base\Widget
1717
use ColorSupportTrait;
1818

1919
const OVERLAY_TYPES = ['overlay', 'dark'];
20-
20+
21+
/**
22+
* id of a card
23+
* @var string
24+
*/
25+
public string $id;
26+
2127
/**
2228
* title of a card
2329
* @var string
@@ -87,7 +93,11 @@ public function run(): string
8793
$this->content = ob_get_clean();
8894
$this->registerJs();
8995

90-
$html = Html::beginTag('div', ['class' => $this->getCardClass(), 'data-widget' => 'card-widget']);
96+
$html = Html::beginTag('div', [
97+
'id' => empty($this->id) ? null : $this->id,
98+
'class' => $this->getCardClass(),
99+
'data-widget' => 'card-widget'
100+
]);
91101

92102
$html .= $this->getCardHeader();
93103
$html .= $this->getCardBody();
@@ -228,4 +238,5 @@ protected function registerJs(): void
228238
", View::POS_READY, 'ajaxLoad');
229239
}
230240
}
241+
231242
}

src/ContactCardWidget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace co0lc0der\Lte3Widgets;
44

5-
use yii\bootstrap\Html;
5+
use yii\bootstrap4\Html;
66

77
/**
88
* Class ContactCardWidget

src/DirectChatWidget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace co0lc0der\Lte3Widgets;
44

5-
use yii\bootstrap\Html;
5+
use yii\bootstrap4\Html;
66

77
/**
88
* Class DirectChatWidget

src/ProfileCardWidget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace co0lc0der\Lte3Widgets;
44

5-
use yii\bootstrap\Html;
5+
use yii\bootstrap4\Html;
66

77
/**
88
* Class ProfileCardWidget

src/SocialWidget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace co0lc0der\Lte3Widgets;
44

5-
use yii\bootstrap\Html;
5+
use yii\bootstrap4\Html;
66

77
/**
88
* Class SocialWidget

src/TabsCardWidget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace co0lc0der\Lte3Widgets;
44

5-
use yii\bootstrap\Html;
5+
use yii\bootstrap4\Html;
66

77
/**
88
* Class TabsCardWidget

src/UserCardWidget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace co0lc0der\Lte3Widgets;
44

5-
use yii\bootstrap\Html;
5+
use yii\bootstrap4\Html;
66

77
/**
88
* Class UserCardWidget

0 commit comments

Comments
 (0)