module Docks::Themes::API::Helpers
Public Instance Methods
docks_component(name, opts = {}, &block)
click to toggle source
# File lib/docks_theme_api/helpers/ui_helper.rb, line 57 def docks_component(name, opts = {}, &block) locals = {} locals[name.to_s.split(":").last.to_sym] = locals[:component] = Components.component_for(name).new(self, opts, &block) if block.nil? render(Components.template_path(name), locals) else concat render(Components.template_path(name), locals) end end
docks_demo(demo, locals = {})
click to toggle source
# File lib/docks_theme_api/helpers/ui_helper.rb, line 30 def docks_demo(demo, locals = {}) locals[:id] ||= unique_iframe_id locals[:demo] = demo render(Docks::Templates.demo.path, layout: Docks::Templates.demo.layout, locals: locals) end
docks_icon(name, options = {})
click to toggle source
# File lib/docks_theme_api/helpers/ui_helper.rb, line 18 def docks_icon(name, options = {}) klass = "icon" size = options.delete(:size) klass << " icon--#{size}" unless size.nil? color = options.delete(:color) klass << " icon--#{color.to_s.gsub("_", "-")}" unless color.nil? "<svg class='#{klass}'><use xlink:href='#icon--#{name}'></use></svg>" end
docks_icons()
click to toggle source
# File lib/docks_theme_api/helpers/ui_helper.rb, line 13 def docks_icons # html safe File.read(API.instance.assets.path_for("images/icons.svg")) end
unique_iframe_id()
click to toggle source
# File lib/docks_theme_api/helpers/ui_helper.rb, line 7 def unique_iframe_id @iframe_id ||= 0 @iframe_id += 1 "iframe--#{@iframe_id}" end