playbook_ui 13.9.0.pre.alpha.play845addswiftkitspage1273 → 13.9.0.pre.alpha.play845allkitsbytypes1260

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: 53d50d860e7e9adef5fe334a04cc9280520dfb37b2aa95b5cf4bf9b9fee90989
4
- data.tar.gz: 345e49952640f1be1926287cca5a6ad843041ff595ee66af344f60458d15662e
3
+ metadata.gz: e47bda24af6edbc23255faea9e74418ea82ec02ecafbcce245aca51ead067eb8
4
+ data.tar.gz: 7a6417c7fded6d9f5117ed28bcb7207a7d9d286611140aa9d82db0879f91cec6
5
5
  SHA512:
6
- metadata.gz: f085b7eeb92a0f525177f4a8f9f0b74740dda58ad287636fbe99df49e876fa5d1cd02c217653e304ae253cdc7576ed44f875ebdcfeb13c889a3b7dd8743e8022
7
- data.tar.gz: c6ce954df39ae04e270f2ecd1917ad611b481c66e1d346e24ed9853a2ea543190ff4f91f08e8721c8b71b50f85a652c0450867b39542911dd10d0f4963be25dd
6
+ metadata.gz: 0a40703a2cbcc0e1fc98ee91a0ba73d219ce1f8172975022c722c3ca425d005a8a05bd3f7290c3bf558a036a53b82a32ea89bad388e5338af9424c66c4ff07ce
7
+ data.tar.gz: f0275c462194c5c2db72f027a0e7347cf423e72e50e1004b6e65fe2b10962b993c3cc88e534e87a4ebeee7778f20abace8b3c2ec42e8dcfbdabd1e5512f0ce24
@@ -26,28 +26,28 @@ module Playbook
26
26
  end
27
27
 
28
28
  # Deal with lists of kits, used in Playbook doc and Externally
29
- # rubocop:disable Style/StringConcatenation
30
- def pb_kits(type: "rails", limit_examples: false, dark_mode: false, method: get_kits)
31
- display_kits = []
32
- kits = method
33
- kits.each do |kit|
34
- if kit.is_a?(Hash)
35
- nav_hash_array(kit).each do |sub_kit|
36
- display_kits << render_pb_doc_kit(sub_kit, type, limit_examples, false, dark_mode)
37
- end
38
- else
39
- display_kits << render_pb_doc_kit(kit, type, limit_examples, false, dark_mode)
40
- end
29
+ def pb_kits(type: "rails", limit_examples: false, dark_mode: false)
30
+ kits = get_kits(type)
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
36
+ end
37
+
38
+ def get_kits(type = "rails")
39
+ kits = YAML.load_file(Playbook::Engine.root.join("dist/menu.yml")) || []
40
+
41
+ # Filter kits that have at least one component compatible with the type
42
+ kits["kits"].select do |kit|
43
+ kit["components"].any? { |component| component["platforms"].include?(type) }
41
44
  end
42
- raw("<div class='pb--docItem'>" + display_kits.join("</div><div class='pb--docItem'>") + "</div>")
43
45
  end
44
- # rubocop:enable Style/StringConcatenation
45
46
 
46
- # rubocop:disable Naming/AccessorMethodName
47
- def get_kits
48
- menu = YAML.load_file(Playbook::Engine.root.join("dist/menu.yml"))
47
+ def aggregate_kits
49
48
  all_kits = []
50
- menu["kits"].each do |kit|
49
+
50
+ YAML.load_file(Playbook::Engine.root.join("dist/menu.yml"))["kits"].each do |kit|
51
51
  kit_name = kit["name"]
52
52
  components = kit["components"].map { |c| c["name"] }
53
53
 
@@ -57,22 +57,44 @@ module Playbook
57
57
  { kit_name => components }
58
58
  end
59
59
  end
60
- all_kits
61
- end
62
60
 
63
- def get_kits_pb_website
64
- menu = YAML.load_file(Rails.root.join("config/menu.yml"))
65
- menu["kits"]
61
+ all_kits
66
62
  end
67
- # rubocop:enable Naming/AccessorMethodName
68
63
 
69
64
  # rubocop:disable Style/OptionalBooleanParameter
70
- def render_pb_doc_kit(kit, type, limit_examples, code = true, dark_mode = false)
71
- title = pb_doc_render_clickable_title(kit, type)
72
- ui = raw("<div class='pb--docItem-ui'>
73
- #{pb_kit(kit: kit, type: type, show_code: code, limit_examples: limit_examples, dark_mode: dark_mode)}</div>")
74
- title + ui
65
+ def render_pb_doc_kit(kit_name, type, limit_examples, code = true, dark_mode = false)
66
+ parent_kit = YAML.load_file(Playbook::Engine.root.join("dist/menu.yml"))["kits"].find { |kit| kit["name"] == kit_name }
67
+
68
+ # Initialize component_content as an empty string
69
+ component_content = ""
70
+
71
+ # Check if parent_kit is not nil
72
+ # Check if type is not "swift"
73
+ if parent_kit && type != "swift"
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
+ end
93
+
94
+ # Return the component_content
95
+ component_content.to_s
75
96
  end
97
+
76
98
  # rubocop:enable Style/OptionalBooleanParameter
77
99
 
78
100
  private
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Playbook
4
4
  PREVIOUS_VERSION = "13.9.0"
5
- VERSION = "13.9.0.pre.alpha.play845addswiftkitspage1273"
5
+ VERSION = "13.9.0.pre.alpha.play845allkitsbytypes1260"
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.play845addswiftkitspage1273
4
+ version: 13.9.0.pre.alpha.play845allkitsbytypes1260
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-10-06 00:00:00.000000000 Z
12
+ date: 2023-10-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack