Skip to content

Commit

Permalink
Update description position implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphjsmit committed Aug 1, 2022
1 parent 82f4f6e commit 8f5e62e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/tables/resources/views/columns/text-column.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
'whitespace-normal' => $canWrap(),
]) }}
>
@if(($showDescriptionOnTop = $getShowDescriptionOnTop()) && ($description = $getDescription()))
@if(($descriptionPosition = $getDescriptionPosition()) === 'above' && ($description = $getDescription()))
<span class="block text-sm text-gray-400"> {!! \Illuminate\Support\Str::of($description)->markdown()->sanitizeHtml() !!}</span>
@endif

{{ $getFormattedState() }}

@if(! $showDescriptionOnTop && ($description = $getDescription()))
@if($descriptionPosition === 'below' && ($description = $getDescription()))
<span class="block text-sm text-gray-400">{!! \Illuminate\Support\Str::of($description)->markdown()->sanitizeHtml() !!}</span>
@endif
</div>
14 changes: 7 additions & 7 deletions packages/tables/src/Columns/Concerns/HasDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ trait HasDescription
{
protected string | Closure | null $description = null;

protected bool | Closure | null $showDescriptionOnTop = null;
protected string | Closure | null $descriptionPosition = 'below';

public function description(string | Closure | HtmlString | null $description, bool | Closure | null $showDescriptionOnTop = false): static
public function description(string | Closure | HtmlString | null $description, string | Closure | null $descriptionPosition = 'below'): static
{
$this->description = $description;
$this->showDescriptionOnTop($showDescriptionOnTop);
$this->descriptionPosition($descriptionPosition);

return $this;
}
Expand All @@ -24,15 +24,15 @@ public function getDescription(): string | HtmlString | null
return $this->evaluate($this->description);
}

public function showDescriptionOnTop(bool | Closure | null $showDescriptionOnTop = true): static
public function descriptionPosition(string | Closure | null $descriptionPosition = 'string'): static
{
$this->showDescriptionOnTop = $showDescriptionOnTop;
$this->descriptionPosition = $descriptionPosition;

return $this;
}

public function getShowDescriptionOnTop(): bool
public function getDescriptionPosition(): string
{
return $this->evaluate($this->showDescriptionOnTop) ?? false;
return $this->evaluate($this->descriptionPosition) ?? 'below';
}
}

0 comments on commit 8f5e62e

Please sign in to comment.