Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
<x-dynamic-component :component="$getEntryWrapperView()" :entry="$entry">
@php
$total = $getState()['total'];
$progress = $getState()['progress'];
$progress = $total > 0 ? ($progress / $total) * 100 : 0;

if($progress === 100){
$progressColor = '#2980b9';
} else if($progress > 50){
$progressColor = '#27ae60';
} else if($progress > 25){
$progressColor = '#f39c12';
} else {
$progressColor = '#e74c3c';
}

$displayProgress = $progress === 100 ? number_format($progress, 0) : number_format($progress, 2);
$data = $column->getProgressData($getState());
@endphp

<div class="progress-circle" style="
background: conic-gradient(
{{ $progressColor }} {{ $displayProgress * 3.6 }}deg,
#e5e7eb {{ $displayProgress * 3.6 }}deg
{{ $data['progressColor'] }} {{ $data['displayProgress'] * 3.6 }}deg,
#e5e7eb {{ $data['displayProgress'] * 3.6 }}deg
);">
@if($entry instanceof \LaraZeus\Progress\Infolists\Components\CircleProgressEntry && $entry->getCanShow())
<small>{{ $displayProgress }}%</small>
<small>{{ $data['displayProgress'] }}%</small>
@endif
</div>

<style>
.progress-circle {
position: relative;
Expand Down
24 changes: 5 additions & 19 deletions resources/views/infolists/components/progress-bar-entry.blade.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
<x-dynamic-component :component="$getEntryWrapperView()" :entry="$entry">
@php
$total = $getState()['total'];
$progress = $getState()['progress'];
$progress = $total > 0 ? ($progress / $total) * 100 : 0;

if($progress === 100){
$progressColor = '#2980b9';
} else if($progress > 50){
$progressColor = '#27ae60';
} else if($progress > 25){
$progressColor = '#f39c12';
} else {
$progressColor = '#e74c3c';
}

$displayProgress = $progress === 100 ? number_format($progress, 0) : number_format($progress, 2);
$data = $column->getProgressData($getState());
@endphp

<div class="progress-container">
<div class="progress-bar" style="width: {{ $displayProgress }}%; background-color: {{ $progressColor }};"></div>
<div class="progress-bar" style="width: {{ $data['displayProgress'] }}%; background-color: {{ $data['progressColor'] }};"></div>
<div class="progress-text">
@if($entry instanceof \LaraZeus\Progress\Infolists\Components\ProgressBarEntry && $entry->getCanShow())
<small @class([
'text-gray-700' => $displayProgress != 100,
'text-white' => $displayProgress == 100
'text-gray-700' => $data['displayProgress'] != 100,
'text-white' => $data['displayProgress'] == 100
])>
{{ $displayProgress }}%
{{ $data['displayProgress'] }}%
</small>
@endif
</div>
Expand Down
24 changes: 5 additions & 19 deletions resources/views/tables/columns/circle-progress.blade.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
@php
$total = $getState()['total'];
$progress = $getState()['progress'];
$progress = $total > 0 ? ($progress / $total) * 100 : 0;

if($progress === 100){
$progressColor = '#2980b9';
} else if($progress > 50){
$progressColor = '#27ae60';
} else if($progress > 25){
$progressColor = '#f39c12';
} else {
$progressColor = '#e74c3c';
}

$displayProgress = $progress === 100 ? number_format($progress, 0) : number_format($progress, 2);
$data = $column->getProgressData($getState());
@endphp

<div class="progress-circle" style="
background: conic-gradient(
{{ $progressColor }} {{ $displayProgress * 3.6 }}deg,
#e5e7eb {{ $displayProgress * 3.6 }}deg
{{ $data['progressColor'] }} {{ $data['displayProgress'] * 3.6 }}deg,
#e5e7eb {{ $data['displayProgress'] * 3.6 }}deg
);">
@if($column instanceof \LaraZeus\Progress\Tables\Columns\CircleProgress && $column->getCanShow())
<small>{{ $displayProgress }}%</small>
<small>{{ $data['displayProgress'] }}%</small>
@endif
</div>

Expand Down Expand Up @@ -55,4 +41,4 @@
font-size: 8pt;
z-index: 2;
}
</style>
</style>
26 changes: 6 additions & 20 deletions resources/views/tables/columns/progress-bar.blade.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
@php
$total = $getState()['total'];
$progress = $getState()['progress'];
$progress = $total > 0 ? ($progress / $total) * 100 : 0;

if($progress === 100){
$progressColor = '#2980b9';
} else if($progress > 50){
$progressColor = '#27ae60';
} else if($progress > 25){
$progressColor = '#f39c12';
} else {
$progressColor = '#e74c3c';
}

$displayProgress = $progress === 100 ? number_format($progress, 0) : number_format($progress, 2);
$data = $column->getProgressData($getState());
@endphp

