Skip to content

Commit f051726

Browse files
committed
✔ Added Dynamic Binding
1 parent bab2817 commit f051726

File tree

5 files changed

+76
-8
lines changed

5 files changed

+76
-8
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,37 @@ Use this in the [jeroennoten/Laravel-AdminLTE](https://github.com/jeroennoten/La
197197
| icon | The fontawesome icon class. Eg. ``fas fa-star``, ``fas fa-user-plus`` | false | string |
198198
| grad | Use gradient color? ``true/false`` | false | boolean |
199199
| full | Use full INFO BOX? ``true/false`` | false | boolean |
200+
| progress | Show Progress bar? | false | int |
201+
| comment | Show comment? | false | string |
202+
| id | Dynamic Binding? | false | string |
200203

201204
**EXAMPLE**
202205
```html
203206
<x-dg-info-box bg="success" title="Yo title" text="123" icon="fas fa-star" :full="true" :grad="true"/>
204207
```
205208

209+
**DYNAMIC BINDINGS**
210+
Set ``id`` attibute, this will enable dynamic attributes for:
211+
| ID |
212+
|----|
213+
|#{id}-title|
214+
|#{id}-text|
215+
|#{id}-progress|
216+
|#{id}-comment|
217+
218+
**EXAMPLE**
219+
```html
220+
<x-dg-info-box bg="success" title="Users" text="100" icon="fas fa-star" :full="true" :grad="true" id="userbox" />
221+
222+
<script>
223+
$(()=>{
224+
$('#userbox-title').text('Users');
225+
$('#userbox-text').text('102');
226+
});
227+
</script>
228+
```
229+
230+
206231
#### **SMALL BOX**
207232
![Small Box](assets/small-box.png)
208233

@@ -220,12 +245,33 @@ Use this in the [jeroennoten/Laravel-AdminLTE](https://github.com/jeroennoten/La
220245
| url | The url to follow. | false | string |
221246
| urlText | Text of the HyperLink. | false | string |
222247
| loading | Set loading state ``true/false`` | false | boolean |
248+
| id | Dynamic Binding? | false | string |
223249

224250
**EXAMPLE**
225251
```html
226252
<x-dg-small-box title="Small box" text="500" bg="warning" url="#" urlText="See More" loading="false" />
227253
```
228254

255+
**DYNAMIC BINDINGS**
256+
Set ``id`` attibute, this will enable dynamic attributes for:
257+
| ID |
258+
|----|
259+
|#{id}-title|
260+
|#{id}-text|
261+
|#{id}-link|
262+
263+
**EXAMPLE**
264+
```html
265+
<x-dg-small-box title="Small box" text="500" bg="warning" url="#" urlText="See More" loading="false" $id="userbox"/>
266+
267+
<script>
268+
$(()=>{
269+
$('#userbox-text').text('102');
270+
$('#userbox-link').attr('href',new.link);
271+
});
272+
</script>
273+
```
274+
229275
#### **CARDS**
230276
![Cards](assets/cards.png)
231277

src/Components/InfoBox.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@
77
class InfoBox extends Component
88
{
99
public $bg, $icon, $title, $text, $full, $grad;
10+
public $id, $progress, $comment;
1011

1112
public function __construct(
12-
$bg = 'info', $icon = 'fas fa-star',
13-
$title, $text, $full = false, $grad = false)
13+
$bg = 'info', $icon = 'fas fa-star', $id = null,
14+
$title, $text, $full = false, $grad = false,
15+
$progress = false, $comment = false)
1416
{
17+
$this->id = $id;
1518
$this->bg = $bg;
1619
$this->icon = $icon;
1720
$this->title = $title;
1821
$this->text = $text;
1922
$this->full = $full;
2023
$this->grad = $grad;
24+
$this->progress = $progress;
25+
$this->comment = $comment;
2126
}
2227

2328
public function background()

src/Components/SmallBox.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
class SmallBox extends Component
88
{
99
public $bg, $icon, $title, $text, $url, $urlText, $loading;
10+
public $id;
1011

1112
public function __construct(
12-
$bg = 'info', $icon = 'fas fa-star', $title,
13+
$bg = 'info', $icon = 'fas fa-star', $title, $id = null,
1314
$text, $url='#', $urlText = null,
1415
$loading = false)
1516
{
17+
$this->id = $id;
1618
$this->bg = $bg;
1719
$this->icon = $icon;
1820
$this->title = $title;

src/resources/components/info-box.blade.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,22 @@
33
<i class="{{$icon}}"></i>
44
</span>
55
<div class="info-box-content">
6-
<span class="info-box-text">{{$title}}</span>
7-
<span class="info-box-number">{{$text}}</span>
6+
<span class="info-box-text" id="{{!is_null($id) ? $id.'-title' : null}}">
7+
{{$title}}
8+
</span>
9+
<span class="info-box-number" id="{{!is_null($id) ? $id.'-text' : null}}">
10+
{{$text}}
11+
</span>
12+
@if($progress)
13+
<div class="progress">
14+
<div class="progress-bar" id="{{!is_null($id) ? $id.'-progress' : null}}" style="width: {{$progress}}%"></div>
15+
</div>
16+
@endif
17+
18+
@if($comment)
19+
<span class="progress-description" id="{{!is_null($id) ? $id.'-comment' : null}}">
20+
{{$comment}}
21+
</span>
22+
@endif
823
</div>
924
</div>

src/resources/components/small-box.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
</div>
66
@endif
77
<div class="inner">
8-
<h3>{{$text}}</h3>
9-
<p>{{$title}}</p>
8+
<h3 id="{{!is_null($id) ? $id.'-text' : null}}">{{$text}}</h3>
9+
<p id="{{!is_null($id) ? $id.'-title' : null}}">{{$title}}</p>
1010
</div>
1111
<div class="icon">
1212
<i class="{{$icon}}"></i>
1313
</div>
14-
<a href="{{$url}}" class="small-box-footer">
14+
<a id="{{!is_null($id) ? $id.'-link' : null}}" href="{{$url}}" class="small-box-footer">
1515
{{$urlTextLine}} <i class="fas fa-arrow-circle-right"></i>
1616
</a>
1717
</div>

0 commit comments

Comments
 (0)