RFC 086: IIIF Viewer Context Refactoring

Status: Not started Estimated effort: 14-17 hours Last modified: 2026-04-14T13:30:00+00:00

Purpose

This folder contains a comprehensive plan to refactor the IIIF Viewer context to eliminate code duplication and centralise derived state calculations.

Key principle: Write automated tests BEFORE refactoring (test-first approach), then use manual testing for extra confidence.

Table of Contents

Understanding the Problem

Approach

Implementation Phases

Reference

Quick Navigation

I want to understand the refactoring

Start with 01-overview.md

I want to implement Phase 3

Read 09-phase-3-canvas-data.md and Testing Guide

I want to see test examples

Go to Testing Guide for complete TypeScript test examples

I want the testing checklist

See 14-testing-strategy.md for automated test requirements and manual testing checklist

Key Principles

  1. Fix types first - Audit and fix all types before refactoring (Phase 0)

  2. Automated tests BEFORE refactoring - Build comprehensive test coverage first

  3. Feature flag everything - Safe rollout with instant rollback capability

  4. Crystal-clear naming - Use is..., has..., can..., should... patterns for booleans

  5. Test-first workflow - Green to Green refactoring (tests pass before and after)

  6. Manual tests as backup - Comprehensive checklist for extra confidence

  7. Context for shared state only - Only add to context if used by 2+ components or likely to be needed soon

  8. Hooks for complex logic - Extract to custom hooks for testability, even if only used once8. Split components with drastically different modes - See Future Improvements for details

Progress Tracking


Related Documentation:

Last updated