Module: Primer::Static::GenerateFormPreviews
- Defined in:
- lib/primer/static/generate_form_previews.rb
Overview
:nodoc:
Class Method Summary collapse
Class Method Details
.call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/primer/static/generate_form_previews.rb', line 12 def call Lookbook.previews.filter_map do |preview| next unless preview.preview_class == Primer::FormsPreview { name: preview.name, lookup_path: preview.lookup_path, examples: preview.scenarios.flat_map do |parent_scenario| scenarios = parent_scenario.type == :scenario_group ? parent_scenario.scenarios : [parent_scenario] scenarios.map do |scenario| snapshot_tag = scenario..find { |tag| tag.tag_name == "snapshot" } snapshot = if snapshot_tag.nil? "false" elsif snapshot_tag.text.blank? "true" else snapshot_tag.text end { preview_path: scenario.lookup_path, name: scenario.name, snapshot: snapshot } end end } end end |