Skip to content

Commit

Permalink
added heading visible and docu
Browse files Browse the repository at this point in the history
  • Loading branch information
199ocero committed Jan 20, 2024
1 parent 14a3641 commit dc4ba58
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 33 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
16 changes: 15 additions & 1 deletion 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,12 +113,17 @@ public function getShowItemsColor(): string
return $this->evaluate($this->showItemsColor) ?? 'gray';
}

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

/**
* @return array<ComponentContainer>
*/
public function getChildComponentContainers(bool $withHidden = false): array
{
if ((! $withHidden) && $this->isHidden()) {
if ((!$withHidden) && $this->isHidden()) {
return [];
}

Expand Down
10 changes: 7 additions & 3 deletions 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 Expand Up @@ -152,7 +156,7 @@ private function modifiedState(): array

$properties = $state['properties'];

if (! empty($properties) && isset($properties['old']) && isset($properties['attributes'])) {
if (!empty($properties) && isset($properties['old']) && isset($properties['attributes'])) {

$oldValues = $properties['old'];
$newValues = $properties['attributes'];
Expand All @@ -161,7 +165,7 @@ private function modifiedState(): array

foreach ($newValues as $key => $newValue) {
if (isset($oldValues[$key]) && $oldValues[$key] != $newValue) {
$changes[] = "- {$key} from <strong>".htmlspecialchars($oldValues[$key]).'</strong> to <strong>'.htmlspecialchars($newValue).'</strong>';
$changes[] = "- {$key} from <strong>" . htmlspecialchars($oldValues[$key]) . '</strong> to <strong>' . htmlspecialchars($newValue) . '</strong>';
}
}

Expand Down

0 comments on commit dc4ba58

Please sign in to comment.