Sha256: 9690074aa24775ff4a3a6f95d18aaf53f6dc1498ba8fc9a6bf037b16129f06e0

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

module ZuoraConnectUi
  # General helpers for application level
  module ApplicationHelper
    def zuo_parameterize(string)
      if Rails::VERSION::STRING.start_with? '5'
        string.parameterize(separator: '_')
      else
        string.parameterize('_')
      end
    end

    def zuo_include_tag
      script_tag(type: 'module', src: anjuna(ANJUNA_VERSION, true)) +
        script_tag(nomodule: '', src: anjuna(ANJUNA_VERSION, false)) +
        link_tag(href: theme(THEME_VERSION, 'application'), rel: 'stylesheet') +
        link_tag(href: theme(THEME_VERSION, 'theme'), rel: 'stylesheet') +
        link_tag(href: theme(THEME_VERSION, 'icons'), rel: 'stylesheet')
    end

    def script_tag(attrs)
      attr_map = attrs.map { |key, value| " #{key}=\"#{value}\"" }

      "<script#{attr_map.join('')}></script>".html_safe
    end

    def anjuna(version, esm)
      "https://cdn.zuora.com/anjuna/#{version}" \
        "/core/anjuna-core/anjuna-core#{'.esm' if esm}.js"
    end

    def link_tag(attrs)
      attr_map = attrs.map { |key, value| " #{key}=\"#{value}\"" }

      "<link#{attr_map.join('')}>".html_safe
    end

    def theme(version, file)
      "https://cdn.zuora.com/theme/#{version}/css/#{file}.css"
    end

    ANJUNA_VERSION = '1.0.0-rc.23'
    THEME_VERSION = '1.0.0-rc.6'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zuora_connect_ui-0.10.0 app/helpers/zuora_connect_ui/application_helper.rb