Skip to content

Commit

Permalink
⚡ splited active and hover item background color to menu and submenu
Browse files Browse the repository at this point in the history
Signed-off-by: Enigma228322 <safin@it-projects.info>
  • Loading branch information
Enigma228322 committed Nov 3, 2020
1 parent faa37dd commit ac9ff26
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 24 deletions.
67 changes: 43 additions & 24 deletions theme_kit/models/theme.py
Expand Up @@ -104,6 +104,14 @@ class ThemeTopPanel(models.Model):
default=False, help="Active item Background color for Top Panel"
)

top_panel_active_subitem_bg = fields.Char(
"Active submenu item Background color",
help="Active item Background color for Top Panel",
)
top_panel_active_subitem_bg_active = fields.Boolean(
default=False, help="Active submenu item Background color for Top Panel"
)

top_panel_hover_item_font = fields.Char(
"Hover item Font color", help="Hover item Font color for Top Panel"
)
Expand All @@ -117,6 +125,12 @@ class ThemeTopPanel(models.Model):
top_panel_hover_item_bg_active = fields.Boolean(
default=False, help="Hover item Background color for Top Panel"
)
top_panel_hover_subitem_bg = fields.Char(
"Hover submenu item Background color", help="Hover item Background color for Top Panel"
)
top_panel_hover_subitem_bg_active = fields.Boolean(
default=False, help="Hover submenu item Background color for Top Panel"
)

# Compatibility theme_kit and material backend theme modules
left_panel_main_menu = fields.Char(
Expand Down Expand Up @@ -163,10 +177,14 @@ def write(self, vals):
self.top_panel_hover_item_font = ""
if not vals.get("top_panel_hover_item_bg_active", "Not found"):
self.top_panel_hover_item_bg = ""
if not vals.get("top_panel_hover_subitem_bg_active", "Not found"):
self.top_panel_hover_subitem_bg = ""
if not vals.get("left_panel_main_menu_active", "Not found"):
self.left_panel_main_menu = ""
if not vals.get("left_panel_sub_menu_active", "Not found"):
self.top_panel_hover_item_bg = ""
if not vals.get("top_panel_active_subitem_bg_active", "Not found"):
self.top_panel_active_subitem_bg = ""

@api.multi
def _compute_less(self):
Expand Down Expand Up @@ -309,6 +327,16 @@ def _compute_less(self):
code
+ """.navbar-nav .active a{{
background-color: {theme.top_panel_active_item_bg}!important;
}}
#odooMenuBarNav > div > div.o_sub_menu_content > ul > li > a.active{{
background-color: {theme.top_panel_active_item_bg}!important;
}}"""
)
if self.top_panel_active_subitem_bg_active:
code = (
code
+ """#odooMenuBarNav > div > div.o_sub_menu_content > ul > li > ul > li.active > a{{
background-color: {theme.top_panel_active_subitem_bg}!important;
}}"""
)
if self.top_panel_hover_item_font_active:
Expand Down Expand Up @@ -347,31 +375,22 @@ def _compute_less(self):
"""
)
if self.top_panel_hover_item_bg_active:
# Compatibility theme_kit and material backend theme modules
code = (
code
+ """.o_main_navbar > ul > li > a:hover{{
background-color: {theme.top_panel_hover_item_bg}!important;
}}
.o_main_navbar > ul > li > a:focus{{
background-color: {theme.top_panel_hover_item_bg}!important;
}}
.navbar-nav li a:hover{{
background-color: {theme.top_panel_hover_item_bg}!important;
}}
.navbar-nav li a:focus{{
background-color: {theme.top_panel_hover_item_bg}!important;
}}
.o_main_navbar > .o_menu_toggle:hover{{
background-color: {theme.top_panel_hover_item_bg}!important;
+ """#odooMenuBarNav > div > div.o_sub_menu_content > ul > li > a:hover{{
background-color: {theme.top_panel_hover_item_bg} !important;
}}
.o_main_navbar > .o_menu_toggle:focus{{
background-color: {theme.top_panel_hover_item_bg}!important;
#odooMenuBarNav > div > div.o_sub_menu_content > ul > li > a:focus{{
background-color: {theme.top_panel_hover_item_bg} !important;
}}
.open .dropdown-menu > li a:hover {{
background-color: {theme.top_panel_hover_item_bg}!important;
}}
.open .dropdown-menu > li a:focus {{
background-color: {theme.top_panel_hover_item_bg}!important;
"""
)
if self.top_panel_hover_subitem_bg_active:
code = (
code
+ """#odooMenuBarNav > div > div.o_sub_menu_content > ul > li > ul > li > a:hover {{
background: {theme.top_panel_hover_subitem_bg} !important;
}}
"""
)
Expand Down Expand Up @@ -614,13 +633,13 @@ def _compute_less(self):
if self.left_panel_active_item_bg_active:
code = (
code
+ """.o_sub_menu .oe_secondary_submenu .active a{{
+ """.o_sub_menu .oe_secondary_submenu a:focus{{
background-color: {theme.left_panel_active_item_bg}!important;
}}
.o_sub_menu .oe_secondary_submenu a:focus{{
.o_mail_chat .o_mail_chat_sidebar .o_mail_chat_channel_item.o_active {{
background-color: {theme.left_panel_active_item_bg}!important;
}}
.o_mail_chat .o_mail_chat_sidebar .o_mail_chat_channel_item.o_active {{
#sidebar > li > a.active{{
background-color: {theme.left_panel_active_item_bg}!important;
}}
"""
Expand Down
27 changes: 27 additions & 0 deletions theme_kit/views/theme.xml
Expand Up @@ -133,6 +133,19 @@
class="oe_inline"
/>
</div>
<div>
<label for="top_panel_active_subitem_bg" />
<field
name="top_panel_active_subitem_bg_active"
nolabel="1"
class="oe_inline"/>
<field
name="top_panel_active_subitem_bg"
widget="color"
attrs="{'readonly':[('top_panel_active_subitem_bg_active','=',False)]}"
class="oe_inline"
/>
</div>
<div>
<label for="top_panel_hover_item_font" />
<field
Expand Down Expand Up @@ -161,6 +174,20 @@
class="oe_inline"
/>
</div>
<div>
<label for="top_panel_hover_subitem_bg"/>
<field
name="top_panel_hover_subitem_bg_active"
nolabel="1"
class="oe_inline"
/>
<field
name="top_panel_hover_subitem_bg"
widget="color"
attrs="{'readonly':[('top_panel_hover_subitem_bg_active','=',False)]}"
class="oe_inline"
/>
</div>
<!-- Compatibility theme_kit and material backend theme modules -->
<div
attrs="{'invisible':[('backend_theme_installed', '=', False)]}"
Expand Down

0 comments on commit ac9ff26

Please sign in to comment.