Sha256: ab982b931215fa76a96838afb7b984f76c53e728731c7d4ec66b206f90ef0a4c

Contents?: true

Size: 428 Bytes

Versions: 2

Compression:

Stored size: 428 Bytes

Contents

json.type facet.type
json.name facet.name
json.display_name facet.display_name

json.results facet.results do |name, count|
  json.name name
  json.count count

  @swatches_cache ||= Workarea::Catalog::Swatch.all.to_a
  swatch = @swatches_cache.detect { |s| s.id == name.systemize }

  if swatch&.image?
    json.swatch_image swatch.image.process(:facet_swatch).url
  elsif swatch&.hex?
    json.swatch_hex swatch.hex
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-swatches-1.0.6 app/views/workarea/api/storefront/facets/_swatches.json.jbuilder
workarea-swatches-1.0.5 app/views/workarea/api/storefront/facets/_swatches.json.jbuilder