-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UX] Disabling tabs #209
base: 5.x
Are you sure you want to change the base?
[UX] Disabling tabs #209
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,55 @@ | ||||||
Disabling interface elements | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Let's not use disabling and instead talk about what we're actually doing - making something inactive or unavailable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're doing this: making users become not allowed to interact with that thing, effectively removing their ability of taking actions in the code, we use: another way to say is that we're removing pointer events, as this attribute is also appended to ensure users have their most deep desire and wishes to interact completely blocked: how would you find better to call? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's great to pick 1 word to avoid having the synonyms (inactive or unavailable) there in every use |
||||||
======================================= | ||||||
|
||||||
The state of interface elements is a crucial aspect of user interface design, providing visual feedback and preventing interaction when certain actions aren't allowed. | ||||||
|
||||||
Disabling tabs | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
-------------- | ||||||
|
||||||
We use the following CSS code to style disabled tabs: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
.. code-block:: css | ||||||
|
||||||
.nav-tabs.nav-tabs-contained > li.disabled { | ||||||
cursor: not-allowed; | ||||||
color: var(--text-disabled); | ||||||
} | ||||||
|
||||||
.nav-tabs.nav-tabs-contained > li.disabled > a { | ||||||
background-color: var(--button-disabled); | ||||||
pointer-events: none; | ||||||
} | ||||||
|
||||||
This CSS accomplishes the following: | ||||||
|
||||||
* Sets the cursor to ``not-allowed`` for disabled tabs, indicating that interaction is prohibited. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* Changes the text color to a predefined disabled state color. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* Modifies the background color of the tab to visually represent its disabled state. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* Prevent click events on the tab using ``pointer-events: none``. | ||||||
|
||||||
To dynamically disable tabs, we use JavaScript to add or remove the ``disabled`` class. Here's an example function: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
.. code-block:: javascript | ||||||
|
||||||
Mautic.togglePermissionVisibility = function () { | ||||||
setTimeout(function () { | ||||||
if (mQuery('#role_isAdmin_0').prop('checked')) { | ||||||
mQuery('#permissions-tab').removeClass('disabled'); | ||||||
} else { | ||||||
mQuery('#permissions-tab').addClass('disabled'); | ||||||
} | ||||||
}, 10); | ||||||
}; | ||||||
|
||||||
This function: | ||||||
|
||||||
* Checks the state of a checkbox - ``#role_isAdmin_0``. | ||||||
* Adds or removes the ``disabled`` class from the permissions tab based on the checkbox state. | ||||||
|
||||||
To implement disabled states for tabs: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
1. Assign unique IDs to your tab elements. | ||||||
2. Use JavaScript to toggle the ``disabled`` class on the appropriate ``<li>`` elements. | ||||||
|
||||||
.. note:: | ||||||
Always use disabled states instead of hiding elements. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment on heading nesting, this is using the wrong underlines.