Skip to content

Commit

Permalink
Refactor button colors
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Jan 26, 2025
1 parent 602a5bc commit c959723
Show file tree
Hide file tree
Showing 19 changed files with 873 additions and 100 deletions.
2 changes: 1 addition & 1 deletion docs-assets/app/public/css/filament/filament/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs-assets/app/public/css/filament/forms/forms.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs-assets/app/public/css/filament/support/support.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/forms/dist/index.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/panels/dist/theme.css

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/panels/src/AvatarProviders/UiAvatarsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Filament\AvatarProviders;

use Filament\Facades\Filament;
use Filament\Support\Colors\Color;
use Filament\Support\Facades\FilamentColor;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
Expand All @@ -17,6 +18,6 @@ public function get(Model | Authenticatable $record): string
->map(fn (string $segment): string => filled($segment) ? mb_substr($segment, 0, 1) : '')
->join(' ');

return 'https://ui-avatars.com/api/?name=' . urlencode($name) . '&color=FFFFFF&background=' . FilamentColor::getColors()['gray'][950];
return 'https://ui-avatars.com/api/?name=' . urlencode($name) . '&color=FFFFFF&background=' . FilamentColor::getColor('gray')[950] ?? Color::Gray[950];

Check failure on line 21 in packages/panels/src/AvatarProviders/UiAvatarsProvider.php

View workflow job for this annotation

GitHub Actions / P8.3 - L11.* - prefer-stable

Expression on left side of ?? is not nullable.

Check failure on line 21 in packages/panels/src/AvatarProviders/UiAvatarsProvider.php

View workflow job for this annotation

GitHub Actions / P8.2 - L11.* - prefer-stable

Expression on left side of ?? is not nullable.
}
}
2 changes: 1 addition & 1 deletion packages/support/dist/index.css

Large diffs are not rendered by default.

30 changes: 21 additions & 9 deletions packages/support/resources/css/components/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
}

&.fi-color {
@apply text-color-600 ring-color-600 dark:text-color-400 dark:ring-color-500;
@apply text-(--color-gray-100-text) ring-color-600 dark:text-(--color-gray-700-text) dark:ring-color-500;

&:not(.fi-disabled):not([disabled]) {
@apply hover:bg-color-400/10;
@apply hover:bg-(--hover-bg)/10 dark:hover:bg-(--dark-hover-bg)/10;
}

& > .fi-icon {
Expand All @@ -69,20 +69,20 @@
@apply hover:bg-gray-50 dark:hover:bg-white/10;
}

&label {
@apply [input:checked+&]:bg-gray-400 [input:checked+&]:text-white [input:checked+&]:ring-0 dark:[input:checked+&]:bg-gray-600;
input:checked + &label {
@apply bg-gray-400 text-white ring-0 dark:bg-gray-600;

&:not(.fi-disabled):not([disabled]) {
@apply [input:checked+&]:hover:bg-gray-300 dark:[input:checked+&]:hover:bg-gray-500;
@apply hover:bg-gray-300 dark:hover:bg-gray-500;
}
}

&.fi-color {
&:not(label) {
@apply bg-color-600 dark:bg-color-500 text-white;
@apply bg-(--bg) dark:bg-(--dark-bg) text-(--text) dark:text-(--dark-text);

&:not(.fi-disabled):not([disabled]) {
@apply hover:bg-color-500 focus-visible:ring-color-500/50 dark:hover:bg-color-400 dark:focus-visible:ring-color-400/50;
@apply hover:bg-(--hover-bg) hover:text-(--hover-text) focus-visible:ring-color-500/50 dark:hover:bg-(--dark-hover-bg) dark:hover:text-(--dark-hover-text) dark:focus-visible:ring-color-400/50;
}

& > .fi-icon {
Expand All @@ -91,10 +91,22 @@
}

&label {
@apply [input:checked+&]:bg-color-600 dark:[input:checked+&]:bg-color-500 [input:checked+&]:text-white [input:checked+&]:ring-0;
input:checked + & {
@apply bg-(--bg) dark:bg-(--dark-bg) text-(--text) dark:text-(--dark-text) ring-0;
}

&:not(.fi-disabled):not([disabled]) {
@apply [input:checked+&]:hover:bg-color-500 dark:[input:checked+&]:hover:bg-color-400 [input:checked:focus-visible+&]:ring-color-500/50 dark:[input:checked:focus-visible+&]:ring-color-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;
input:checked + & {
@apply hover:bg-(--hover-bg) dark:hover:bg-(--dark-hover-bg) hover:text-(--hover-text) dark:hover:text-(--dark-hover-text);
}

input:focus-visible + & {
@apply z-10 ring-2 ring-gray-950/10 dark:ring-white/20;
}

input:checked:focus-visible + & {
@apply ring-color-500/50 dark:ring-color-400/50;
}
}
}
}
Expand Down
Loading

0 comments on commit c959723

Please sign in to comment.