I've added a Rails Direct upload integration hyperstack-org/hyperstack#273 (comment)
Last active
October 19, 2019 21:51
-
-
Save sebyx07/75c154b95f0aed28b26d7721a5a5528f to your computer and use it in GitHub Desktop.
JS React => Ruby HYPERSTACK.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mui = require('@material-ui/core'); | |
Mui.default = Mui; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HyperComponent | |
include Hyperstack::Component | |
include Hyperstack::State::Observable | |
param_accessor_style :accessors | |
def __material_component(component_name, **options, &block) | |
Mui.send(component_name, options, &block) | |
end | |
def __material_icon(icon_name, **options) | |
__material_component("Icon", options) { icon_name.underscore } | |
end | |
def method_missing(method_name, *_args, **options, &block) | |
classified_name = method_name.classify | |
name_without_icon = method_name.sub("Icon", "") | |
if classified_name == method_name && `Mui[#{method_name}]` | |
__material_component(method_name, **options, &block) | |
elsif name_without_icon != method_name && classified_name == method_name | |
__material_icon(name_without_icon, **options, &block) | |
else | |
super | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment