Skip to content
brightness-system logo

Brightness System Skill

brightness-system

8-mode brightness system implementation with CSS custom properties. Use when implementing theme switching, color tokens, or fixing brightness-related issues.

SKILL.md

Full skill instructions

Brightness System Skill

Overview

The omer-akben portfolio implements an 8-mode brightness system that must be tested and supported for all UI changes. This skill covers implementation patterns, testing requirements, and troubleshooting.

8 Brightness Modes

Modes: -3 (darkest) → 0 (baseline) → +3 (brightest) + auto

Implementation

  • data-brightness attribute on <html> element
  • CSS custom properties in globals.css
  • State management in lib/​brightness-context.tsx

CSS Custom Properties (MANDATORY)

Color Tokens

✅ ALWAYS USE:

/​* Surfaces */
bg-surf-0    /​* Primary background */
bg-surf-1    /​* Secondary background */
bg-surf-2    /​* Tertiary background */

/​* Text */
text-text-1  /​* Primary text */
text-text-2  /​* Secondary text */
text-text-3  /​* Tertiary text */

/​* Brand */
bg-brand-primary    /​* Brand accent color */
bg-brand-secondary  /​* Secondary brand color */

/​* Borders */
border-border-line  /​* Border color */
```typescript

❌ **NEVER USE:**

- Hardcoded hex colors: `#00FFC6`, `#1a1a1a`
- Inline color values: `bg-[#00FFC6]`
- Direct Tailwind colors without tokens

### Example Implementation

```tsx
// ✅ CORRECT
<div className="bg-surf-1 text-text-1 border-border-line">
  <button className="bg-brand-primary hover:bg-brand-secondary">
    Click me
  </​button>
</​div>

// ❌ WRONG
<div className="bg-[#1a1a1a] text-white border-gray-800">
  <button className="bg-[#00FFC6] hover:bg-emerald-400">
    Click me
  </​button>
</​div>
```typescript

## Implementation Patterns

### Setting Brightness Mode

```typescript
import { useBrightness } from "@/​lib/​brightness-context";

function BrightnessControl() {
  const { brightness, setBrightness } = useBrightness();

  return (
    <select
      value={brightness}
      onChange={(e) => setBrightness(e.target.value as BrightnessMode)}
    >
      <option value="-3">Darkest (-3)</​option>
      <option value="-2">Darker (-2)</​option>
      <option value="-1">Dark (-1)</​option>
      <option value="0">Baseline (0)</​option>
      <option value="1">Light (+1)</​option>
      <option value="2">Lighter (+2)</​option>
      <option value="3">Lightest (+3)</​option>
      <option value="auto">Auto</​option>
    </​select>
  );
}
```typescript

### Brightness Context Provider

Location: `src/​lib/​brightness-context.tsx`

```typescript
export type BrightnessMode = "-3" | "-2" | "-1" | "0" | "1" | "2" | "3" | "auto";

interface BrightnessContextType {
  brightness: BrightnessMode;
  setBrightness: (mode: BrightnessMode) => void;
}
```typescript

### HTML Attribute

The brightness mode is set on the root HTML element:

```html
<html data-brightness="0">
  <!-- content -->
</​html>
```typescript

CSS custom properties respond to this attribute:

```css
[data-brightness="0"] {
  --color-surf-0: #0a0a0a;
  --color-text-1: #ffffff;
}

[data-brightness="3"] {
  --color-surf-0: #f5f5f5;
  --color-text-1: #0a0a0a;
}
```typescript

## Testing Requirements

### ⚠️ CRITICAL: Test All 8 Modes

**Every UI change MUST be tested in all 8 brightness modes.**

### Manual Testing

1. Open DevTools (F12)
2. Find `<html>` element in Elements tab
3. Modify `data-brightness` attribute manually
4. Test each mode: `-3`, `-2`, `-1`, `0`, `1`, `2`, `3`, `auto`
5. Verify:
   - Text is readable
   - Contrast is sufficient
   - Colors follow design tokens
   - No hardcoded colors appear

### Unit Test Pattern

```typescript
import { render } from "@testing-library/​react";

describe("Component brightness modes", () => {
  const modes = ["-3", "-2", "-1", "0", "1", "2", "3", "auto"];

  modes.forEach((mode) => {
    it(`should render correctly in brightness mode ${mode}`, () => {
      // Set mode on root
      document.documentElement.setAttribute("data-brightness", mode);

      render(<YourComponent />);

      // Assert appearance
      const element = screen.getByRole("button");
      expect(element).toHaveClass("bg-brand-primary");
      expect(element).not.toHaveClass("bg-[#00FFC6]");
    });
  });
});
```typescript

### E2E Test Pattern

```typescript
import { test, expect } from "@playwright/​test";

test.describe("Brightness modes", () => {
  const modes = ["-3", "-2", "-1", "0", "1", "2", "3", "auto"];

  modes.forEach((mode) => {
    test(`should display correctly in mode ${mode}`, async ({ page }) => {
      await page.goto("/");

      // Set brightness mode
      await page.evaluate((m) => {
        document.documentElement.setAttribute("data-brightness", m);
      }, mode);

      // Wait for CSS to apply
      await page.waitForTimeout(100);

      // Take screenshot for visual comparison
      await expect(page).toHaveScreenshot(`brightness-${mode}.png`);
    });
  });
});
```typescript

## Common Issues & Solutions

### Issue: Hardcoded Colors Appear

**Symptoms:** Colors don't change with brightness mode

### Solution

1. Search codebase for hex colors: `#[0-9a-fA-F]{3,6}`
2. Replace with CSS custom properties
3. Verify with `grep -r "#[0-9a-fA-F]" src/`

### Issue: Insufficient Contrast

**Symptoms:** Text hard to read in certain modes

### Solution

1. Review color token values in `globals.css`
2. Adjust contrast ratios (minimum 4.5:1 for normal text)
3. Test with browser DevTools contrast checker

### Issue: Component Not Responding to Mode Changes

**Symptoms:** Component colors stay the same

### Solution

1. Verify component uses CSS custom properties
2. Check if component has inline styles (remove them)
3. Ensure parent elements don't override tokens

## Design Token Reference

Complete list of available tokens in `src/​app/​globals.css`:

```css
/​* Surface Colors */
--color-surf-0: /​* Primary surface */
--color-surf-1: /​* Secondary surface */
--color-surf-2: /​* Tertiary surface */

/​* Text Colors */
--color-text-1: /​* Primary text */
--color-text-2: /​* Secondary text */
--color-text-3: /​* Tertiary text */

/​* Brand Colors */
--color-brand-primary: /​* Primary brand (emerald) */
--color-brand-secondary: /​* Secondary brand */

/​* Border Colors */
--color-border-line: /​* Default border */

/​* Functional Colors */
--color-error: /​* Error state */
--color-success: /​* Success state */
--color-warning: /​* Warning state */
```typescript

## Checklist for New Components

When creating a new component:

- [ ] Use only CSS custom properties for colors
- [ ] No hardcoded hex colors or Tailwind color classes
- [ ] Test component in all 8 brightness modes
- [ ] Verify contrast ratios meet WCAG AA (4.5:1)
- [ ] Check hover states in all modes
- [ ] Verify focus indicators are visible in all modes
- [ ] Test with auto mode (respects system preference)

## Auto Mode Behavior

When `brightness="auto"`:

- Respects user's system preference (light/​dark)
- Uses `prefers-color-scheme` media query
- Maps to mode `0` (dark) or mode `2` (light) by default

```css
[data-brightness="auto"] {
  @media (prefers-color-scheme: dark) {
    /​* Use dark mode tokens */
  }

  @media (prefers-color-scheme: light) {
    /​* Use light mode tokens */
  }
}
```typescript

## Performance Considerations

- CSS custom properties are performant (no runtime calculation)
- Mode changes only update root attribute (no re-renders)
- Tailwind processes tokens at build time
- No JavaScript needed for color computation

## Related Files

- `src/​lib/​brightness-context.tsx` - Context provider and hooks
- `src/​app/​globals.css` - Color token definitions
- `src/​components/​brightness-toggle.tsx` - UI control (if exists)

## Quick Reference

```bash
# Find hardcoded colors in codebase
grep -r "#[0-9a-fA-F]" src/

# Test brightness modes in browser DevTools
document.documentElement.setAttribute("data-brightness", "3")

# Check component uses correct tokens
// Should see: bg-surf-1, text-text-1, border-border-line
// Should NOT see: bg-[#xxx], text-white, border-gray-800
```typescript

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View