playbook_ui 13.9.0.pre.alpha.play845allkitsbytypes1263 → 13.9.0.pre.alpha.play845allkitsbytypes1266
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 +27 -45
- 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: dd75764f72b4bb2917191a2c207c70b5d15a693fddfdfa22ceecaaba99612e53
|
4
|
+
data.tar.gz: 312b4da9ec9808ad0288fd4ab4e89631160146e661dd06f2e44cff1db29f236a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3cb3ac2786b777f5b619e44b2ccb3a9fcefcde3c30823d8228f823974b597dc8b4bd20374c7c62d6d2969917a82195d36d257074c6eac73c2642f79ce2ec152
|
7
|
+
data.tar.gz: b1d30a2524cdda08af688d5b2546ab3136e31beda614af2792b6c08c551e684c1d4844fb5796b9e37a10107b59acc4f2f1a9cab6f0de442ef5f17b37efe0b00c
|
@@ -2,15 +2,14 @@
|
|
2
2
|
|
3
3
|
module Playbook
|
4
4
|
module PbDocHelper
|
5
|
-
def render_markdown(text)
|
6
|
-
PlaybookWebsite::Markdown::Helper.markdown(text)
|
7
|
-
end
|
8
|
-
|
9
5
|
def pb_kit_title(title)
|
10
6
|
title.remove("pb_").titleize.tr("_", " ")
|
11
7
|
end
|
12
8
|
|
13
9
|
def pb_kit(kit: "", type: "rails", show_code: true, limit_examples: false, dark_mode: false)
|
10
|
+
# Check if the type is "swift" and return an empty string if it is
|
11
|
+
return "" if type == "swift"
|
12
|
+
|
14
13
|
examples = pb_doc_kit_examples(kit, type)
|
15
14
|
examples = examples.first(1) if limit_examples
|
16
15
|
examples.map do |example|
|
@@ -25,18 +24,23 @@ module Playbook
|
|
25
24
|
end.join.yield_self(&method(:raw))
|
26
25
|
end
|
27
26
|
|
28
|
-
def nav_hash_array(link)
|
29
|
-
link.first.last
|
30
|
-
end
|
31
|
-
|
32
27
|
# Deal with lists of kits, used in Playbook doc and Externally
|
33
28
|
def pb_kits(type: "rails", limit_examples: false, dark_mode: false)
|
34
29
|
kits = get_kits(type)
|
35
30
|
|
36
|
-
#
|
37
|
-
|
38
|
-
|
39
|
-
|
31
|
+
# Initialize an empty string to store the rendered HTML
|
32
|
+
rendered_html = ""
|
33
|
+
|
34
|
+
# Iterate through the filtered kits and render their child components
|
35
|
+
kits.each do |kit|
|
36
|
+
kit["components"].each do |component|
|
37
|
+
# Check if the component is compatible with the specified type
|
38
|
+
rendered_html += render_pb_doc_kit(component["name"], type, limit_examples, true, dark_mode) if component["platforms"].include?(type)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Return the rendered HTML as safe HTML
|
43
|
+
rendered_html.html_safe
|
40
44
|
end
|
41
45
|
|
42
46
|
def get_kits(type = "rails")
|
@@ -67,33 +71,10 @@ module Playbook
|
|
67
71
|
|
68
72
|
# rubocop:disable Style/OptionalBooleanParameter
|
69
73
|
def render_pb_doc_kit(kit_name, type, limit_examples, code = true, dark_mode = false)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
# Check if parent_kit is not nil
|
76
|
-
# Filter components based on the specified type
|
77
|
-
components = parent_kit["components"].select { |component| component["platforms"].include?(type) }
|
78
|
-
|
79
|
-
# If it's a parent with components, accumulate the UI content for child components
|
80
|
-
if components.any?
|
81
|
-
component_content = components.map do |component|
|
82
|
-
component_name = component["name"]
|
83
|
-
title = pb_doc_render_clickable_title(component_name, type) # Use component_name for the title
|
84
|
-
|
85
|
-
# Render the component UI content with the same styles/tags as the parent
|
86
|
-
component_ui = raw("<div class='pb--docItem-ui'>
|
87
|
-
#{pb_kit(kit: component_name, type: type, show_code: code, limit_examples: limit_examples, dark_mode: dark_mode)}
|
88
|
-
</div>")
|
89
|
-
|
90
|
-
# Combine the component name and component UI content
|
91
|
-
"#{title}#{component_ui}"
|
92
|
-
end.join.to_s
|
93
|
-
end
|
94
|
-
|
95
|
-
# Return the component_content
|
96
|
-
component_content.to_s
|
74
|
+
title = pb_doc_render_clickable_title(kit_name, type)
|
75
|
+
ui = raw("<div class='pb--docItem-ui'>
|
76
|
+
#{pb_kit(kit: kit_name, type: type, show_code: code, limit_examples: limit_examples, dark_mode: dark_mode)}</div>")
|
77
|
+
title + ui
|
97
78
|
end
|
98
79
|
|
99
80
|
# rubocop:enable Style/OptionalBooleanParameter
|
@@ -115,23 +96,24 @@ module Playbook
|
|
115
96
|
end
|
116
97
|
end
|
117
98
|
|
118
|
-
|
99
|
+
# Modify the method to accept kit_name
|
100
|
+
def pb_doc_render_clickable_title(kit_name, type)
|
119
101
|
url = "#"
|
120
102
|
begin
|
121
103
|
url = case type
|
122
104
|
when "react"
|
123
|
-
kit_show_reacts_path(kit
|
105
|
+
kit_show_reacts_path(kit_name) # Use kit_name instead of kit
|
124
106
|
when "swift"
|
125
|
-
kit_show_swift_path(kit
|
107
|
+
kit_show_swift_path(kit_name) # Use kit_name instead of kit
|
126
108
|
else
|
127
|
-
kit_show_path(kit
|
109
|
+
kit_show_path(kit_name) # Use kit_name instead of kit
|
128
110
|
end
|
129
111
|
# FIXME: this is here because this helper generates a link for playbook website,
|
130
112
|
# but shouldn't do anything when used elsewhere
|
131
113
|
rescue
|
132
|
-
puts "Kit Path Not
|
114
|
+
puts "Kit Path Not Available"
|
133
115
|
end
|
134
|
-
render inline: "<a href='#{url}'>#{pb_rails(:title, props: { text: pb_kit_title(
|
116
|
+
render inline: "<a href='#{url}'>#{pb_rails(:title, props: { text: pb_kit_title(kit_name), tag: 'h3', size: 2 })}</a>"
|
135
117
|
end
|
136
118
|
end
|
137
119
|
end
|
data/lib/playbook/version.rb
CHANGED