This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Before making any file edits or starting implementation, FIRST provide a concise summary of findings/plan to the user and wait for confirmation. Do not spend excessive time reading files without delivering intermediate findings.
When performing code reviews, ALWAYS use the svelte-code-writer skill for any Svelte (.svelte) file validation. Do not skip this step even if the review seems straightforward.
Visualización de tiempos en limbo del sistema de aislamiento en prisiones. Proyecto Svelte 5 de Civio.
tiempos-limbo/
├── index.html # HTML entry point with <div id="tiempos-limbo">
├── package.json # Dependencies and npm scripts
├── vite.config.js # Vite + Svelte configuration
├── svelte.config.js # Svelte preprocessor config
├── jsconfig.json # JS/TS path aliases config
├── oxlint.json # Linting rules
├── knip.json # Dead code detection config
├── .prettierrc # Prettier configuration
├── .prettierignore # Prettier ignore rules
├── .nvmrc # Node.js version
├── generate-breakpoints.js # Playwright script for iframe heights
├── breakpoints-report.md # Generated breakpoints report
├── README.md # Embedding code and documentation
│
├── src/
│ ├── main.js # App mount point (reads lang, data-a11y, data-alt)
│ ├── App.svelte # Main component
│ ├── vite-env.d.ts # Vite type declarations
│ │
│ ├── states/ # Reactive state (Svelte 5 runes)
│ │ ├── data.svelte.js # Hardcoded data array
│ │ ├── language.svelte.js # i18n texts and formatters
│ │ └── utils.svelte.js # URL params, mobile detection
│ │
│ ├── lib/ # Reusable components
│ │ ├── WaffleChart.svelte # Main waffle chart (canvas-based grouped squares)
│ │ ├── Selector.svelte # Radio button selector (grouped/detail view)
│ │ ├── ScreenReaderDescription.svelte # A11y: SR descriptions (list/table)
│ │ ├── canvas/
│ │ │ ├── Canvas.svelte # Canvas rendering container
│ │ │ └── CanvasSquare.svelte # Square shape for Canvas
│ │ └── footer/
│ │ ├── Footer.svelte
│ │ └── ShareContainer.svelte
│ │
│ ├── utils/ # Helper functions
│ │ ├── colors.js # Civio color system
│ │ ├── locale.js # Number formatters
│ │ └── clickOutside.svelte.js
│ │
│ ├── a11y/ # Accessibility helpers
│ │ ├── index.js # Type definitions and exports
│ │ └── mainChart.js # Chart description generator
│ │
│ └── assets/ # Static assets
│ ├── civio.svg # Civio logo
│ └── civio-dots.svg # Civio dots logo
│
├── public/ # Static files (copied to dist/)
│ └── civio.png # Civio logo for sharing
│
└── dist/ # Production build output
└── assets/
├── index.js
└── index.css
# Development
npm run dev # Start Vite dev server (localhost:5173)
npm run build # Production build to dist/
npm run preview # Preview production build
# Linting & Formatting
npm run lint # Run Oxlint on src/
npm run lint:fix # Auto-fix Oxlint issues
npm run lint:deps # Check unused dependencies with Knip
npm run lint:all # Full lint + dependency check
npm run format # Format with Prettier
npm run format:check # Check formatting
# Iframe Generation
npm run iframe # Generate iframes for all charts
npm run iframe --languages=es,en # Multiple languages
npm run iframe --selector=chart-id # Specific chart
npm run iframe --selector=chart-id --languages=en # Combinedindex.html- Contains<div id="tiempos-limbo">mount pointsrc/main.js- Mounts App component, readslang,data-a11y, anddata-altattributes from target element
The App component receives these props from main.js:
lang- Language code ('es'default)chartID- Element ID ('tiempos-limbo')a11y- Accessibility debug mode (fromdata-a11yattribute)alt- Alt-text mode (fromdata-altattribute)
Located in src/states/:
data.svelte.js- Hardcoded data as exportedconst dataarray (no async loading)language.svelte.js-Langclass with$state/$derived: i18n texts, number formatters, groupLabelsutils.svelte.js-UrlInfoclass with$state/$derived: URL params (?lang=,?a11y,?alt),isMobileviaMediaQuery
src/App.svelte- Main component with color injection, debug modessrc/lib/WaffleChart.svelte- Canvas-based waffle chart with grouped/expanded viewssrc/lib/Selector.svelte- Radio button toggle (grouped/detail view)src/lib/ScreenReaderDescription.svelte- A11y component: generates sr-only descriptions (list or table format)src/lib/footer/- Footer and sharing componentssrc/lib/canvas/- Canvas rendering components (Canvas + CanvasSquare)
src/utils/colors.js- Civio brand colors, project-specific palettes, CSS variable generationsrc/utils/locale.js- Number formatters (ES/EN decimals, integers)src/utils/clickOutside.svelte.js- Click outside directive
src/lib/ScreenReaderDescription.svelte- Reusable component that renders sr-only descriptions as list or tablesrc/a11y/- Functions that generate screen reader descriptions from datasrc/a11y/mainChart.js-getMainChartA11y()generates description fromvizLangand data. Group labels come fromvizLang.texts.groupLabels- Debug mode: Add
?a11yURL param ordata-a11yattribute to visualize sr-only elements - Alt-text mode: Add
?altURL param ordata-altattribute to show alt description
Data is hardcoded as a static array in data.svelte.js (no async fetch):
export const data = [
["<= 15", { count: 3760, perc: 48.2 }],
[">15 & <= 30", { count: 1559, perc: 19.99 }],
// ... [label, { count, perc }] tuples
];language.svelte.js and utils.svelte.js use classes with Svelte 5 runes:
class Lang {
value = $state('es');
texts = $derived(texts[this.value]);
formatDecimals = $derived(formatDecimals[this.value] ?? formatDecimals['es']);
setLang(lang) { ... }
}
export const vizLang = new Lang();Colors are injected as CSS variables on the chart container:
--civio-blue,--civio-yellow,--civio-green,--civio-lightYellow,--civio-lightGreen(main brand)--primary,--secondary,--light(project area)--bw0to--bw990(grayscale ramp)
Charts are embedded via the code in README.md. The generate-breakpoints.js script uses Playwright to capture responsive heights for iframe generation.