You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
e.g. you should be able to do <Cube color="red" size={[1,0,0]} />
If color is provided, wrap the shape in a Colorize (NOTE: probably should be implemented as a wrapper to prevent redundant code)
Accept/convert colors from any standard web format, e.g. "red", "#f00", "#ff0000", "ff0000", "rgba(255,0,0,1)" (note: there are libraries that convert all of these)
The text was updated successfully, but these errors were encountered:
@Slaviiiii yes the idea behind the React Colorize wrapper is to make it so a component accepts the color prop without repeating code across components.
interfaceColorProps{color?: string;}// Define the type for a React component that can accept any propstypeReactComponent<P=any>=React.ComponentType<P>;exportfunctionwithColorProps<Pextendsobject>(WrappedComponent: ReactComponent<P>): ReactComponent<P&ColorProps>{// Create a new component that includes the color propconstWithColor: React.FC<P&ColorProps>=({ color, ...props})=>{return(<Colorizecolor={color}<WrappedComponent{...propsasP}/>;
</Colorize>)};// Set the display name for easier debuggingWithColor.displayName=`WithColor(${WrappedComponent.displayName||WrappedComponent.name||'Component'})`;returnWithColor;}
e.g. you should be able to do
<Cube color="red" size={[1,0,0]} />
color
is provided, wrap the shape in aColorize
(NOTE: probably should be implemented as a wrapper to prevent redundant code)The text was updated successfully, but these errors were encountered: