Skip to content

accept @echecs/pgn Arrow type directly #43

@mormubis

Description

@mormubis

react-board defines its own Arrow type with a kind: ArrowKind field ('move' | 'capture' | 'danger' | 'alternative'), which maps to colors internally. pgn defines Arrow with color: AnnotationColor ('G' | 'R' | 'Y' | 'B' | 'O' | 'C').

consumers parsing PGN [%cal] annotations can't pass them to the board without an adapter.

proposal

switch react-board's Arrow to use pgn's AnnotationColor instead of ArrowKind:

// before
type ArrowKind = 'alternative' | 'capture' | 'danger' | 'move';
interface Arrow { from: Square; kind: ArrowKind; to: Square }

// after
type AnnotationColor = 'B' | 'C' | 'G' | 'O' | 'R' | 'Y';
interface Arrow { color: AnnotationColor; from: Square; to: Square }

the CSS variable map in annotation-overlay.tsx changes from keying on kind to keying on color. the drawing hook maps keyboard modifiers to AnnotationColor values instead of ArrowKind values. Circle gets the same change (kindcolor).

this also expands the palette — current board only supports 4 colors, pgn supports 6 (adds cyan and orange).

breaking change — major version bump.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions