Skip to the content

Kyuubuキューブ

Turn CSS 3D cubes by touch, keys or notation, reproduce a scramble from a seed, and follow a solve one named step at a time.

Kyuubu (キューブ) is the Japanese spelling of cube. About the name

Contents

Reference · React components

KyuubuPropstype

The component's props: every option of CubeView, a state the parent may keep, and the box's className, style and data-*.

Import it

import type { KyuubuProps } from "@johnmorrisdotca/kyuubu/react";

Definition

type KyuubuProps = Omit<CubeViewOptions, "state"> & {
    state?: string;
    className?: string;
    style?: CSSProperties;
    ref?: Ref<KyuubuHandle>;
    colours?: Partial<Record<CubeFace, string>>;
    hint?: CubeMove | readonly CubeMove[] | null;
    [data: `data-${string}`]: string | undefined;
};

Members

NameTypeDescription
sizenumber

The cube's side: 2 for a 2×2, 3 for the classic.

colours (optional)Partial<Record<"U" | "R" | "F" | "D" | "L" | "B", string>> | undefined

Colours for the six faces, by the letter a solved face carries. A face left out takes its CSS custom property (--kyuubu-up and the rest), and the standard colour where that is not set.

plastic (optional)string | undefined

The colour of the plastic between stickers and inside the cube. Left out, it is --kyuubu-plastic, and #111 where that is not set.

theme (optional)CubeTheme | undefined

A whole look at once: colours, plastic and the shape of a sticker. colours and plastic given beside it win.

rounded (optional)boolean | undefined

Whether the cube's corners are rounded, like the plastic of a real one: true when left out. The theme's cornerRadius says how round.

locale (optional)KyuubuLanguage | undefined

The language of the cube's accessible name: English or Japanese. Left out, it follows the page's lang.

scale (optional)"small" | "medium" | "large" | undefined

How big it is drawn: small (72 pixels, for a list or a picker), medium (160) or large (300). The host is given that width and kept square. Left out, the cube fills the box it is in. width wins over it. A small cube is look-only unless interactive says otherwise.

width (optional)number | undefined

How wide it is drawn, in pixels, in place of scale's.

interactive (optional)boolean | undefined

Whether a person can turn it. A look-only cube still turns when asked (turn). True when left out, except at small.

keyboard (optional)"focus" | "page" | "none" | undefined

Where the keys are listened for: the cube itself once it has focus (the default), the whole page, or nowhere.

animateScramble (optional)boolean | undefined

Whether scramble shows the turns it makes: the last few, quickly, after the rest are made at once. True when left out; a device that asks for reduced motion shows none whatever this says.

turnMs (optional)number | undefined

How long a quarter turn takes, in milliseconds, when it is made by a key, by notation or from code: 160 when left out. A device that asks for reduced motion gets no animation, whatever this says. setTurnMs changes it later.

commitAngle (optional)number | undefined

The point of no return of a dragged layer, in degrees: 30 when left out. A layer let go short of it goes back and no move is made; at it or past it, the turn is completed. From 5 to 85.

yaw (optional)number | undefined

How the cube is first seen: turned about its up axis, in degrees.

pitch (optional)number | undefined

How the cube is first seen: tipped towards the viewer, in degrees.

fill (optional)number | undefined

How much of the space the cube fills, 0 to 1.

onTurn (optional)((move: CubeMove, state: string) => void) | undefined

A turn a person made, with the cube's stickers once it is done.

onLook (optional)((yaw: number, pitch: number) => void) | undefined

Every time the view is turned, for anything that wants to keep it.

label (optional)string | undefined

What a screen reader calls the cube. Left out, it is "A 3×3 cube" in the cube's language.

state (optional)string | undefined

The stickers the cube starts with. Read when the cube is made, and again whenever it changes to something the cube is not already showing, so a parent that keeps the state and hands it back never makes it jump.

className (optional)string | undefined
style (optional)CSSProperties | undefined
ref (optional)Ref<KyuubuHandle> | undefined
hint (optional)CubeMove | readonly CubeMove[] | null | undefined

Moves to show on the cube, the way the visual guide shows them: the layer lit and an arrow the way to drag it. Null or left out shows nothing. Shown again whenever it changes, and on a cube made afresh.

Examples

import type { KyuubuProps } from "@johnmorrisdotca/kyuubu/react";


const value: KyuubuProps = { size: 3, interactive: true, "data-puzzle": "daily" };
console.log(value.size);
3

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/kyuubu 1.14.1.