UNPKG

@dcl/react-ecs

Version:
38 lines (37 loc) 1.06 kB
import { parseProps } from '../utils'; import { ReactEcs } from '../../react-ecs'; import { getFont, getFontSize, getTextAlign, getTextWrap } from './utils'; export { scaleFontSize } from './utils'; /** * * @public * Label component * * A label displays text content * * @example * <Label value="SDK 7" uiTransform={{ margin: { left: 10 } }} /> * * @category Component */ /* @__PURE__ */ export function Label(props) { const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, ...uiTextProps } = props; const commonProps = parseProps({ uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave }); const { font, textAlign, fontSize, textWrap, ...textProps } = uiTextProps; const uiText = { ...textProps, ...getFont(font), ...getTextAlign(textAlign), ...getFontSize(fontSize), ...getTextWrap(textWrap) }; return ReactEcs.createElement("entity", { ...commonProps, uiText: uiText }); }