playbook_ui 13.9.0.pre.alpha.play845allkitsbytypes1271 → 13.9.0.pre.alpha.play978makehighchartsadevdependencypoc1292

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,75 +7,61 @@ module Playbook
7
7
  end
8
8
 
9
9
  def pb_kit(kit: "", type: "rails", show_code: true, limit_examples: false, dark_mode: false)
10
- unless type == "swift"
11
- examples = pb_doc_kit_examples(kit, type)
12
- examples = examples.first(1) if limit_examples
13
- examples.map do |example|
14
- pb_rails "docs/kit_example", props: {
15
- kit: kit,
16
- example_title: example.values.first,
17
- example_key: example.keys.first,
18
- show_code: show_code,
19
- type: type,
20
- dark: dark_mode,
21
- }
22
- end.join.yield_self(&method(:raw))
23
- end
10
+ examples = pb_doc_kit_examples(kit, type)
11
+ examples = examples.first(1) if limit_examples
12
+ examples.map do |example|
13
+ pb_rails "docs/kit_example", props: {
14
+ kit: kit,
15
+ example_title: example.values.first,
16
+ example_key: example.keys.first,
17
+ show_code: show_code,
18
+ type: type,
19
+ dark: dark_mode,
20
+ }
21
+ end.join.yield_self(&method(:raw))
24
22
  end
25
23
 
26
- # Deal with lists of kits, used in Playbook doc and Externally
27
- def pb_kits(type: "rails", limit_examples: false, dark_mode: false)
28
- kits = get_kits(type)
29
-
30
- # Initialize an empty string to store the rendered HTML
31
- rendered_html = ""
24
+ def nav_hash_array(link)
25
+ link.first.last
26
+ end
32
27
 
33
- # Iterate through the filtered kits and render their child components
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
34
33
  kits.each do |kit|
35
- kit["components"].each do |component|
36
- # Check if the component is compatible with the specified type
37
- rendered_html += render_pb_doc_kit(component["name"], type, limit_examples, true, dark_mode) if component["platforms"].include?(type)
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)
38
40
  end
39
41
  end
40
-
41
- # Return the rendered HTML as safe HTML
42
- rendered_html.html_safe
42
+ raw("<div class='pb--docItem'>" + display_kits.join("</div><div class='pb--docItem'>") + "</div>")
43
43
  end
44
+ # rubocop:enable Style/StringConcatenation
44
45
 
45
- def get_kits(type = "rails")
46
- kits = YAML.load_file(Playbook::Engine.root.join("dist/menu.yml")) || []
47
-
48
- # Filter kits that have at least one component compatible with the type
49
- kits["kits"].select do |kit|
50
- kit["components"].any? { |component| component["platforms"].include?(type) }
51
- end
46
+ # rubocop:disable Naming/AccessorMethodName
47
+ def get_kits
48
+ menu = YAML.load_file(Playbook::Engine.root.join("dist/menu.yml"))
49
+ menu["kits"]
52
50
  end
53
51
 
54
- def aggregate_kits
55
- all_kits = []
56
-
57
- YAML.load_file(Playbook::Engine.root.join("dist/menu.yml"))["kits"].each do |kit|
58
- kit_name = kit["name"]
59
- components = kit["components"].map { |c| c["name"] }
60
-
61
- all_kits << if components.size == 1
62
- components.first
63
- else
64
- { kit_name => components }
65
- end
66
- end
67
-
68
- all_kits
52
+ def get_kits_pb_website
53
+ menu = YAML.load_file(Rails.root.join("config/menu.yml"))
54
+ menu["kits"]
69
55
  end
56
+ # rubocop:enable Naming/AccessorMethodName
70
57
 
71
58
  # rubocop:disable Style/OptionalBooleanParameter
72
- def render_pb_doc_kit(kit_name, type, limit_examples, code = true, dark_mode = false)
73
- title = pb_doc_render_clickable_title(kit_name, type)
59
+ def render_pb_doc_kit(kit, type, limit_examples, code = true, dark_mode = false)
60
+ title = pb_doc_render_clickable_title(kit, type)
74
61
  ui = raw("<div class='pb--docItem-ui'>
75
- #{pb_kit(kit: kit_name, type: type, show_code: code, limit_examples: limit_examples, dark_mode: dark_mode)}</div>")
62
+ #{pb_kit(kit: kit, type: type, show_code: code, limit_examples: limit_examples, dark_mode: dark_mode)}</div>")
76
63
  title + ui
77
64
  end
78
-
79
65
  # rubocop:enable Style/OptionalBooleanParameter
80
66
 
81
67
  private
@@ -95,24 +81,23 @@ module Playbook
95
81
  end
96
82
  end
97
83
 
98
- # Modify the method to accept kit_name
99
- def pb_doc_render_clickable_title(kit_name, type)
84
+ def pb_doc_render_clickable_title(kit, type)
100
85
  url = "#"
101
86
  begin
102
87
  url = case type
103
88
  when "react"
104
- kit_show_reacts_path(kit_name) # Use kit_name instead of kit
89
+ kit_show_reacts_path(kit)
105
90
  when "swift"
106
- kit_show_swift_path(kit_name) # Use kit_name instead of kit
91
+ kit_show_swift_path(kit)
107
92
  else
108
- kit_show_path(kit_name) # Use kit_name instead of kit
93
+ kit_show_path(kit)
109
94
  end
110
95
  # FIXME: this is here because this helper generates a link for playbook website,
111
96
  # but shouldn't do anything when used elsewhere
112
97
  rescue
113
- puts "Kit Path Not Available"
98
+ puts "Kit Path Not Avaliable"
114
99
  end
115
- render inline: "<a href='#{url}'>#{pb_rails(:title, props: { text: pb_kit_title(kit_name), tag: 'h3', size: 2 })}</a>"
100
+ render inline: "<a href='#{url}'>#{pb_rails(:title, props: { text: pb_kit_title(kit), tag: 'h3', size: 2 })}</a>"
116
101
  end
117
102
  end
118
103
  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.play845allkitsbytypes1271"
5
+ VERSION = "13.9.0.pre.alpha.play978makehighchartsadevdependencypoc1292"
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.play845allkitsbytypes1271
4
+ version: 13.9.0.pre.alpha.play978makehighchartsadevdependencypoc1292
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-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack