Last active
May 28, 2016 12:34
-
-
Save f/352b385a505cc1e97bca9899868163ac to your computer and use it in GitHub Desktop.
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
| module CssModulesHelper | |
| class Styler | |
| def initialize(component) | |
| @component = encode_module_name(component) | |
| end | |
| def encode_module_name(name) | |
| Base64.encode64(name).gsub(/\W/, "") | |
| end | |
| def style(name) | |
| [@component, name].join("_") | |
| end | |
| end | |
| def style_for(component, name) | |
| Styler.new(component.to_s).style(name.to_s) | |
| end | |
| def component(name, &block) | |
| block.call(Styler.new(name.to_s)) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment