Skip to content

Commit

Permalink
add the icons parameter to the menu captionedGroup function
Browse files Browse the repository at this point in the history
  • Loading branch information
charbelrami committed Dec 5, 2024
1 parent 1f495d6 commit 4fd711f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 25 deletions.
5 changes: 3 additions & 2 deletions component-catalog/src/Examples/Menu.elm
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ import Nri.Ui.Colors.V1 as Colors
import Nri.Ui.Fonts.V1 as Fonts
import Nri.Ui.Heading.V3 as Heading
import Nri.Ui.Html.Attributes.V2 exposing (safeIdWithPrefix)
import Nri.Ui.Menu.V4 as Menu
import Nri.Ui.Menu.V5 as Menu
import Nri.Ui.RadioButton.V4 as RadioButton
import Nri.Ui.Spacing.V1 as Spacing
import Nri.Ui.Svg.V1 as Svg
import Nri.Ui.Switch.V3 as Switch
import Nri.Ui.Table.V8 as Table
import Nri.Ui.Text.V6 as Text
Expand Down Expand Up @@ -842,7 +843,7 @@ In this realistic example, we can't actually pass the correct attributes to Radi
]
, Menu.captionedGroup "Guided Draft"
"Students draft with the support of tutorials, models, and targeted tips."
[ span [] [text "icon"], span [] [text "icon"] ]
[ UiIcon.home |> Svg.withWidth (Css.px 24) |> Svg.toHtml ]
[ Menu.entry "preview-guided-draft" <|
\attributes ->
ClickableSvg.link "Preview"
Expand Down
2 changes: 1 addition & 1 deletion elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"Nri.Ui.Mark.V6",
"Nri.Ui.MasteryIcon.V1",
"Nri.Ui.MediaQuery.V1",
"Nri.Ui.Menu.V4",
"Nri.Ui.Menu.V5",
"Nri.Ui.Message.V4",
"Nri.Ui.Modal.V12",
"Nri.Ui.Outline.V1",
Expand Down
23 changes: 4 additions & 19 deletions src/Nri/Ui/Menu/V4.elm → src/Nri/Ui/Menu/V5.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Nri.Ui.Menu.V4 exposing
module Nri.Ui.Menu.V5 exposing
( view, Attribute
, isOpen, isDisabled
, opensOnHover
Expand All @@ -12,24 +12,9 @@ module Nri.Ui.Menu.V4 exposing
, Entry, group, captionedGroup, entry
)

{-| Patch changes:
{-| Changes from V4:
- improve interoperability with Tooltip (Note that tooltip keyboard events are not fully supported!)
- Use Nri.Ui.WhenFocusLeaves.V2
- Adjust disabled styles
- when the Menu is a dialog or disclosure, _don't_ add role menuitem to the entries
- Use ClickableText.medium as the default size when the trigger is `Menu.clickableText`
- Adds containerCss, menuCss, groupContainerCss, and entryContainerCss to customize the style of the respective containers
- Adds captionedGroup to create a group with a caption
- Adds groupTitleCss and groupCaptionCss to customize the style of the group title and caption
Changes from V3:
- improve composability with Button, ClickableText, and ClickableSvg
A togglable menu view and related buttons.
<https://zpl.io/a75OrE2>
- add the icons parameter to the menu captionedGroup function
## Menu rendering
Expand Down Expand Up @@ -846,7 +831,7 @@ viewEntry config focusAndToggle { upId, downId, entry_ } =
(styleGroupTitleText config
|> Maybe.cons (Maybe.map (always (Aria.describedBy [ captionId ])) caption)
)
[ Html.text title, span [ css [ marginLeft (Css.px 5), display inlineFlex, Css.property "gap" "5px" ] ] icons ]
[ Html.text title, span [ css [ marginLeft (Css.px 5), display inlineFlex, Css.property "gap" "5px", verticalAlign bottom ] ] icons ]
]
, viewJust
(\c ->
Expand Down
4 changes: 2 additions & 2 deletions tests/Spec/Nri/Ui/Menu.elm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Html.Styled as HtmlStyled
import Json.Encode as Encode
import Nri.Test.KeyboardHelpers.V1 as KeyboardHelpers
import Nri.Ui.ClickableText.V4 as ClickableText
import Nri.Ui.Menu.V4 as Menu
import Nri.Ui.Menu.V5 as Menu
import Nri.Ui.Tooltip.V3 as Tooltip
import ProgramTest exposing (ProgramTest, ensureViewHas, ensureViewHasNot)
import Spec.Helpers exposing (nriDescription)
Expand All @@ -17,7 +17,7 @@ import Test.Html.Selector as Selector exposing (text)

spec : Test
spec =
describe "Nri.Ui.Menu.V4"
describe "Nri.Ui.Menu.V5"
[ test "Opens when mouse enters" <|
\() ->
program [ Menu.opensOnHover True ]
Expand Down
2 changes: 1 addition & 1 deletion tests/elm-verify-examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"Nri.Ui.Mark.V6",
"Nri.Ui.MasteryIcon.V1",
"Nri.Ui.MediaQuery.V1",
"Nri.Ui.Menu.V4",
"Nri.Ui.Menu.V5",
"Nri.Ui.Message.V4",
"Nri.Ui.Modal.V12",
"Nri.Ui.Outline.V1",
Expand Down

0 comments on commit 4fd711f

Please sign in to comment.