import * as React from "react"; import * as cx from "classnames"; import { Dispatch } from "redux"; import { PCVariable, PCVariableType } from "paperclip"; import { BaseVariableRowItemProps } from "./view.pc"; import { DropdownMenuOption } from "../../../../inputs/dropdown/controller"; import { variableLabelChangeCompleted, variableValueChanged, variableValueChangeCompleted } from "../../../../../actions"; import { EMPTY_ARRAY } from "tandem-common"; import { FontFamily } from "../../../../../state"; import { getFontFamilyOptions } from "../styles/pretty/panes/typography-controller"; export type Props = { alt: boolean; dispatch: Dispatch; variable: PCVariable; fontFamilies: FontFamily[]; }; export default (Base: React.ComponentClass) => class VariableRowItemController extends React.PureComponent { onValueChange = value => { this.props.dispatch(variableValueChanged(this.props.variable, value)); }; onValueChangeComplete = value => { this.props.dispatch( variableValueChangeCompleted(this.props.variable, value) ); }; onLabelChangeComplete = value => { this.props.dispatch( variableLabelChangeCompleted(this.props.variable, value) ); }; render() { const { onValueChange, onValueChangeComplete, onLabelChangeComplete } = this; const { variable, fontFamilies, alt, ...rest } = this.props; const limited = variable.type === PCVariableType.FONT; const color = variable.type === PCVariableType.COLOR; const unlimited = variable.type === PCVariableType.NUMBER || variable.type === PCVariableType.UNIT || variable.type === PCVariableType.TEXT; let limitedOptions: DropdownMenuOption[] = EMPTY_ARRAY; if (variable.type === PCVariableType.FONT) { limitedOptions = getFontFamilyOptions(fontFamilies); } return ( ); } };