Skip to content

Commit

Permalink
Merge pull request #15 from 199ocero/enhancement
Browse files Browse the repository at this point in the history
added heading visible and docu
  • Loading branch information
199ocero authored Jan 20, 2024
2 parents 14a3641 + 5cfa048 commit f34683f
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 30 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public function activityTimelineInfolist(Infolist $infolist): Infolist
->showItemsIcon('heroicon-m-chevron-down') // Show button icon
->showItemsColor('gray') // Show button color and it supports all colors
->aside(true)
->headingVisible(true) // make heading visible or not
->extraAttributes(['class'=>'my-new-class']) // add extra class
]);
}
```
Expand Down Expand Up @@ -241,6 +243,8 @@ class ViewOrderActivities extends ActivityTimelinePage
'empty_state_heading' => 'No activities yet', // heading for the empty state
'empty_state_description' => 'Check back later for activities that have been recorded.', // description for the empty state
'empty_state_icon' => 'heroicon-o-bolt-slash', // icon for the empty state
'heading_visible' => true, // show the heading
'extra_attributes' => [], // extra attributes
],
'activity_title' => [
'placeholder' => 'No title is set', // this will show when there is no title
Expand Down
56 changes: 28 additions & 28 deletions resources/views/components/section.blade.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
@props(['heading', 'description' => null, 'aside' => true, 'extraAttributes' => []])
@props(['heading', 'headingVisible' => true, 'description' => null, 'aside' => true, 'extraAttributes' => []])

<section
{{
$attributes
->merge($extraAttributes, escape: false)
->class([
'fi-timeline-section',
match (true) {
!$aside => 'bg-white shadow-sm rounded-xl ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10',
$aside => 'grid items-start grid-cols-1 gap-x-6 gap-y-4 md:grid-cols-3',
},
])
}}>
<header @class([
'fi-timeline-section-header',
'flex flex-col gap-3 px-6 py-4 overflow-hidden sm:flex-row sm:items-center' => !$aside,
'flex flex-col gap-3 overflow-hidden sm:flex-row sm:items-center' => $aside,
])>
<div class="grid flex-1 gap-y-1">
<h3
class="text-base font-semibold leading-6 fi-timeline-section-header-heading text-gray-950 dark:text-white">
{{ $heading }}
</h3>
<p class="text-sm text-gray-500 fi-timeline-section-header-description dark:text-gray-400">
{{ $description }}
</p>
</div>
</header>
{{ $attributes->merge($extraAttributes, escape: false)->class([
'fi-timeline-section',
'grid items-start grid-cols-1 gap-x-6 gap-y-4 md:grid-cols-3' => $aside && $headingVisible,
'bg-white shadow-sm rounded-xl ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10' => !$aside,
]) }}>

@if ($headingVisible)
<header @class([
'fi-timeline-section-header',
'flex flex-col gap-3 px-6 py-4 overflow-hidden sm:flex-row sm:items-center' => !$aside,
'flex flex-col gap-3 overflow-hidden sm:flex-row sm:items-center' => $aside,
])>
<div class="grid flex-1 gap-y-1">
<h3
class="text-base font-semibold leading-6 fi-timeline-section-header-heading text-gray-950 dark:text-white">
{{ $heading }}
</h3>
<p class="text-sm text-gray-500 fi-timeline-section-header-description dark:text-gray-400">
{{ $description }}
</p>
</div>
</header>
@endif

@if ($aside)
<div
class="p-6 bg-white shadow-sm fi-timeline-section-content md:col-span-2 rounded-xl ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10">
{{ $slot }}
</div>
@else
<div class="p-6 border-t border-gray-200 fi-timeline-section-content dark:border-white/10">
<div @class([
'p-6 fi-timeline-section-content',
'border-t border-gray-200 dark:border-white/10' => $headingVisible,
])>
{{ $slot }}
</div>
@endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<x-activity-timeline::section :aside="$isAside()" :extraAttributes="$getExtraAttributes()">
<x-activity-timeline::section :aside="$isAside()" :extraAttributes="$getExtraAttributes()" :headingVisible="$isHeadingVisible()">
<x-slot name="heading">
{{ $getLabel() ?? $getHeading() }}
</x-slot>
Expand Down
14 changes: 14 additions & 0 deletions src/Components/ActivitySection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class ActivitySection extends Entry

protected bool|Closure|null $isAside = null;

protected bool|Closure|null $isHeadingVisible = null;

public function description(string|Closure|null $description = null): static
{
$this->description = $description;
Expand Down Expand Up @@ -68,6 +70,13 @@ public function showItemsColor(string|Closure $color): static
return $this;
}

public function headingVisible(bool|Closure|null $condition = true): static
{
$this->isHeadingVisible = $condition;

return $this;
}

public function isAside(): bool
{
return (bool) ($this->evaluate($this->isAside) ?? false);
Expand Down Expand Up @@ -104,6 +113,11 @@ public function getShowItemsColor(): string
return $this->evaluate($this->showItemsColor) ?? 'gray';
}

public function isHeadingVisible(): bool
{
return (bool) ($this->evaluate($this->isHeadingVisible) ?? true);
}

/**
* @return array<ComponentContainer>
*/
Expand Down
6 changes: 5 additions & 1 deletion src/Concerns/HasSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ protected function configuration(): array
'empty_state_heading' => 'No activities yet',
'empty_state_description' => 'Check back later for activities that have been recorded.',
'empty_state_icon' => 'heroicon-o-bolt-slash',
'heading_visible' => true,
'extra_attributes' => [],
],
'activity_title' => [
'placeholder' => 'No title is set',
Expand Down Expand Up @@ -97,7 +99,9 @@ public function activityInfolist(Infolist $infolist): Infolist
->aside($this->configuration()['activity_section']['aside'])
->emptyStateHeading($this->configuration()['activity_section']['empty_state_heading'])
->emptyStateDescription($this->configuration()['activity_section']['empty_state_description'])
->emptyStateIcon($this->configuration()['activity_section']['empty_state_icon']),
->emptyStateIcon($this->configuration()['activity_section']['empty_state_icon'])
->headingVisible($this->configuration()['activity_section']['heading_visible'])
->extraAttributes($this->configuration()['activity_section']['extra_attributes']),
])
->columns(1);
}
Expand Down

0 comments on commit f34683f

Please sign in to comment.