Decision Lab: Making tradeoffs visible with Sanity
Описание и применение
Decision Lab позволяет сравнивать варианты по нескольким критериям, изменяя приоритеты без редактирования контента.
Задача
Decisions with no obvious winner need a way to compare options based on multiple criteria and adjust priorities without editing content.
Результат
The Decision Lab app allows users to compare options based on weighted criteria, see how rankings change with priority adjustments, and edit decisions in Sanity without rebuilding the frontend.
Рабочий процесс
- Create a Sanity project and define a decision schema with criteria and options.
- Add a React frontend that queries the public dataset with GROQ.
- Implement scoring formula: fit = sum(score * criterion weight) / (5 * sum(criterion weight)) * 100.
- Normalize missing score arrays in the query layer.
- Add Studio validation to enforce score presence.
- Fix CSS specificity for table headers.
- Deploy the app to Netlify and test with real content.
- Use temporary sliders to adjust weights without changing published data.
Доказательства
The app calculates: fit = sum(score * criterion weight) / (5 * sum(criterion weight)) * 100
The first real publish revealed a useful failure: the document had options but no scores yet. The API returned null for the score arrays.
We also caught a small CSS specificity issue during visual review. The initial letters in the comparison table's colored option marks were pushed away from the center by a generic table-header rule.
- Дата записи: 2026-10-04T17:10:47.120Z