Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The priority of pseudo-classes is set. #352 #353

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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