Sha256: bae16afac5554336602bc2b1c66a6ac3b18fd4b9419a4554b2c44e2df57922be

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.14'
    THEME_VERSION = '1.0.0-rc.5'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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