Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

SnakeGame component has flattened props #7

Open
petertriho opened this issue Feb 23, 2021 · 0 comments
Open

SnakeGame component has flattened props #7

petertriho opened this issue Feb 23, 2021 · 0 comments

Comments

@petertriho
Copy link
Contributor

useSnakeGame has config that is an object:

export type SnakeGameConfig = {
    smoothAnimations: boolean;
    speed: number;
    multiplier: number; // speed mulitplier when key is held
    tileSize: number; // in px
    numOfTiles: { x: number; y: number };
    colors: {
        tile: string;
        border: string;
        snake: string[];
        apple: string;
    };
};

SnakeGame component has flattened props:

export type Props = {
    className?: string;
    numOfTilesX: SnakeGameConfig["numOfTiles"]["x"];
    numOfTilesY: SnakeGameConfig["numOfTiles"]["y"];
    tileColor: SnakeGameConfig["colors"]["tile"];
    borderColor: SnakeGameConfig["colors"]["border"];
    snakeColors: SnakeGameConfig["colors"]["snake"];
    appleColor: SnakeGameConfig["colors"]["apple"];
} & Omit<SnakeGameConfig, "numOfTiles" | "colors">;

Should just make Props the same type as SnakeGameConfig but Storybook does not support nested types (controls) at the moment so we do not get the nice control types like "color" with nested objects

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant