Skip to content

Commit f615e2e

Browse files
committed
Adds Z-Index Layering System
1 parent 903b1c2 commit f615e2e

File tree

7 files changed

+61
-4
lines changed

7 files changed

+61
-4
lines changed

packages/web-forms/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@ It uses the [PrimeVue component library](https://primevue.org/).
4949

5050
We are using a customized version of the Material Light Indigo theme provided by PrimeVue.
5151

52+
#### Z-Index Layering System
53+
54+
This package uses a centralized `z-index` layering system to manage UI stacking order, defined in `src/assets/css/z-index.css`. Custom properties (e.g., `--z-index-error-banner`) ensure elements like floating error messages, form controls, and overlays stack correctly without overlap.
55+
56+
- **Key Layers**:
57+
58+
- `--z-index-base: 0` (background)
59+
- `--z-index-form-content: 10` (inputs, buttons)
60+
- `--z-index-form-floating: 20` (highlights, tooltips)
61+
- `--z-index-error-banner: 30` (floating errors)
62+
- `--z-index-overlay: 100` (modals)
63+
- `--z-index-topmost: 1000` (loaders, notifications)
64+
65+
- **Usage**: Apply with `z-index: var(--z-index-error-banner);` on positioned elements (e.g., `position: absolute`).
66+
67+
See [src/assets/css/z-index.css](src/assets/css/z-index.css) for full details.
68+
5269
### Icons
5370

5471
We use **Material Icons** using IcoMoon to select a subset of icons in order to minimize the size. The font files are located in [`./src/assets/fonts/`](./src/assets/fonts/), and the CSS is [`./src/assets/css/icomoon.css`](/src/assets/css/icomoon.css). Our IcoMoon definition is in the root directory of this package at [`./icomoon.json`](./icomoon.json).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Z-Index Layering System
3+
*
4+
* This project uses a centralized z-index layering system to manage the stacking order of UI
5+
* elements, preventing overlap issues and ensuring maintainability. CSS custom properties are
6+
* defined with meaningful names and a logical sequence, making it easy to understand and adjust
7+
* the stacking order.
8+
*
9+
* Purpose:
10+
* - Avoid z-index conflicts by assigning predefined layers to UI components.
11+
* - Provide clarity on stacking priorities for developers and maintainers.
12+
* - Allow flexibility for future additions without restructuring existing values.
13+
*
14+
* Example:
15+
* .error-banner-placeholder {
16+
* z-index: var(--z-index-error-banner);
17+
* position: absolute;
18+
* }
19+
*/
20+
21+
:root {
22+
/* Base layer for static content (e.g., page content, form background) */
23+
--z-index-base: 0;
24+
25+
/* Standard form controls (e.g., inputs, labels, buttons) */
26+
--z-index-form-content: 10;
27+
28+
/* Floating form elements (e.g., validation highlights, tooltips) */
29+
--z-index-form-floating: 20;
30+
31+
/* Floating error messages or banners above the form */
32+
--z-index-error-banner: 30;
33+
34+
/* Overlays like modals, popups, or dialogs above form content */
35+
--z-index-overlay: 100;
36+
37+
/* Critical UI elements (e.g., loading spinners, toast notifications) */
38+
--z-index-topmost: 1000;
39+
}

packages/web-forms/src/components/OdkWebForm.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ watchEffect(() => {
269269

270270
.form-error-message.p-message.p-message-error {
271271
position: fixed;
272-
z-index: 100;
272+
z-index: var(--z-index-error-banner);
273273
border-radius: 10px;
274274
background-color: var(--error-bg-color);
275275
border: 1px solid var(--error-text-color);

packages/web-forms/src/components/controls/Range/RangeControl.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ const orientation = props.node.appearances.vertical ? 'vertical' : 'horizontal';
192192
// No clue why PrimeVue has a default `transform` style to shrink this!
193193
transform: none;
194194
195-
z-index: 1;
195+
z-index: var(--z-index-form-content);
196196
197197
&:focus-visible {
198198
box-shadow:

packages/web-forms/src/components/widgets/LikertWidget.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ defineEmits(['change']);
6969
7070
.p-radiobutton {
7171
position: relative;
72-
z-index: 10;
72+
z-index: var(--z-index-form-content);
7373
}
7474
7575
.label-text {

packages/web-forms/src/demo/FeedbackButton.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const surveyLink = computed(() => {
3838
right: 0;
3939
bottom: 150px;
4040
height: 4rem;
41-
z-index: 99999;
41+
z-index: var(--z-index-topmost);
4242
border-top-left-radius: 5px;
4343
border-top-right-radius: 5px;
4444
text-align: center;

packages/web-forms/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import OdkWebForm from './components/OdkWebForm.vue';
33

44
import '@fontsource/roboto/300.css';
55
import './assets/css/icomoon.css';
6+
import './assets/css/z-index.css';
67
import './themes/2024-light/theme.scss';
78

89
// TODO/sk: Purge it - using postcss-purgecss

0 commit comments

Comments
 (0)