There's a frequent usecase with javascript libraries where you want to decorate your components with higher order components.
For example, the material-ui library includes a styling higher-order component withStyles. 
In javascript, you would do
import { withStyles } from '@material-ui/core';
const styles = {
  example: {
    padding: 8
  }
}
const SomeComponent = ({classes}) => <div className={classes.example}>I'm a component</div>;
export default withStyles(SomeComponent);
How can you achieve the same in Hyperstack?
 
                        
First off looks like there is an issue that you have to patch. This will be fixed in the next point release: Just add this method to your
Hypercomponentbase class (app/hyperstack/components/hypercomponent.rb)Now if you have the following styles:
and a component that you want to style:
You can do so like this:
What is happening is we are dropping out to JS using the backticks and calling
Mui.with_stylesdirectly and passing itMY_STYLES(just like in the MUI doc example). Theto_nconverts from a Ruby Hash to JS object. (When passing params to components this is automatic, but not so with simple function calls.)Then we call the resulting HOC with our
StyleTestclass (also callingto_nto convert from a Ruby class to a simple JS class.)Finally, we import it back into a Hyperstack component class.
That is a little more work than I like so we can just add a handy helper method to our
HyperComponentclass:Now we can add styles like this:
and now we have a new Component Class with our style in it.
For example: