Skip to content

Commit

Permalink
Link color
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Jan 30, 2025
1 parent 5d892c7 commit b491a15
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs-assets/app/public/css/filament/filament/app.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs-assets/app/public/css/filament/forms/forms.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs-assets/app/public/css/filament/support/support.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/forms/dist/index.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/panels/dist/theme.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/support/dist/index.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/support/resources/css/components/link.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
}

&.fi-color {
@apply text-color-600 dark:text-color-400;
@apply text-(--text) dark:text-(--dark-text);

& > .fi-icon {
@apply text-color-600 dark:text-color-400;
Expand Down
41 changes: 40 additions & 1 deletion packages/support/src/View/Components/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Filament\Support\View\Components;

use Filament\Support\Colors\Color;
use Filament\Support\Facades\FilamentColor;
use Filament\Support\View\Components\Contracts\HasColor;
use Filament\Support\View\Components\Contracts\HasDefaultGrayColor;

Expand All @@ -13,6 +15,43 @@ class Link implements HasColor, HasDefaultGrayColor
*/
public function getColorClasses(array $color): array
{
return [];
$gray = FilamentColor::getColor('gray');

ksort($color);

$darkestLightGrayBg = $gray[50];

foreach ($color as $shade => $shadeValue) {
if (Color::isTextContrastRatioAccessible($darkestLightGrayBg, $shadeValue)) {
$text = $shade;

break;
}
}

$text ??= 900;

krsort($color);

$lightestDarkGrayBg = $gray[700];

foreach ($color as $shade => $shadeValue) {
if ($shade > 400) {
continue;
}

if (Color::isTextContrastRatioAccessible($lightestDarkGrayBg, $shadeValue)) {
$darkText = $shade;

break;
}
}

$darkText ??= 200;

return [
"fi-text-color-{$text}",
"dark:fi-text-color-{$darkText}",
];
}
}

0 comments on commit b491a15

Please sign in to comment.