Sha256: 67dcada55845502692174ab91042162bb84a6d68b0280b9dc385e782d0b7e040

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

module ZuoraConnectUi
  # Helper methods for including CDN links in views
  module AssetHelper
    ANJUNA_VERSION = '1.2.14'
    ANJUNA_CORE_URL = "https://cdn.zuora.com/@anjuna/core@#{ANJUNA_VERSION}/anjuna-core/anjuna-core.js"
    ANJUNA_CHARTS_URL = "https://cdn.zuora.com/@anjuna/charts@#{ANJUNA_VERSION}/anjuna-charts/anjuna-charts.js"

    def zuo_include_tag
      anjuna_core + anjuna_charts + anjuna_theme
    end

    private

    def to_esm(url)
      url.gsub('.js', '.esm.js')
    end

    # NOTE(hartley): nomodule was added as an explict boolean attribute in Rails
    # 6.1, meaning 'nomodule: true' should be used once minimum version is 6.1
    # However, for consistency with older versions we have to specify 'nomodule'
    # as the value
    def anjuna_core
      tag.script(type: 'module', src: to_esm(ANJUNA_CORE_URL)) +
        tag.script(nomodule: 'nomodule', src: ANJUNA_CORE_URL)
    end

    def anjuna_charts
      tag.script(type: 'module', src: to_esm(ANJUNA_CHARTS_URL)) +
        tag.script(nomodule: 'nomodule', src: ANJUNA_CHARTS_URL)
    end

    def anjuna_theme
      tag.link(href: anjuna_theme_url('application'), rel: 'stylesheet') +
        tag.link(href: anjuna_theme_url('theme'), rel: 'stylesheet') +
        tag.link(href: anjuna_theme_url('icons'), rel: 'stylesheet')
    end

    def anjuna_theme_url(file)
      "https://cdn.zuora.com/@anjuna/theme@#{ANJUNA_VERSION}/css/#{file}.css"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zuora_connect_ui-0.12.3 app/helpers/zuora_connect_ui/asset_helper.rb
zuora_connect_ui-0.12.2 app/helpers/zuora_connect_ui/asset_helper.rb
zuora_connect_ui-0.12.1 app/helpers/zuora_connect_ui/asset_helper.rb
zuora_connect_ui-0.12.0 app/helpers/zuora_connect_ui/asset_helper.rb