← All changes
|
modules/atomic-widgets/styles/style-states.php
+3
-58
4.2.0-beta2
→
3.34.0-beta1
View file →
| @@ -5,70 +5,28 @@ | ||
| 5 | 5 | class Style_States { |
| 6 | 6 | const HOVER = 'hover'; |
| 7 | 7 | const ACTIVE = 'active'; |
| 8 | 8 | const FOCUS = 'focus'; |
| 9 | - const FOCUS_VISIBLE = 'focus-visible'; | |
| 10 | - const CHECKED = 'checked'; | |
| 11 | 9 | |
| 12 | 10 | const SELECTED = 'e--selected'; |
| 13 | - const DISABLED = 'e--disabled'; | |
| 14 | 11 | |
| 15 | - private static function get_pseudo_states(): array { | |
| 12 | + public static function get_pseudo_states(): array { | |
| 16 | 13 | return [ |
| 17 | 14 | self::HOVER, |
| 18 | 15 | self::ACTIVE, |
| 19 | 16 | self::FOCUS, |
| 20 | - self::FOCUS_VISIBLE, | |
| 21 | - self::CHECKED, | |
| 22 | 17 | ]; |
| 23 | 18 | } |
| 24 | 19 | |
| 25 | - private static function get_class_states(): array { | |
| 20 | + public static function get_class_states(): array { | |
| 26 | 21 | return [ |
| 27 | 22 | self::SELECTED, |
| 28 | - self::DISABLED, | |
| 29 | 23 | ]; |
| 30 | 24 | } |
| 31 | 25 | |
| 32 | - private static function get_additional_states_map(): array { | |
| 33 | - return [ | |
| 34 | - self::HOVER => [ self::FOCUS_VISIBLE ], | |
| 35 | - ]; | |
| 36 | - } | |
| 37 | - | |
| 38 | - public static function get_selector_with_state( string $base_selector, string $state ): string { | |
| 39 | - $additional_states = self::get_additional_states( $state ); | |
| 40 | - $all_states = [ $state, ...$additional_states ]; | |
| 41 | - | |
| 42 | - foreach ( $all_states as $current_state ) { | |
| 43 | - $selector_strings[] = $base_selector . self::get_state_selector( $current_state ); | |
| 44 | - } | |
| 45 | - | |
| 46 | - return implode( ',', $selector_strings ); | |
| 47 | - } | |
| 48 | - | |
| 49 | - public static function get_additional_states( string $state ): array { | |
| 50 | - return self::get_additional_states_map()[ $state ] ?? []; | |
| 51 | - } | |
| 52 | - | |
| 53 | - public static function get_state_selector( string $state ): string { | |
| 54 | - if ( self::is_class_state( $state ) ) { | |
| 55 | - return '.' . $state; | |
| 56 | - } | |
| 57 | - | |
| 58 | - if ( self::is_pseudo_state( $state ) ) { | |
| 59 | - return ':' . $state; | |
| 60 | - } | |
| 61 | - | |
| 62 | - return $state; | |
| 63 | - } | |
| 64 | - | |
| 65 | - | |
| 66 | 26 | public static function get_valid_states(): array { |
| 67 | 27 | return [ |
| 68 | - ...array_filter( self::get_pseudo_states(), function ( $state ) { | |
| 69 | - return ! in_array( $state, self::get_additional_states_map()[ $state ] ?? [], true ); | |
| 70 | - } ), | |
| 28 | + ...self::get_pseudo_states(), | |
| 71 | 29 | ...self::get_class_states(), |
| 72 | 30 | null, |
| 73 | 31 | ]; |
| 74 | 32 | } |
| @@ -93,21 +51,8 @@ | ||
| 93 | 51 | return [ |
| 94 | 52 | 'selected' => [ |
| 95 | 53 | 'name' => 'selected', |
| 96 | 54 | 'value' => self::SELECTED, |
| 97 | - ], | |
| 98 | - 'disabled' => [ | |
| 99 | - 'name' => 'disabled', | |
| 100 | - 'value' => self::DISABLED, | |
| 101 | - ], | |
| 102 | - ]; | |
| 103 | - } | |
| 104 | - | |
| 105 | - public static function get_pseudo_states_map(): array { | |
| 106 | - return [ | |
| 107 | - 'checked' => [ | |
| 108 | - 'name' => 'checked', | |
| 109 | - 'value' => self::CHECKED, | |
| 110 | 55 | ], |
| 111 | 56 | ]; |
| 112 | 57 | } |
| 113 | 58 | } |