File tree Expand file tree Collapse file tree 5 files changed +61
-73
lines changed
resources/views/tables/columns Expand file tree Collapse file tree 5 files changed +61
-73
lines changed Original file line number Diff line number Diff line change 11@php
2- $total = $getState ()[' total' ];
3- $progress = $getState ()[' progress' ];
4- $progress = $total > 0 ? ($progress / $total ) * 100 : 0 ;
5-
6- if ($progress === 100 ){
7- $progressColor = ' #2980b9' ;
8- } else if ($progress > 50 ){
9- $progressColor = ' #27ae60' ;
10- } else if ($progress > 25 ){
11- $progressColor = ' #f39c12' ;
12- } else {
13- $progressColor = ' #e74c3c' ;
14- }
15-
16- $displayProgress = $progress === 100 ? number_format ($progress , 0 ) : number_format ($progress , 2 );
2+ $data = $column -> getProgressData ($getState ());
173@endphp
184
195<div class =" progress-circle" style ="
206 background : conic-gradient (
21- {{ $progressColor }} {{ $displayProgress * 3.6 }}deg ,
22- #e 5e 7eb {{ $displayProgress * 3.6 }}deg
7+ {{ $data [' progressColor '] }} {{ $data [' displayProgress '] * 3.6 }}deg ,
8+ #e 5e 7eb {{ $data [' displayProgress '] * 3.6 }}deg
239 ); " >
2410 @if ($column instanceof \LaraZeus\Progress\Tables\Columns\ CircleProgress && $column -> getCanShow () )
25- <small >{{ $displayProgress } } %</small >
11+ <small >{{ $data [ ' displayProgress' ] } } %</small >
2612 @endif
2713</div >
2814
5541 font-size : 8pt ;
5642 z-index : 2 ;
5743 }
58- </style >
44+ </style >
Original file line number Diff line number Diff line change 11@php
2- $total = $getState ()[' total' ];
3- $progress = $getState ()[' progress' ];
4- $progress = $total > 0 ? ($progress / $total ) * 100 : 0 ;
5-
6- if ($progress === 100 ){
7- $progressColor = ' #2980b9' ;
8- } else if ($progress > 50 ){
9- $progressColor = ' #27ae60' ;
10- } else if ($progress > 25 ){
11- $progressColor = ' #f39c12' ;
12- } else {
13- $progressColor = ' #e74c3c' ;
14- }
15-
16- $displayProgress = $progress === 100 ? number_format ($progress , 0 ) : number_format ($progress , 2 );
2+ $data = $column -> getProgressData ($getState ());
173@endphp
184
195<div class =" progress-container" >
20- <div class =" progress-bar" style =" width : {{ $displayProgress }}%; background-color : {{ $progressColor }};" ></div >
6+ <div class =" progress-bar" style =" width : {{ $data[ ' displayProgress' ] }}%; background-color : {{ $data[ ' progressColor' ] }};" ></div >
217 <div class =" progress-text" >
228 @if ($column instanceof \LaraZeus\Progress\Tables\Columns\ ProgressBar && $column -> getCanShow () )
239 <small @class ([
24- ' text-gray-700' => $displayProgress !== 100 ,
25- ' text-white' => $displayProgress === 100
10+ ' text-gray-700' => $data [ ' displayProgress' ] !== 100 ,
11+ ' text-white' => $data [ ' displayProgress' ] === 100
2612 ] )>
27- {{ $displayProgress } } %
13+ {{ $data [ ' displayProgress' ] } } %
2814 </small >
2915 @endif
3016 </div >
7763 background-position : 0 0 ;
7864 }
7965 }
80- </style >
66+ </style >
Original file line number Diff line number Diff line change 22
33namespace LaraZeus \Progress \Tables \Columns ;
44
5- use Filament \Tables \Columns \Column ;
6-
7- class CircleProgress extends Column
5+ class CircleProgress extends Progress
86{
9- protected bool $ canShow = true ;
10-
117 protected string $ view = 'lara-zeus-progress::tables.columns.circle-progress ' ;
12-
13- public function hideProgressValue ($ canShow = false ): static
14- {
15- $ this ->canShow = $ canShow ;
16-
17- return $ this ;
18- }
19-
20- public function getCanShow (): bool
21- {
22- return $ this ->canShow ;
23- }
248}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace LaraZeus \Progress \Tables \Columns ;
4+
5+ use Filament \Tables \Columns \Column ;
6+
7+ class Progress extends Column
8+ {
9+ protected bool $ canShow = true ;
10+
11+ public function hideProgressValue ($ canShow = false ): static
12+ {
13+ $ this ->canShow = $ canShow ;
14+
15+ return $ this ;
16+ }
17+
18+ public function getCanShow (): bool
19+ {
20+ return $ this ->canShow ;
21+ }
22+
23+ public function getProgressData (array $ state ): array
24+ {
25+ $ total = $ state ['total ' ] ?? 0 ;
26+ $ progress = $ state ['progress ' ] ?? 0 ;
27+ $ progress = $ total > 0 ? ($ progress / $ total ) * 100 : 0 ;
28+
29+ if ($ progress === 100 ) {
30+ $ progressColor = '#2980b9 ' ;
31+ } elseif ($ progress > 50 ) {
32+ $ progressColor = '#27ae60 ' ;
33+ } elseif ($ progress > 25 ) {
34+ $ progressColor = '#f39c12 ' ;
35+ } else {
36+ $ progressColor = '#e74c3c ' ;
37+ }
38+
39+ $ displayProgress = $ progress === 100 ? number_format ($ progress , 0 ) : number_format ($ progress , 2 );
40+ $ displayProgress = (int ) round ($ displayProgress );
41+
42+ return [
43+ 'progress ' => $ progress ,
44+ 'progressColor ' => $ progressColor ,
45+ 'displayProgress ' => $ displayProgress ,
46+ ];
47+ }
48+ }
Original file line number Diff line number Diff line change 22
33namespace LaraZeus \Progress \Tables \Columns ;
44
5- use Filament \Tables \Columns \Column ;
6-
7- class ProgressBar extends Column
5+ class ProgressBar extends Progress
86{
9- protected bool $ canShow = true ;
10-
117 protected string $ view = 'lara-zeus-progress::tables.columns.progress-bar ' ;
12-
13- public function hideProgressValue ($ canShow = false ): static
14- {
15- $ this ->canShow = $ canShow ;
16-
17- return $ this ;
18- }
19-
20- public function getCanShow (): bool
21- {
22- return $ this ->canShow ;
23- }
248}
You can’t perform that action at this time.
0 commit comments