playbook_ui 13.9.0.pre.alpha.play845allkitsbytypes1262 → 13.9.0.pre.alpha.play845allkitsbytypes1264

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4efefad3fac932098f8436a5ba32e7949aa5aaa5bb9aef4d876ad35ddec3f25
4
- data.tar.gz: 456d83d00606bee916bce37e4a358985db6c234200e6e71465204b4317f18ba3
3
+ metadata.gz: b5ef9474deca298344d2c388497f4a090ced68f56944c2f73e894b68ba08aa82
4
+ data.tar.gz: 5d0f76105a845c36e6cc2d23e2e00b7a0bf85a0e1a93ec9ecdb9304ddc652f54
5
5
  SHA512:
6
- metadata.gz: e1c9517925cac47db7868497da8792b01b7acd6542b6ee9b2aef3880241acc1f62efc356fe47e6f3a72d6f1e4f102dbeb827782ea84fc48b93b99a0d07034a94
7
- data.tar.gz: 9a0df5e8ec261a2d26ec5a6686529c8e5f7688b739e5cf751350567e531782645b47507bb7a4734f9fe2bc09526fb633dbb7009f0cd17a434f20e48bdce2c2ba
6
+ metadata.gz: 76c46a6dd52917b5a6e794efc19c1c466a9203902a6c8d3e7660c3e72301c77d895102ebf75d7ab540ddcb4b45558255bec6d69b142ea60dde03f22e2c69309d
7
+ data.tar.gz: 48304dce687cc1791dfe7bbd7d62a428d6cb65844d6b7386a7a2e379d0b5c933277a66064353da8e49a3f45fd5b5d87022ff546e761ccccfc41b1f8ce699e403
@@ -29,15 +29,22 @@ module Playbook
29
29
  def pb_kits(type: "rails", limit_examples: false, dark_mode: false)
30
30
  kits = get_kits(type)
31
31
 
32
- # Iterate through the filtered kits and render them
33
- kits.map do |kit|
34
- render_pb_doc_kit(kit["name"], type, limit_examples, true, dark_mode)
35
- end.join.html_safe
32
+ # Initialize an empty string to store the rendered HTML
33
+ rendered_html = ""
34
+
35
+ # Iterate through the filtered kits and render their child components
36
+ kits.each do |kit|
37
+ kit["components"].each do |component|
38
+ # Check if the component is compatible with the specified type
39
+ rendered_html += render_pb_doc_kit(component["name"], type, limit_examples, true, dark_mode) if component["platforms"].include?(type)
40
+ end
41
+ end
42
+
43
+ # Return the rendered HTML as safe HTML
44
+ rendered_html.html_safe
36
45
  end
37
46
 
38
47
  def get_kits(type = "rails")
39
- return [] if type == "swift"
40
-
41
48
  kits = YAML.load_file(Playbook::Engine.root.join("dist/menu.yml")) || []
42
49
 
43
50
  # Filter kits that have at least one component compatible with the type
@@ -65,33 +72,10 @@ module Playbook
65
72
 
66
73
  # rubocop:disable Style/OptionalBooleanParameter
67
74
  def render_pb_doc_kit(kit_name, type, limit_examples, code = true, dark_mode = false)
68
- parent_kit = YAML.load_file(Playbook::Engine.root.join("dist/menu.yml"))["kits"].find { |kit| kit["name"] == kit_name }
69
-
70
- # Initialize component_content as an empty string
71
- component_content = ""
72
-
73
- # Check if parent_kit is not nil
74
- # Filter components based on the specified type
75
- components = parent_kit["components"].select { |component| component["platforms"].include?(type) }
76
-
77
- # If it's a parent with components, accumulate the UI content for child components
78
- if components.any?
79
- component_content = components.map do |component|
80
- component_name = component["name"]
81
- title = pb_doc_render_clickable_title(component_name, type) # Use component_name for the title
82
-
83
- # Render the component UI content with the same styles/tags as the parent
84
- component_ui = raw("<div class='pb--docItem-ui'>
85
- #{pb_kit(kit: component_name, type: type, show_code: code, limit_examples: limit_examples, dark_mode: dark_mode)}
86
- </div>")
87
-
88
- # Combine the component name and component UI content
89
- "#{title}#{component_ui}"
90
- end.join.to_s
91
- end
92
-
93
- # Return the component_content
94
- component_content.to_s
75
+ title = pb_doc_render_clickable_title(kit_name, type)
76
+ ui = raw("<div class='pb--docItem-ui'>
77
+ #{pb_kit(kit: kit_name, type: type, show_code: code, limit_examples: limit_examples, dark_mode: dark_mode)}</div>")
78
+ title + ui
95
79
  end
96
80
 
97
81
  # rubocop:enable Style/OptionalBooleanParameter
@@ -113,23 +97,24 @@ module Playbook
113
97
  end
114
98
  end
115
99
 
116
- def pb_doc_render_clickable_title(kit, type)
100
+ # Modify the method to accept kit_name
101
+ def pb_doc_render_clickable_title(kit_name, type)
117
102
  url = "#"
118
103
  begin
119
104
  url = case type
120
105
  when "react"
121
- kit_show_reacts_path(kit)
106
+ kit_show_reacts_path(kit_name) # Use kit_name instead of kit
122
107
  when "swift"
123
- kit_show_swift_path(kit)
108
+ kit_show_swift_path(kit_name) # Use kit_name instead of kit
124
109
  else
125
- kit_show_path(kit)
110
+ kit_show_path(kit_name) # Use kit_name instead of kit
126
111
  end
127
112
  # FIXME: this is here because this helper generates a link for playbook website,
128
113
  # but shouldn't do anything when used elsewhere
129
114
  rescue
130
- puts "Kit Path Not Avaliable"
115
+ puts "Kit Path Not Available"
131
116
  end
132
- render inline: "<a href='#{url}'>#{pb_rails(:title, props: { text: pb_kit_title(kit), tag: 'h3', size: 2 })}</a>"
117
+ render inline: "<a href='#{url}'>#{pb_rails(:title, props: { text: pb_kit_title(kit_name), tag: 'h3', size: 2 })}</a>"
133
118
  end
134
119
  end
135
120
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Playbook
4
4
  PREVIOUS_VERSION = "13.9.0"
5
- VERSION = "13.9.0.pre.alpha.play845allkitsbytypes1262"
5
+ VERSION = "13.9.0.pre.alpha.play845allkitsbytypes1264"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.9.0.pre.alpha.play845allkitsbytypes1262
4
+ version: 13.9.0.pre.alpha.play845allkitsbytypes1264
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX