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 +4 -4
- data/lib/playbook/pb_doc_helper.rb +24 -39
- data/lib/playbook/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5ef9474deca298344d2c388497f4a090ced68f56944c2f73e894b68ba08aa82
|
4
|
+
data.tar.gz: 5d0f76105a845c36e6cc2d23e2e00b7a0bf85a0e1a93ec9ecdb9304ddc652f54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
#
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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
|
-
|
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
|
115
|
+
puts "Kit Path Not Available"
|
131
116
|
end
|
132
|
-
render inline: "<a href='#{url}'>#{pb_rails(:title, props: { text: pb_kit_title(
|
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
|
data/lib/playbook/version.rb
CHANGED