From 077cf924f941ec0e2d0d62e923cf77091a88453d Mon Sep 17 00:00:00 2001 From: Jayash Tripathy <76092296+JayashTripathy@users.noreply.github.com> Date: Mon, 8 Dec 2025 13:42:28 +0530 Subject: [PATCH] chore: enhance design system documentation with rare exceptions for visual separation --- .../design-system-philosophy.stories.tsx | 43 +++++++++++++-- packages/tailwind-config/AGENTS.md | 55 ++++++++++++++++--- 2 files changed, 83 insertions(+), 15 deletions(-) diff --git a/packages/propel/src/design-system/design-system-philosophy.stories.tsx b/packages/propel/src/design-system/design-system-philosophy.stories.tsx index 386620645e..511a29a076 100644 --- a/packages/propel/src/design-system/design-system-philosophy.stories.tsx +++ b/packages/propel/src/design-system/design-system-philosophy.stories.tsx @@ -136,7 +136,8 @@ export const SurfaceLayerAssociation: Story = { render: () => ( - Each surface should use its corresponding layer: surface-1 → layer-1, surface-2 → layer-2 + Each surface should use its corresponding layer: surface-1 → layer-1, surface-2 → layer-2. Very rare exception: + inputs/buttons can go one level above for visual separation. @@ -156,6 +157,30 @@ export const SurfaceLayerAssociation: Story = { + +
+ + In very rare cases, form elements (inputs, buttons, switches) can use one level above for visual separation. + + +

Modal with Input (Rare Exception)

+
+
+ + +

+ Input uses bg-layer-2 (one level above) for visual separation from modal surface +

+
+
+
+
), }; @@ -214,16 +239,19 @@ export const CardListPattern: Story = { export const SidebarLayoutPattern: Story = { render: () => ( - Sidebar and main content are both part of the same surface + + Sidebar and main content are both part of the same surface. Sidebar menu items use transparent backgrounds with + hover states. + @@ -366,10 +394,13 @@ export const CommonMistakes: Story = {

Surface 1

-

Using layer-2 with surface-1 - WRONG!

+

Using layer-2 with surface-1 for content box - WRONG!

-

✅ Fix: Use bg-layer-1 with bg-surface-1

+

+ ✅ Fix: Use bg-layer-1 with bg-surface-1 for content boxes. Exception: Very rare cases for inputs/buttons + that need visual separation (e.g., input in modal can use bg-layer-2 for separation). +

diff --git a/packages/tailwind-config/AGENTS.md b/packages/tailwind-config/AGENTS.md index 68f7ca7181..a275327ef7 100644 --- a/packages/tailwind-config/AGENTS.md +++ b/packages/tailwind-config/AGENTS.md @@ -154,6 +154,14 @@ function Page() { - `bg-surface-2` → use `bg-layer-2` for nested elements - `bg-surface-3` → use `bg-layer-3` for nested elements +**Rare Exception - Visual Separation**: + +In very rare cases, you may go one level above for visual separation when needed for specific UI elements: + +- Inputs in modals (modal has `bg-surface-1`, input can use `bg-layer-2` for separation) +- Buttons, switches, and form controls that need more visual distinction +- **Important**: This is very rare and should only be used for interactive form elements, not for content boxes or cards + **Example**: ```tsx @@ -171,12 +179,20 @@ function Page() {
-// ❌ Wrong: Surface-1 with layer-2 +// ❌ Wrong: Surface-1 with layer-2 (for content boxes)
- {/* Wrong layer for this surface */} + {/* Wrong layer for this surface - use layer-1 for content boxes */}
+ +// ✅ Correct: Rare exception - Input in modal for visual separation +
+
+ + {/* Input uses layer-2 for visual separation from modal surface */} +
+
``` ## Stacking Layers @@ -359,12 +375,13 @@ function PageWithModal() { ```tsx // ✅ Correct: Sidebar with main content (page level, not app root) // Both sidebar and main are siblings on the same surface +// Sidebar menu items use transparent backgrounds with hover states function DashboardPage() { return (
{/* Sidebar - part of the page surface */} {/* Main content - part of the page surface */} @@ -395,12 +412,22 @@ function DashboardPage() {
+ {/* Input can use bg-surface-1 or bg-layer-2 for visual separation (rare exception) */}
+ +// ✅ Correct: Input in modal (rare exception for visual separation) +
+
+ + {/* Input uses layer-2 for visual separation from modal surface - rare exception */} + +
+
``` ## Decision Tree @@ -524,21 +551,29 @@ function Page() { ### ❌ Mistake 3: Wrong Layer for Surface ```tsx -// ❌ Wrong: surface-1 with layer-2 +// ❌ Wrong: surface-1 with layer-2 (for content boxes)
- Content + Content box
-// ✅ Correct: surface-1 with layer-1 +// ✅ Correct: surface-1 with layer-1 (for content boxes)
- Content + Content box
+ +// ✅ Correct: Rare exception - Input/button for visual separation +
+ + {/* Input uses layer-2 for visual separation - very rare exception */} +
``` +**Note**: Going one level above (e.g., `bg-layer-2` with `bg-surface-1`) is only valid in very rare cases for interactive form elements (inputs, buttons, switches) that need extra visual separation. For content boxes, cards, and normal nested elements, always match the layer number to the surface number. + ### ❌ Mistake 4: Mismatched Hover ```tsx @@ -573,7 +608,7 @@ function Page() { 2. **Use Surfaces for Pages and Top-Level Containers**: Surfaces are siblings, not nested (except modals/overlays on different planes) -3. **Match Layers to Surfaces**: surface-1 → layer-1, surface-2 → layer-2, etc. +3. **Match Layers to Surfaces**: surface-1 → layer-1, surface-2 → layer-2, etc. (Very rare exception: form elements can go one level above for visual separation) 4. **Stack Layers Properly**: Use layer-1 first, then layer-2, then layer-3 as needed @@ -605,6 +640,7 @@ Canvas (one per page) - Card: `bg-surface-1` → `bg-layer-1 hover:bg-layer-1-hover` - Nested Card: `bg-surface-1` → `bg-layer-1` → `bg-layer-2` - Sidebar Layout: `bg-surface-1` (sidebar) + `bg-surface-1` (main) - both siblings +- Sidebar Menu Items: Transparent background with `hover:bg-layer-1-hover` (no base `bg-layer-1`) ### State Variants @@ -619,7 +655,8 @@ When reviewing components, ensure: - [ ] Canvas is only used at the application root (one place in entire app) - [ ] Pages use surfaces, not canvas - [ ] Surfaces are siblings, not nested (except modals/overlays on different planes) -- [ ] Layers match their surface (surface-1 → layer-1) +- [ ] Layers match their surface (surface-1 → layer-1) - except rare cases for form elements +- [ ] Sidebar menu items use transparent backgrounds with hover states - [ ] Hover states match base layers - [ ] Layers stack properly (1 → 2 → 3) - [ ] Text colors are semantic (primary, secondary, tertiary, placeholder)