Sha256: 018eee2568ccc330c38060e62f9389e6a9935f6baa9ab1bd454ec24bb3ded375

Contents?: true

Size: 507 Bytes

Versions: 1

Compression:

Stored size: 507 Bytes

Contents

# frozen_string_literal: true

require "json"

module TNS
  module Output
    # Output a given color palette as Tailwind JSON.
    class Tailwind
      def initialize(name)
        @name = name
      end

      def format(palette)
        colors = palette.map { |variant| format_variant(variant) }
        JSON.pretty_generate({ @name.to_s => colors.reduce({}, :merge) })
      end

      def format_variant(variant)
        { (variant.index * 100).to_s => variant.to_css.to_s }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tints-n-shades-0.1.0 lib/tns/output/tailwind.rb