Module: LucidApp::Api

Defined in:
lib/isomorfeus_preact/lucid_app/api.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/isomorfeus_preact/lucid_app/api.rb', line 3

def self.included(base)
  base.instance_exec do
    def theme(theme_hash = nil, &block)
      theme_hash = block.call if block_given?
      if theme_hash
        %x{
          let css;
          if (typeof theme_hash.$to_n === 'function') { css = theme_hash.$to_n(); }
          else { css = theme_hash; }
          let nano_styles = Opal.global.NanoCSSInstance.sheet(css, "LucidAppTheme");
          base.css_theme = #{::LucidComponent::StylesWrapper.new(`nano_styles`)};
        }
      end
      `base.css_theme`
    end
    alias_method :theme=, :theme
  end
end