Skip to content

Commit

Permalink
feat: rulers
Browse files Browse the repository at this point in the history
  • Loading branch information
saade committed Feb 13, 2024
1 parent a9e8a8f commit 5932e2d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion resources/dist/filament-adjacency-list.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions resources/views/builder.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ class="filament-navigation"
@php
$treeId = $getId();
$hasRulers = $hasRulers();
$isAddable = $isAddable();
$isDeletable = $isDeletable();
$isDisabled = $isDisabled();
$isEditable = $isEditable();
$isReorderable = $isReorderable();
$isCollapsible = $isCollapsible();
$isCollapsed = $isCollapsed();
$maxDepth = $getMaxDepth();
$addAction = $getAction('add');
Expand Down Expand Up @@ -48,6 +50,7 @@ class="filament-navigation"
:deletable="$isDeletable"
:disabled="$isDisabled"
:editable="$isEditable"
:has-rulers="$hasRulers"
:is-collapsed="$isCollapsed"
:is-collapsible="$isCollapsible"
:item="$item"
Expand Down
9 changes: 7 additions & 2 deletions resources/views/components/item.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@props(['uuid', 'treeId', 'actions', 'addable', 'childrenKey', 'isCollapsible', 'isCollapsed', 'deletable', 'disabled', 'editable', 'item', 'itemStatePath', 'labelKey', 'reorderable', 'statePath'])
@props(['uuid', 'treeId', 'actions', 'addable', 'childrenKey', 'hasRulers', 'isCollapsible', 'isCollapsed', 'deletable', 'disabled', 'editable', 'item', 'itemStatePath', 'labelKey', 'reorderable', 'statePath'])

<div
{{-- hover:bg-gray-950/5 --}}
Expand Down Expand Up @@ -74,7 +74,11 @@ class="px-2 text-gray-500 appearance-none"
</div>

<div
@class(['ms-6', 'pt-2' => $hasChildren])
@class([
'ms-6' => !$hasRulers,
'ms-5 border-l border-l-gray-100 ps-4' => $hasRulers,
'pt-2' => $hasChildren,
])
x-show="! isCollapsed"
x-collapse
>
Expand All @@ -97,6 +101,7 @@ class="px-2 text-gray-500 appearance-none"
:deletable="$deletable"
:disabled="$disabled"
:editable="$editable"
:has-rulers="$hasRulers"
:is-collapsed="$isCollapsed"
:is-collapsible="$isCollapsible"
:item="$child"
Expand Down
14 changes: 13 additions & 1 deletion src/Forms/Components/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ abstract class Component extends Forms\Components\Field

protected int $maxDepth = -1;

protected bool $startCollapsed = false;
protected bool | Closure $hasRulers = false;

protected function setUp(): void
{
Expand Down Expand Up @@ -111,6 +111,18 @@ public function getMaxDepth(): int
return $this->evaluate($this->maxDepth);
}

public function rulers(bool | Closure $condition = true): static
{
$this->hasRulers = $condition;

return $this;
}

public function hasRulers(): bool
{
return $this->evaluate($this->hasRulers);
}

public function getRelativeStatePath(string $path): string
{
return str($path)->after($this->getStatePath())->trim('.')->toString();
Expand Down

0 comments on commit 5932e2d

Please sign in to comment.