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