<div class="progress-container">
<div class="progress-bar" style="width: {{ $displayProgress }}%; background-color: {{ $progressColor }};"></div>
<div class="progress-bar" style="width: {{ $data['displayProgress'] }}%; background-color: {{ $data['progressColor'] }};"></div>
<div class="progress-text">
@if($column instanceof \LaraZeus\Progress\Tables\Columns\ProgressBar && $column->getCanShow())
<small @class([
'text-gray-700' => $displayProgress !== 100,
'text-white' => $displayProgress === 100
'text-gray-700' => $data['displayProgress'] !== 100,
'text-white' => $data['displayProgress'] === 100
])>
{{ $displayProgress }}%
{{ $data['displayProgress'] }}%
</small>
@endif
</div>
Expand Down Expand Up @@ -77,4 +63,4 @@
background-position: 0 0;
}
}
</style>
</style>
18 changes: 1 addition & 17 deletions src/Infolists/Components/CircleProgressEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,7 @@

namespace LaraZeus\Progress\Infolists\Components;

use Filament\Infolists\Components\Entry;

class CircleProgressEntry extends Entry
class CircleProgressEntry extends ProgressEntry
{
protected bool $canShow = true;

protected string $view = 'lara-zeus-progress::infolists.components.circle-progress-entry';

public function hideProgressValue($canShow = false): static
{
$this->canShow = $canShow;

return $this;
}

public function getCanShow(): bool
{
return $this->canShow;
}
}
18 changes: 1 addition & 17 deletions src/Infolists/Components/ProgressBarEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,7 @@

namespace LaraZeus\Progress\Infolists\Components;

use Filament\Infolists\Components\Entry;

class ProgressBarEntry extends Entry
class ProgressBarEntry extends ProgressEntry
{
protected bool $canShow = true;

protected string $view = 'lara-zeus-progress::infolists.components.progress-bar-entry';

public function hideProgressValue($canShow = false): static
{
$this->canShow = $canShow;

return $this;
}

public function getCanShow(): bool
{
return $this->canShow;
}
}
49 changes: 49 additions & 0 deletions src/Infolists/Components/ProgressEntry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace LaraZeus\Progress\Infolists\Components;

use Filament\Infolists\Components\Entry;

class ProgressEntry extends Entry
{
protected bool $canShow = true;

protected string $view = 'lara-zeus-progress::infolists.components.circle-progress-entry';

public function hideProgressValue($canShow = false): static
{
$this->canShow = $canShow;

return $this;
}

public function getCanShow(): bool
{
return $this->canShow;
}

public function getProgressData(array $state): array
{
$total = $state['total'] ?? 0;
$progress = $state['progress'] ?? 0;
$progress = $total > 0 ? ($progress / $total) * 100 : 0;

if ($progress === 100) {
$progressColor = '#2980b9';
} elseif ($progress > 50) {
$progressColor = '#27ae60';
} elseif ($progress > 25) {
$progressColor = '#f39c12';
} else {
$progressColor = '#e74c3c';
}

$displayProgress = number_format($progress);

return [
'progress' => $progress,
'progressColor' => $progressColor,
'displayProgress' => $displayProgress,
];
}
}
18 changes: 1 addition & 17 deletions src/Tables/Columns/CircleProgress.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,7 @@

namespace LaraZeus\Progress\Tables\Columns;

use Filament\Tables\Columns\Column;

class CircleProgress extends Column
class CircleProgress extends Progress
{
protected bool $canShow = true;

protected string $view = 'lara-zeus-progress::tables.columns.circle-progress';

public function hideProgressValue($canShow = false): static
{
$this->canShow = $canShow;

return $this;
}

public function getCanShow(): bool
{
return $this->canShow;
}
}
47 changes: 47 additions & 0 deletions src/Tables/Columns/Progress.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace LaraZeus\Progress\Tables\Columns;

use Filament\Tables\Columns\Column;

class Progress extends Column
{
protected bool $canShow = true;

public function hideProgressValue($canShow = false): static
{
$this->canShow = $canShow;

return $this;
}

public function getCanShow(): bool
{
return $this->canShow;
}

public function getProgressData(array $state): array
{
$total = $state['total'] ?? 0;
$progress = $state['progress'] ?? 0;
$progress = $total > 0 ? ($progress / $total) * 100 : 0;

if ($progress === 100) {
$progressColor = '#2980b9';
} elseif ($progress > 50) {
$progressColor = '#27ae60';
} elseif ($progress > 25) {
$progressColor = '#f39c12';
} else {
$progressColor = '#e74c3c';
}

$displayProgress = number_format($progress);

return [
'progress' => $progress,
'progressColor' => $progressColor,
'displayProgress' => $displayProgress,
];
}
}
18 changes: 1 addition & 17 deletions src/Tables/Columns/ProgressBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,7 @@

namespace LaraZeus\Progress\Tables\Columns;

use Filament\Tables\Columns\Column;

class ProgressBar extends Column
class ProgressBar extends Progress
{
protected bool $canShow = true;

protected string $view = 'lara-zeus-progress::tables.columns.progress-bar';

public function hideProgressValue($canShow = false): static
{
$this->canShow = $canShow;

return $this;
}

public function getCanShow(): bool
{
return $this->canShow;
}
}
Loading