Module: Workarea::StyleGuidesHelper

Defined in:
app/helpers/workarea/style_guides_helper.rb

Defined Under Namespace

Classes: Partials

Instance Method Summary collapse

Instance Method Details



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/helpers/workarea/style_guides_helper.rb', line 36

def link_to_style_guide(category, partial, dialog = false, custom_anchor = nil)
  parent = partial.split('__').first
  anchor = partial.include?('__') ? partial.dasherize : custom_anchor
  text = custom_anchor.present? ? custom_anchor : partial.dasherize

  link_to(
    text,
    style_guide_path(
      category,
      parent,
      anchor: anchor,
      locale: params[:locale] # included to fix tests
    ),
    data: dialog ? { dialog_button: '' } : nil,
    class: style_guide_link_class(partial)
  )
end

#partial_paths_for(category) ⇒ Object



28
29
30
31
32
33
34
# File 'app/helpers/workarea/style_guides_helper.rb', line 28

def partial_paths_for(category)
  scope = engine.parent.to_s.demodulize.downcase

  style_guide_engines.map { |e| Partials.new(e.root, scope, category).to_a }
    .flatten
    .uniq
end

#style_guide_iconsObject



54
55
56
57
58
59
60
61
# File 'app/helpers/workarea/style_guides_helper.rb', line 54

def style_guide_icons
  style_guide_engines
    .map { |e| Dir["#{e.root}/app/assets/images/workarea/#{parent_module.slug}/**/icons/**/*.svg"].uniq.sort }
    .flatten
    .reverse
    .uniq { |path| File.basename(path) }
    .sort_by { |path| File.basename(path) }
end


64
65
66
67
68
# File 'app/helpers/workarea/style_guides_helper.rb', line 64

def style_guide_link_class(partial)
  classes = ['style-guide__link']
  classes << 'style-guide__link--active' if partial == params[:id]
  classes.join(' ')
end