Sha256: ba1a93c85799c3f150dc06ba308234e98df5a2f95d4b35a3b7b8c49fddd46eff
Contents?: true
Size: 1.71 KB
Versions: 2
Compression:
Stored size: 1.71 KB
Contents
module Headmin module BootstrapHelper def bootstrap_icon(icon, options = {}) tag_name = options.extract!(:tag_name).fetch(:tag_name, :i) options[:class] = ['bi', "bi-#{icon}", options.dig(:class)].compact.join(' ') content_tag(tag_name, options) {} end # References # https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types def bootstrap_icon_for_mime_type(mime_type, options = {}) type_map = { image: %w[image/bmp image/gif image/vnd.microsoft.icon image/jpeg image/png image/svg+xml image/tiff image/webp], play: %w[video/mp4 video/mpeg video/ogg video/mp2t video/webm video/3gpp video/3gpp2], music: %w[audio/aac audio/midi audio/x-midi audio/mpeg audio/ogg audio/opus audio/wav audio/webm audio/3gpp audio/3gpp2], word: %w[application/msword application/vnd.openxmlformats-officedocument.wordprocessingml.document], ppt: %w[application/vnd.ms-powerpoint application/vnd.openxmlformats-officedocument.presentationml.presentation], excel: %w[application/vnd.ms-excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet], slides: %w[application/vnd.oasis.opendocument.presentation], spreadsheet: %w[application/vnd.oasis.opendocument.spreadsheet], richtext: %w[application/vnd.oasis.opendocument.text], zip: %w[application/zip application/x-7z-compressed application/x-bzip application/x-bzip2 application/gzip application/vnd.rar], pdf: %w[application/pdf], } icon_name = type_map.find{|key, mime_types| mime_types.include?(mime_type)}.first icon = ['file', 'earmark', icon_name].compact.join('-') bootstrap_icon(icon, options) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
headmin-0.3.2 | app/helpers/headmin/bootstrap_helper.rb |
headmin-0.3.1 | app/helpers/headmin/bootstrap_helper.rb |