-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
So that we can have a more flexible way to render menu items, e.g. with an automatic h2 title for the menu item.
- Loading branch information
1 parent
1245600
commit a786bc6
Showing
5 changed files
with
269 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
require "debug" | ||
|
||
module PhlexyUI | ||
# @private | ||
class MenuItem < Base | ||
def view_template(&) | ||
generate_classes!( | ||
modifiers_map: MENU_ITEM_MODIFIERS_MAP, | ||
base_modifiers:, | ||
options: | ||
).then do |classes| | ||
li(class: classes, &) | ||
end | ||
end | ||
|
||
def title(*, **options, &block) | ||
generate_classes!( | ||
component_html_class: :"menu-title", | ||
options: | ||
).then do |classes| | ||
h2(class: classes, **options, &block) | ||
end | ||
end | ||
|
||
def submenu(*base_modifiers, **, &) | ||
if base_modifiers.include?(:collapsible) | ||
render CollapsibleSubMenu.new(*base_modifiers, **, &) | ||
else | ||
render SubMenu.new(*base_modifiers, **, &) | ||
end | ||
end | ||
|
||
private | ||
|
||
MENU_ITEM_MODIFIERS_MAP = { | ||
# "sm:disabled" | ||
# "md:disabled" | ||
# "lg:disabled" | ||
disabled: "disabled", | ||
# "sm:active" | ||
# "md:active" | ||
# "lg:active" | ||
active: "active", | ||
# "sm:focus" | ||
# "md:focus" | ||
# "lg:focus" | ||
focus: "focus" | ||
}.freeze | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.