Skip to content

Commit

Permalink
refactor(primer-miso): Use IDs instead of unique classes
Browse files Browse the repository at this point in the history
This makes no functional difference, but is good practice due to indicating the semantics as well as providing a theoretical performance improvement.

Signed-off-by: George Thomas <georgefsthomas@gmail.com>
  • Loading branch information
georgefst committed Jan 9, 2025
1 parent c28342f commit a5a6d45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions primer-miso/frontend/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ body {
height: 100vh;
}

.miso-root {
#miso-root {
height: 100%;
display: grid;
grid-template-columns: 12rem 1fr 2fr;
Expand All @@ -81,7 +81,7 @@ body {
}
}

.def-panel {
#def-panel {
grid-row-start: 1;
grid-row-end: 3;
background-color: var(--grey-primary);
Expand All @@ -103,7 +103,7 @@ body {
}
}

.selection-type {
#selection-type {
grid-column-start: 2;
grid-column-end: 4;
}
Expand Down
11 changes: 6 additions & 5 deletions primer-miso/src/Primer/Miso.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import Miso (
defaultEvents,
div_,
fromTransition,
id_,
img_,
onClick,
src_,
Expand Down Expand Up @@ -174,9 +175,9 @@ updateModel =
viewModel :: Model -> View Action
viewModel Model{..} =
div_
[class_ "miso-root"]
[id_ "miso-root"]
$ [ div_
[class_ "def-panel"]
[id_ "def-panel"]
$ Map.keys module_.defs <&> \(qualifyName module_.name -> def) ->
button_
[ class_ $ mwhen (Just def == ((.def) <$> selection)) "selected"
Expand All @@ -188,19 +189,19 @@ viewModel Model{..} =
Nothing -> [text "no selection"]
Just defSel ->
[ div_
[ class_ "sig"
[ id_ "sig"
]
[ SelectNode . NodeSelection SigNode
<$> fst (viewTree (viewTreeType (Just . Right &&& isSelected) def.sig))
]
, div_
[ class_ "body"
[ id_ "body"
]
[ SelectNode . NodeSelection BodyNode
<$> fst (viewTree (viewTreeExpr (Just &&& isSelected) def.expr))
]
, div_
[ class_ "selection-type"
[ id_ "selection-type"
]
[ fst $ viewTree case defSel.node of
Nothing -> viewTreeType mkMeta $ forgetTypeMetadata def.sig
Expand Down

0 comments on commit a5a6d45

Please sign in to comment.