1
0
mirror of https://github.com/sakofchit/system.css.git synced 2026-05-05 06:01:22 +09:00

feat(style.css): enhance single children menu bar items

This commit targets items that act as single children items within a menu bar list, and enhances the styling so that they look and behave as items with a menu dropdown associated with them.
It checks for the "aria-haspopup" attribute set to false and applies the styles.
As I read the code, I found that some CSS rules clash with other rules if I use color variables for states like hover and focus, or if I try to look for a common styles ruleset and I add a selector for it.

I believe what I added is not a good practice and does not follow a pattern because the code base became complicated to debug. In this case, I decided to inherit some styles and apply them to my selectors as I think it's a safe approach.

Fixes #26
This commit is contained in:
Houssam Jelliti
2023-03-08 00:38:58 +01:00
parent e40c91daf9
commit 876ff0f3eb
2 changed files with 8 additions and 0 deletions

View File

@@ -197,11 +197,14 @@
</blockquote>
<p>A menu bar consists of menu elements that name menu items and they typically have a dropdown menu associated with them.</p>
<p>In case of a menu item as a single children or plain text with no menu dropdown associated with it, use <code>aria-haspopup="false"</code> attribute.</p>
<p>To create a menu bar we will use the <code>.menu-bar</code> class. </p>
<%- example(`
<ul role="menu-bar">
<li role="menu-item" tabindex="0" aria-haspopup="false">Single Item</li>
<li role="menu-item" tabindex="0" aria-haspopup="false"><a target="_blank" href="https://github.com/sakofchit/system.css">System.css on GitHub</a></li>
<li role="menu-item" tabindex="0" aria-haspopup="true">
File
<ul role="menu">

View File

@@ -637,6 +637,11 @@ ul[role="menu-bar"] > [role="menu-item"]:focus, ul[role="menu-bar"] > [role="men
color: var(--primary);
outline: none;
}
ul[role="menu-bar"] > [role="menu-item"][aria-haspopup="false"] * {
color: inherit;
background: inherit;
text-decoration: none;
}
ul[role="menu"] {
position: relative;
min-width: 200px;