Skip to content

Commit f448d3e

Browse files
authored
Merge pull request #209 from andersonjeccel/disabling-tabs
[UX] Disabling tabs
2 parents 9ed36da + c7e5bad commit f448d3e

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

docs/design/availability.rst

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Depicting availability of interface elements
2+
############################################
3+
4+
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.
5+
6+
Working with tabs
7+
*****************
8+
9+
Mautic uses the following CSS code to style tabs which aren't available for interaction:
10+
11+
.. code-block:: css
12+
13+
.nav-tabs.nav-tabs-contained > li.disabled {
14+
cursor: not-allowed;
15+
color: var(--text-disabled);
16+
}
17+
18+
.nav-tabs.nav-tabs-contained > li.disabled > a {
19+
background-color: var(--button-disabled);
20+
pointer-events: none;
21+
}
22+
23+
This CSS accomplishes the following:
24+
25+
* Sets the cursor to ``not-allowed`` for tabs which can't be interacted with, indicating that interaction is prohibited.
26+
* Changes the text color to a predefined inactive state color.
27+
* Modifies the background color of the tab to visually represent its inactive state.
28+
* Prevent click events on the tab using ``pointer-events: none``.
29+
30+
To dynamically deactivate tabs, use JavaScript to add or remove the ``disabled`` class. Here's an example function:
31+
32+
.. code-block:: javascript
33+
34+
Mautic.togglePermissionVisibility = function () {
35+
setTimeout(function () {
36+
if (mQuery('#role_isAdmin_0').prop('checked')) {
37+
mQuery('#permissions-tab').removeClass('disabled');
38+
} else {
39+
mQuery('#permissions-tab').addClass('disabled');
40+
}
41+
}, 10);
42+
};
43+
44+
This function:
45+
46+
* Checks the state of a checkbox - ``#role_isAdmin_0``.
47+
* Adds or removes the ``disabled`` class from the permissions tab based on the checkbox state.
48+
49+
To implement inactive states for tabs:
50+
51+
1. Assign unique IDs to your tab elements.
52+
2. Use JavaScript to toggle the ``disabled`` class on the appropriate ``<li>`` elements.
53+
54+
.. note::
55+
Always use inactive states instead of hiding elements.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ There are several ways to support Mautic other than contributing with code.
5757
:hidden:
5858

5959
design/accordion
60+
design/availability
6061
design/feedback
6162
design/labelling
6263
design/notifications

0 commit comments

Comments
 (0)