Skip to content

Commit

Permalink
Hiding Column Labels
Browse files Browse the repository at this point in the history
  • Loading branch information
lrljoe authored Oct 17, 2023
1 parent ac21555 commit a814b84
Showing 2 changed files with 49 additions and 46 deletions.
94 changes: 49 additions & 45 deletions resources/views/components/table/th.blade.php
Original file line number Diff line number Diff line change
@@ -18,32 +18,34 @@
->except('default')
}}
>
@unless ($component->sortingIsEnabled() && ($column->isSortable() || $column->getSortCallback()))
{{ $column->getTitle() }}
@else
<button
wire:click="sortBy('{{ ($column->isSortable() ? $column->getColumnSelectName() : $column->getSlug()) }}')"
{{
$attributes->merge($customSortButtonAttributes)
->class(['flex items-center space-x-1 text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider group focus:outline-none dark:text-gray-400' => $customSortButtonAttributes['default'] ?? true])
->except(['default', 'wire:key'])
}}
>
<span>{{ $column->getTitle() }}</span>
@if(!$column->isLabelHidden())
@unless (($component->sortingIsEnabled() && ($column->isSortable() || $column->getSortCallback())))
{{ $column->getTitle() }}
@else
<button
wire:click="sortBy('{{ ($column->isSortable() ? $column->getColumnSelectName() : $column->getSlug()) }}')"
{{
$attributes->merge($customSortButtonAttributes)
->class(['flex items-center space-x-1 text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider group focus:outline-none dark:text-gray-400' => $customSortButtonAttributes['default'] ?? true])
->except(['default', 'wire:key'])
}}
>
<span>{{ $column->getTitle() }}</span>

<span class="relative flex items-center">
@if ($direction === 'asc')
<x-heroicon-o-chevron-up class="w-3 h-3 group-hover:opacity-0" />
<x-heroicon-o-chevron-down class="w-3 h-3 opacity-0 group-hover:opacity-100 absolute"/>
@elseif ($direction === 'desc')
<x-heroicon-o-chevron-down class="w-3 h-3 group-hover:opacity-0" />
<x-heroicon-o-x-circle class="w-3 h-3 opacity-0 group-hover:opacity-100 absolute"/>
@else
<x-heroicon-o-chevron-up class="w-3 h-3 opacity-0 group-hover:opacity-100 transition-opacity duration-300" />
@endif
</span>
</button>
@endunless
<span class="relative flex items-center">
@if ($direction === 'asc')
<x-heroicon-o-chevron-up class="w-3 h-3 group-hover:opacity-0" />
<x-heroicon-o-chevron-down class="w-3 h-3 opacity-0 group-hover:opacity-100 absolute"/>
@elseif ($direction === 'desc')
<x-heroicon-o-chevron-down class="w-3 h-3 group-hover:opacity-0" />
<x-heroicon-o-x-circle class="w-3 h-3 opacity-0 group-hover:opacity-100 absolute"/>
@else
<x-heroicon-o-chevron-up class="w-3 h-3 opacity-0 group-hover:opacity-100 transition-opacity duration-300" />
@endif
</span>
</button>
@endunless
@endif
</th>
@elseif ($component->isBootstrap())
<th scope="col" {{
@@ -55,26 +57,28 @@
->except('default')
}}
>
@unless ($component->sortingIsEnabled() && ($column->isSortable() || $column->getSortCallback()))
{{ $column->getTitle() }}
@else
<div
class="d-flex align-items-center"
wire:click="sortBy('{{ ($column->isSortable() ? $column->getColumnSelectName() : $column->getSlug()) }}')"
style="cursor:pointer;"
>
<span>{{ $column->getTitle() }}</span>
@if(!$column->isLabelHidden())
@unless ($component->sortingIsEnabled() && ($column->isSortable() || $column->getSortCallback()))
{{ $column->getTitle() }}
@else
<div
class="d-flex align-items-center"
wire:click="sortBy('{{ ($column->isSortable() ? $column->getColumnSelectName() : $column->getSlug()) }}')"
style="cursor:pointer;"
>
<span>{{ $column->getTitle() }}</span>

<span class="relative d-flex align-items-center">
@if ($direction === 'asc')
<x-heroicon-o-chevron-up class="ml-1" style="width:1em;height:1em;" />
@elseif ($direction === 'desc')
<x-heroicon-o-chevron-down class="ml-1" style="width:1em;height:1em;" />
@else
<x-heroicon-o-chevron-up-down class="ml-1" style="width:1em;height:1em;" />
@endif
</span>
</div>
@endunless
<span class="relative d-flex align-items-center">
@if ($direction === 'asc')
<x-heroicon-o-chevron-up class="ml-1" style="width:1em;height:1em;" />
@elseif ($direction === 'desc')
<x-heroicon-o-chevron-down class="ml-1" style="width:1em;height:1em;" />
@else
<x-heroicon-o-chevron-up-down class="ml-1" style="width:1em;height:1em;" />
@endif
</span>
</div>
@endunless
@endif
</th>
@endif
1 change: 0 additions & 1 deletion resources/views/datatable.blade.php
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@

@foreach($columns as $index => $column)
@continue($column->isHidden())
@continue($column->isLabelHidden())
@continue($this->columnSelectIsEnabled() && ! $this->columnSelectIsEnabledForColumn($column))
@continue($column->isReorderColumn() && !$this->getCurrentlyReorderingStatus() && $this->getHideReorderColumnUnlessReorderingStatus())

0 comments on commit a814b84

Please sign in to comment.