narraleaf-react
Version:
A React visual novel player framework
75 lines (74 loc) • 2.45 kB
TypeScript
import { Color, CommonDisplayableConfig } from "../../types";
import { Chained, Proxied } from "../../action/chain";
import { LogicAction } from "../../action/logicAction";
import type { TransformDefinitions } from "../../elements/transform/type";
import { Displayable } from "../../elements/displayable/displayable";
import { EventfulDisplayable } from "../../../player/elements/displayable/type";
import { Layer } from "../../elements/layer";
export type TextConfig = {
alignX: "left" | "center" | "right";
alignY: "top" | "center" | "bottom";
className?: string;
layer: Layer | undefined;
};
export type TextState = {
fontSize: number;
display: boolean;
text: string;
};
export interface ITextUserConfig extends CommonDisplayableConfig {
/**
* Where to align the text horizontally
* @default "center"
*/
alignX: "left" | "center" | "right";
/**
* Where to align the text vertically
* @default "center"
*/
alignY: "top" | "center" | "bottom";
className?: string;
/**
* The font size of the text, see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/font-size)
*
* **Only supports px unit**
* @default 16
*/
fontSize: number;
/**
* The color of the text, supports {@link Color} and hex string
* @default "#000000"
*/
fontColor: Color;
/**
* The text content
*/
text: string;
/**
* Layer of the text
*/
layer?: Layer;
}
export declare class Text extends Displayable<TextDataRaw, Text, TransformDefinitions.TextTransformProps> implements EventfulDisplayable {
constructor(config: Partial<ITextUserConfig>);
constructor(text: string, config?: Partial<ITextUserConfig>);
/**
* Set the text of the Text
* @chainable
*/
setText(text: string): Proxied<Text, Chained<LogicAction.Actions>>;
/**
* Set the font color of the Text
* @chainable
*/
setFontColor(color: Color, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Text, Chained<LogicAction.Actions>>;
/**
* Set the font color of the Text
* @chainable
*/
setFontSize(fontSize: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Text, Chained<LogicAction.Actions>>;
/**
* Use a layer for the Text, will override the layer in the text config
*/
useLayer(layer: Layer): this;
}