-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
157 additions
and
64 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
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; | ||
|
||
class Toggle implements HasColor, HasDefaultGrayColor | ||
{ | ||
/** | ||
* @param array<int, string> $color | ||
* @return array<string> | ||
*/ | ||
public function getColorClasses(array $color): array | ||
{ | ||
$gray = FilamentColor::getColor('gray'); | ||
|
||
ksort($color); | ||
|
||
/** | ||
* Since the toggle doesn't contain text, the icon may be imperative for the user to understand the | ||
* button's state. Therefore, the color should contrast at least 3:1 with the background to | ||
* remain compliant with WCAG AA standards. | ||
* | ||
* @ref https://www.w3.org/WAI/WCAG21/Understanding/non-bg-contrast.html | ||
*/ | ||
foreach (array_keys($color) as $shade) { | ||
if (Color::isNonTextContrastRatioAccessible('oklch(1 0 0)', $color[$shade])) { | ||
$text = $shade; | ||
|
||
break; | ||
} | ||
} | ||
|
||
$text ??= 900; | ||
|
||
/** | ||
* Since the toggle doesn't contain text, the color is imperative for the user to understand the | ||
* button's state. Therefore, the color should contrast at least 3:1 with the background to | ||
* remain compliant with WCAG AA standards. | ||
* | ||
* @ref https://www.w3.org/WAI/WCAG21/Understanding/non-bg-contrast.html | ||
*/ | ||
$darkestLightGrayBg = $gray[50]; | ||
|
||
foreach (array_keys($color) as $shade) { | ||
if (Color::isNonTextContrastRatioAccessible($darkestLightGrayBg, $color[$shade])) { | ||
$bg = $shade; | ||
|
||
break; | ||
} | ||
} | ||
|
||
$bg ??= 900; | ||
|
||
krsort($color); | ||
|
||
$lightestDarkGrayBg = $gray[700]; | ||
|
||
foreach (array_keys($color) as $shade) { | ||
if (Color::isNonTextContrastRatioAccessible($lightestDarkGrayBg, $color[$shade])) { | ||
$darkBg = $shade; | ||
|
||
break; | ||
} | ||
} | ||
|
||
$darkBg ??= 200; | ||
|
||
return [ | ||
"fi-bg-color-{$bg}", | ||
"fi-text-color-{$text}", | ||
"dark:fi-bg-color-{$darkBg}", | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
...__dropdown_item_icon______gray______Filament_Support_View_Compone___m_Icon____gray__.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
[ | ||
"fi-color", | ||
"fi-color-gray" | ||
] | ||
[] |
7 changes: 7 additions & 0 deletions
7
..._dataset__toggle______danger______Filament_Support_View_Compone___Toggle____danger__.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[ | ||
"fi-color", | ||
"fi-color-danger", | ||
"fi-bg-color-500", | ||
"fi-text-color-500", | ||
"dark:fi-bg-color-400" | ||
] |
1 change: 1 addition & 0 deletions
1
...set__dataset__toggle______gray______Filament_Support_View_Compone___Toggle____gray__.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
7 changes: 7 additions & 0 deletions
7
...set__dataset__toggle______info______Filament_Support_View_Compone___Toggle____info__.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[ | ||
"fi-color", | ||
"fi-color-info", | ||
"fi-bg-color-500", | ||
"fi-text-color-500", | ||
"dark:fi-bg-color-400" | ||
] |
7 changes: 7 additions & 0 deletions
7
...ataset__toggle______primary______Filament_Support_View_Compone___Toggle____primary__.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[ | ||
"fi-color", | ||
"fi-color-primary", | ||
"fi-bg-color-600", | ||
"fi-text-color-600", | ||
"dark:fi-bg-color-600" | ||
] |
7 changes: 7 additions & 0 deletions
7
...ataset__toggle______success______Filament_Support_View_Compone___Toggle____success__.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[ | ||
"fi-color", | ||
"fi-color-success", | ||
"fi-bg-color-600", | ||
"fi-text-color-600", | ||
"dark:fi-bg-color-600" | ||
] |
7 changes: 7 additions & 0 deletions
7
...ataset__toggle______warning______Filament_Support_View_Compone___Toggle____warning__.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[ | ||
"fi-color", | ||
"fi-color-warning", | ||
"fi-bg-color-600", | ||
"fi-text-color-600", | ||
"dark:fi-bg-color-600" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters