Sha256: 115441e468c3740dd6f4b037a618c286433d2f78bffb6059e9f770befa8c0ccb

Contents?: true

Size: 1.31 KB

Versions: 63

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require_relative 'helper'

REPO_URL = 'https://github.com/Remix-Design/RemixIcon.git'
REPO_NAME = 'remix-design-remixicon'
ICONS_PACK_PATH = 'lib/phlex/icons/remix'

TEMPLATE = ERB.new <<~TEMPLATE
  # frozen_string_literal: true

  # rubocop:disable #{ROBOCOP_DISABLE_WARNINGS}
  module Phlex
    module Icons
      module Remix
        class <%= icon_name %> < Base
          def view_template
            <%= icon %>
          end
        end
      end
    end
  end
  # rubocop:enable #{ROBOCOP_DISABLE_WARNINGS}
TEMPLATE

REPLACEMENTS = {
  '4k-' => 'four-k-',
  '24-' => 'twenty-four-'
}.freeze

def main
  run_generator { icon_file_paths.tqdm.each { create_icon_component(_1) } }
end

def icon_file_paths
  Dir.glob("generators/#{REPO_NAME}/icons/**/*.svg")
end

def create_icon_component(icon_file_path)
  File.write(
    File.join(ICONS_PACK_PATH, component_file_name(icon_file_path, REPLACEMENTS)),
    TEMPLATE.result_with_hash(
      icon_name: component_class_name(icon_file_path, REPLACEMENTS),
      icon: read_and_convert_icon(icon_file_path)
    )
  )
end

def read_and_convert_icon(icon_file_path)
  icon_file_content = File.read(icon_file_path)

  Phlexing::Converter.convert(icon_file_content)
                     .sub('svg(', "svg(\nclass: classes,")
end

main if __FILE__ == $PROGRAM_NAME

Version data entries

63 entries across 63 versions & 8 rubygems

Version Path
phlex-icons-flag-0.16.0 generators/remix.rb
phlex-icons-bootstrap-0.16.0 generators/remix.rb
phlex-icons-tabler-0.16.0 generators/remix.rb
phlex-icons-lucide-0.16.0 generators/remix.rb
phlex-icons-0.16.0 generators/remix.rb
phlex-icons-remix-0.16.0 generators/remix.rb
phlex-icons-hero-0.16.0 generators/remix.rb
phlex-icons-radix-0.16.0 generators/remix.rb
phlex-icons-tabler-0.15.0 generators/remix.rb
phlex-icons-flag-0.15.0 generators/remix.rb
phlex-icons-0.15.0 generators/remix.rb
phlex-icons-bootstrap-0.15.0 generators/remix.rb
phlex-icons-remix-0.15.0 generators/remix.rb
phlex-icons-radix-0.15.0 generators/remix.rb
phlex-icons-lucide-0.15.0 generators/remix.rb
phlex-icons-hero-0.15.0 generators/remix.rb
phlex-icons-tabler-0.14.0 generators/remix.rb
phlex-icons-flag-0.14.0 generators/remix.rb
phlex-icons-lucide-0.14.0 generators/remix.rb
phlex-icons-radix-0.14.0 generators/remix.rb