Skip to content

Commit

Permalink
The priority of pseudo-classes is set. mdgriffith#352
Browse files Browse the repository at this point in the history
  • Loading branch information
XOMAv2 committed Jul 13, 2023
1 parent acae885 commit 347f80e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
31 changes: 31 additions & 0 deletions examples/Pseudo.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module Pseudo exposing (..)

import Element exposing (..)
import Element.Background as Background
import Element.Font as Font


main =
Element.layout
[ Background.color (rgba 0 0 0 1)
, Font.color (rgba 1 1 1 1)
, Font.italic
, Font.size 32
, Font.family
[ Font.sansSerif ]
]
<|
column [ centerX, centerY ]
[ el
[ mouseOver [ Background.color <| rgb255 255 0 0 ]
, mouseDown [ Background.color <| rgb255 0 0 255 ]
]
<|
text "The following priority of pseudo classes is fixed"
, el
[ mouseDown [ Background.color <| rgb255 0 0 255 ]
, mouseOver [ Background.color <| rgb255 255 0 0 ]
]
<|
text "hover < focused < active"
]
16 changes: 15 additions & 1 deletion src/Internal/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2622,7 +2622,21 @@ toStyleSheetString options stylesheet =
in
case List.foldl combine { topLevel = [], rules = [] } stylesheet of
{ topLevel, rules } ->
renderTopLevelValues topLevel ++ String.concat rules
let
ruleWeight s =
if String.contains ":hover" s then
1

else if String.contains ":focus" s then
2

else if String.contains ":active" s then
3

else
0
in
renderTopLevelValues topLevel ++ String.concat (List.sortBy ruleWeight rules)


renderStyle : OptionRecord -> Maybe PseudoClass -> String -> List Property -> List String
Expand Down

0 comments on commit 347f80e

Please sign in to comment.