Module: Admin::MediaAssetsHelper

Defined in:
lib/generators/ruby_cms/templates/helpers/admin/media_assets_helper.rb

Instance Method Summary collapse

Instance Method Details

#media_asset_check_icon(size: 12) ⇒ Object



19
20
21
22
# File 'lib/generators/ruby_cms/templates/helpers/admin/media_assets_helper.rb', line 19

def media_asset_check_icon(size: 12)
  svg = %(<svg fill="none" viewBox="0 0 24 24" stroke-width="3" stroke="currentColor" width="#{size}" height="#{size}"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"/></svg>)
  sanitize(svg, tags: %w[svg path], attributes: %w[fill viewBox stroke-width stroke width height stroke-linecap stroke-linejoin d])
end

#media_asset_icon(kind, size: 28) ⇒ Object

SVG icons used in media asset thumbnails. Returns SafeBuffer. Static markup — no user input — safe to mark as html_safe.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/generators/ruby_cms/templates/helpers/admin/media_assets_helper.rb', line 7

def media_asset_icon(kind, size: 28)
  svg = case kind.to_s
  when "image"
          %(<svg fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" width="#{size}" height="#{size}"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14M4 6a2 2 0 012-2h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6z"/><circle cx="9" cy="9" r="1.5" fill="currentColor" stroke="none"/></svg>)
  when "video"
          %(<svg fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" width="#{size}" height="#{size}"><path stroke-linecap="round" stroke-linejoin="round" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"/><circle cx="12" cy="12" r="9"/></svg>)
  else
          %(<svg fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" width="#{size}" height="#{size}"><path stroke-linecap="round" stroke-linejoin="round" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"/></svg>)
  end
  sanitize(svg, tags: %w[svg path circle], attributes: %w[fill viewBox stroke-width stroke width height stroke-linecap stroke-linejoin d cx cy r])
end

#media_chip_icon(kind) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/generators/ruby_cms/templates/helpers/admin/media_assets_helper.rb', line 24

def media_chip_icon(kind)
  svg = case kind.to_s
  when "folder"
          %(<svg fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M3 7a2 2 0 012-2h4l2 2h8a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2V7z"/></svg>)
  when "layers"
          %(<svg fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16"/></svg>)
  when "search"
          %(<svg fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-4.35-4.35M11 19a8 8 0 100-16 8 8 0 000 16z"/></svg>)
  else
          ""
  end
  sanitize(svg, tags: %w[svg path], attributes: %w[fill viewBox stroke-width stroke stroke-linecap stroke-linejoin d])
end