Skip to content

Commit

Permalink
value metric
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Dec 22, 2023
1 parent cfe793d commit fdcc935
Show file tree
Hide file tree
Showing 37 changed files with 316 additions and 67 deletions.
4 changes: 3 additions & 1 deletion resources/views/resources/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
@if(! empty($widgets))
<div class="l-row l-row--column:sm:2 l-row--column:lg:3">
@foreach($widgets as $widget)
@include($widget['template'], $widget)
<turbo-frame id="widget-{{ $widget['key'] }}" src="{{ $widget['url'] }}">
@include('root::widgets.pending-widget', $widget)
</furbo-frame>
@endforeach
</div>
@endif
Expand Down
8 changes: 8 additions & 0 deletions resources/views/widgets/pending-widget.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<turbo-frame id="widget-{{ $key }}">
<div {{ $attrs }}>
<div class="app-widget__column">
<h2 class="app-widget__title">{{ $name }}</h2>
<p class="app-widget__data">{{ __('Loading') }}...</p>
</div>
</div>
</turbo-frame>
34 changes: 23 additions & 11 deletions resources/views/widgets/trend.blade.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
<div class="app-widget app-widget--primary">
<div class="app-widget__column">
<h2 class="app-widget__title">{{ $name }}</h2>
<p class="app-widget__data">65</p>
<div class="trending trending--up app-widget__trending">
<span class="trending__caption">+12%</span>
<x-root::icon name="trending-up" class="trending__icon" />
<turbo-frame id="widget-{{ $key }}">
<div {{ $attrs }}>
<div class="app-widget__column">
<h2 class="app-widget__title">
{{ $name }}
<div class="form-group">
<label class="form-label sr-only" for="widget-{{ $key }}-interval">{{ __('Interval') }}</label>
<select class="form-control form-control--sm" id="widget-{{ $key }}-interval">
<option value="this-week">This Week</option>
<option value="last-week">Last Week</option>
<option value="last-month">Last Month</option>
</select>
</div>
</h2>
<p class="app-widget__data">65</p>
<div class="trending trending--up app-widget__trending">
<span class="trending__caption">+12%</span>
<x-root::icon name="trending-up" class="trending__icon" />
</div>
</div>
<div class="app-widget__chart">
<div id="chart01"></div>
</div>
</div>
<div class="app-widget__chart">
<div id="chart01"></div>
</div>
</div>
</turbo-frame>
37 changes: 37 additions & 0 deletions resources/views/widgets/value.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<turbo-frame id="widget-{{ $key }}">
<div {{ $attrs }}>
@if(! is_null($icon))
<div class="app-widget__icon">
<x-root::icon :name="$icon" />
</div>
@endif
<div class="app-widget__column">
<h2 class="app-widget__title">
{{ $name }}
<div class="form-group">
<label class="form-label sr-only" for="widget-{{ $key }}-interval">{{ __('Interval') }}</label>
<select class="form-control form-control--sm" id="widget-{{ $key }}-interval">
<option value="this-week">This Week</option>
<option value="last-week">Last Week</option>
<option value="last-month">Last Month</option>
</select>
</div>
</h2>
<p class="app-widget__data">{{ $data['current'] }}</p>
@if($data['trend'] < 0)
<div class="trending trending--down app-widget__trending">
<span class="trending__caption">{{ $data['trend'] }}%</span>
<x-root::icon name="trending-down" class="trending__icon" />
</div>
@elseif($data['trend'] > 0)
<div class="trending trending--up app-widget__trending">
<span class="trending__caption">+{{ $data['trend'] }}%</span>
<x-root::icon name="trending-up" class="trending__icon" />
</div>
@endif
</div>
<div class="app-widget__chart">
<div id="chart01"></div>
</div>
</div>
</turbo-frame>
4 changes: 3 additions & 1 deletion resources/views/widgets/widget.blade.php
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<div class="app-widget"></div>
<turbo-frame id="widget-{{ $key }}">
<div {{ $attrs }}></div>
</turbo-frame>
2 changes: 1 addition & 1 deletion src/Actions/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function register(array|Action $actions): static
/**
* Filter the actions that are available for the current request and model.
*/
public function authorized(Request $request, Model $model = null): static
public function authorized(Request $request, ?Model $model = null): static
{
return $this->filter->authorized($request, $model)->values();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Conversion/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function setQuality(int $quality): static
*
* @return $this
*/
public function crop(int $width = null, int $height = null): static
public function crop(?int $width = null, ?int $height = null): static
{
$this->resize($width, $height, true);

Expand All @@ -106,7 +106,7 @@ public function crop(int $width = null, int $height = null): static
/**
* Resize the image.
*/
public function resize(int $width = null, int $height = null, bool $crop = false): static
public function resize(?int $width = null, ?int $height = null, bool $crop = false): static
{
$x = $y = 0;
[$originalWidth, $originalHeight] = getimagesize($this->medium->getAbsolutePath());
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BelongsToMany extends Relation
/**
* Create a new relation field instance.
*/
public function __construct(string $label, Closure|string $modelAttribute = null, Closure|string $relation = null)
public function __construct(string $label, Closure|string|null $modelAttribute = null, Closure|string|null $relation = null)
{
parent::__construct($label, $modelAttribute, $relation);

Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Boolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Boolean extends Field
/**
* Create a new file field instance.
*/
public function __construct(string $label, Closure|string $modelAttribute = null)
public function __construct(string $label, Closure|string|null $modelAttribute = null)
{
parent::__construct($label, $modelAttribute);

Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Color extends Field
/**
* Create a new field instance.
*/
public function __construct(string $label, Closure|string $modelAttribute = null)
public function __construct(string $label, Closure|string|null $modelAttribute = null)
{
parent::__construct($label, $modelAttribute);

Expand Down
4 changes: 2 additions & 2 deletions src/Fields/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Date extends Field
/**
* Create a new field instance.
*/
public function __construct(string $label, Closure|string $modelAttribute = null)
public function __construct(string $label, Closure|string|null $modelAttribute = null)
{
parent::__construct($label, $modelAttribute);

Expand Down Expand Up @@ -73,7 +73,7 @@ public function withTime(bool $value = true): static
/**
* Set the timezone.
*/
public function timezone(string $value = null): static
public function timezone(?string $value = null): static
{
$this->timezone = $value;

Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Dropdown extends Select
/**
* Create a new field instance.
*/
public function __construct(string $label, Closure|string $modelAttribute = null)
public function __construct(string $label, Closure|string|null $modelAttribute = null)
{
parent::__construct($label, $modelAttribute);

Expand Down
4 changes: 2 additions & 2 deletions src/Fields/Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Editor extends Field
/**
* Create a new field instance.
*/
public function __construct(string $label, Closure|string $modelAttribute = null)
public function __construct(string $label, Closure|string|null $modelAttribute = null)
{
parent::__construct($label, $modelAttribute);

Expand Down Expand Up @@ -83,7 +83,7 @@ public function getConfig(): array
/**
* Configure the media field.
*/
public function withMedia(Closure $callback = null): static
public function withMedia(?Closure $callback = null): static
{
if (is_null($this->fields)) {
$this->fields = new Fields();
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Email extends Text
/**
* Create a new field instance.
*/
public function __construct(string $label, Closure|string $modelAttribute = null)
public function __construct(string $label, Closure|string|null $modelAttribute = null)
{
parent::__construct($label, $modelAttribute);

Expand Down
8 changes: 4 additions & 4 deletions src/Fields/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ abstract class Field implements Arrayable, JsonSerializable
/**
* Create a new field instance.
*/
public function __construct(string $label, Closure|string $modelAttribute = null)
public function __construct(string $label, Closure|string|null $modelAttribute = null)
{
$this->computed = $modelAttribute instanceof Closure;

Expand Down Expand Up @@ -235,7 +235,7 @@ public function placeholder(string|Closure $value): static
/**
* Set the help attribute.
*/
public function help(string $value = null): static
public function help(?string $value = null): static
{
$this->help = $value;

Expand Down Expand Up @@ -329,7 +329,7 @@ public function resolveSearchQuery(Request $request, Builder $query, mixed $valu
/**
* Set the value resolver.
*/
public function value(Closure $callback = null): static
public function value(?Closure $callback = null): static
{
$this->valueResolver = $callback;

Expand Down Expand Up @@ -391,7 +391,7 @@ public function getValue(Model $model): mixed
/**
* Set the format resolver.
*/
public function format(Closure $callback = null): static
public function format(?Closure $callback = null): static
{
$this->formatResolver = $callback;

Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function persist(Request $request, Model $model): void
/**
* Filter the fields that are available for the current request and model.
*/
public function authorized(Request $request, Model $model = null): static
public function authorized(Request $request, ?Model $model = null): static
{
return $this->filter->authorized($request, $model)->values();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Fieldset.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Fieldset extends Field
/**
* Create a new field instance.
*/
public function __construct(string $label, Closure|string $modelAttribute = null)
public function __construct(string $label, Closure|string|null $modelAttribute = null)
{
parent::__construct($label, $modelAttribute);

Expand Down
2 changes: 1 addition & 1 deletion src/Fields/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class File extends MorphToMany
/**
* Create a new field instance.
*/
public function __construct(string $label, Closure|string $modelAttribute = null, Closure|string $relation = null)
public function __construct(string $label, Closure|string|null $modelAttribute = null, Closure|string|null $relation = null)
{
parent::__construct($label, $modelAttribute, $relation);

Expand Down
2 changes: 1 addition & 1 deletion src/Fields/HasMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HasMany extends HasOneOrMany
/**
* Create a new relation field instance.
*/
public function __construct(string $label, Closure|string $modelAttribute = null, Closure|string $relation = null)
public function __construct(string $label, Closure|string|null $modelAttribute = null, Closure|string|null $relation = null)
{
parent::__construct($label, $modelAttribute, $relation);

Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Hidden.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Hidden extends Field
/**
* Create a new field instance.
*/
public function __construct(string $label, Closure|string $modelAttribute = null)
public function __construct(string $label, Closure|string|null $modelAttribute = null)
{
parent::__construct($label, $modelAttribute);

Expand Down
Loading

0 comments on commit fdcc935

Please sign in to comment.