Skip to content

Commit

Permalink
Merge branch '3.x' into 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed May 9, 2024
2 parents b8b9f59 + 39b4651 commit d417871
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 7 deletions.
5 changes: 2 additions & 3 deletions packages/forms/resources/js/components/rich-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ Trix.config.textAttributes.underline = {

Trix.Block.prototype.breaksOnReturn = function () {
const lastAttribute = this.getLastAttribute()
const blockConfig = Trix.config.blockAttributes[
lastAttribute ? lastAttribute : 'default'
]
const blockConfig =
Trix.config.blockAttributes[lastAttribute ? lastAttribute : 'default']

return blockConfig?.breakOnReturn ?? false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ class="fi-fo-rich-editor fi-disabled prose block w-full max-w-none rounded-lg bg
@endif
{{ $getExtraAlpineAttributeBag() }}
>
<input id="trix-value-{{ $id }}" x-ref="trixValue" type="hidden" />
<input
id="trix-value-{{ $id }}"
x-ref="trixValue"
type="hidden"
/>

<trix-toolbar
id="trix-toolbar-{{ $id }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
:active="$activeTab === $tabKey"
:badge="$tab->getBadge()"
:badge-color="$tab->getBadgeColor()"
:badge-icon="$tab->getBadgeIcon()"
:badge-icon-position="$tab->getBadgeIconPosition()"
:icon="$tab->getIcon()"
:icon-position="$tab->getIconPosition()"
:wire:click="'$set(\'activeTab\', ' . (filled($tabKey) ? ('\'' . $tabKey . '\'') : 'null') . ')'"
Expand Down
2 changes: 2 additions & 0 deletions packages/schema/resources/views/components/tabs.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
:alpine-active="'tab === \'' . $tabKey . '\''"
:badge="$tab->getBadge()"
:badge-color="$tab->getBadgeColor()"
:badge-icon="$tab->getBadgeIcon()"
:badge-icon-position="$tab->getBadgeIconPosition()"
:icon="$tab->getIcon()"
:icon-position="$tab->getIconPosition()"
:x-on:click="'tab = \'' . $tabKey . '\''"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
'ring-1 ring-gray-950/10 dark:ring-white/20' => (($color === 'gray') || ($tag === 'label')) && (! $grouped),
'bg-custom-600 text-white hover:bg-custom-500 focus-visible:ring-custom-500/50 dark:bg-custom-500 dark:hover:bg-custom-400 dark:focus-visible:ring-custom-400/50' => ($color !== 'gray') && ($tag !== 'label'),
'[input:checked+&]:bg-custom-600 [input:checked+&]:text-white [input:checked+&]:ring-0 [input:checked+&]:hover:bg-custom-500 dark:[input:checked+&]:bg-custom-500 dark:[input:checked+&]:hover:bg-custom-400 [input:checked:focus-visible+&]:ring-custom-500/50 dark:[input:checked:focus-visible+&]:ring-custom-400/50 [input:focus-visible+&]:z-10 [input:focus-visible+&]:ring-2 [input:focus-visible+&]:ring-gray-950/10 dark:[input:focus-visible+&]:ring-white/20' => ($color !== 'gray') && ($tag === 'label'),
]
]
),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
'badge' => null,
'badgeColor' => null,
'badgeTooltip' => null,
'badgeIcon' => null,
'badgeIconPosition' => IconPosition::Before,
'href' => null,
'icon' => null,
'iconColor' => 'gray',
Expand Down Expand Up @@ -49,7 +51,7 @@
@endif
@if ($hasAlpineActiveClasses)
x-bind:class="{
@js($inactiveItemClasses): ! ({{ $alpineActive }}),
@js($inactiveItemClasses): ! {{ $alpineActive }},
@js($activeItemClasses): {{ $alpineActive }},
}"
@endif
Expand Down Expand Up @@ -81,7 +83,7 @@
<span
@if ($hasAlpineActiveClasses)
x-bind:class="{
@js($inactiveLabelClasses): ! ({{ $alpineActive }}),
@js($inactiveLabelClasses): ! {{ $alpineActive }},
@js($activeLabelClasses): {{ $alpineActive }},
}"
@endif
Expand Down Expand Up @@ -109,6 +111,8 @@
@if (filled($badge))
<x-filament::badge
:color="$badgeColor"
:icon="$badgeIcon"
:icon-position="$badgeIconPosition"
size="sm"
:tooltip="$badgeTooltip"
class="w-max"
Expand Down
29 changes: 29 additions & 0 deletions packages/support/src/Concerns/HasBadge.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Filament\Support\Concerns;

use Closure;
use Filament\Support\Enums\IconPosition;

trait HasBadge
{
Expand All @@ -13,6 +14,10 @@ trait HasBadge
*/
protected string | array | Closure | null $badgeColor = null;

protected string | Closure | null $badgeIcon = null;

protected IconPosition | string | Closure | null $badgeIconPosition = null;

public function badge(string | int | float | Closure | null $badge = null): static
{
if (func_num_args() === 0) {
Expand Down Expand Up @@ -43,6 +48,20 @@ public function badgeColor(string | array | Closure | null $color): static
return $this;
}

public function badgeIcon(string | Closure | null $icon): static
{
$this->badgeIcon = $icon;

return $this;
}

public function badgeIconPosition(IconPosition | string | Closure | null $position): static
{
$this->badgeIconPosition = $position;

return $this;
}

/**
* @deprecated Use `badgeColor()` instead.
*
Expand All @@ -65,4 +84,14 @@ public function getBadgeColor(): string | array | null
{
return $this->evaluate($this->badgeColor);
}

public function getBadgeIcon(): ?string
{
return $this->evaluate($this->badgeIcon);
}

public function getBadgeIconPosition(): IconPosition | string
{
return $this->evaluate($this->badgeIconPosition) ?? IconPosition::Before;
}
}

0 comments on commit d417871

Please sign in to comment.