playbook-ui 13.18.0-alpha.useexactnodejsversionghactions2183 → 13.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,102 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PlaybookWebsite
4
- module PbDocHelper
5
- def pb_kit_title(title)
6
- title.remove("pb_").titleize.tr("_", " ")
7
- end
8
-
9
- def pb_kit(kit: "", type: "rails", show_code: true, limit_examples: false, dark_mode: false)
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))
22
- end
23
-
24
- def nav_hash_array(link)
25
- link.first.last
26
- end
27
-
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[:name], type, limit_examples, false, dark_mode) if sub_kit[:status] != "beta" && pb_doc_has_kit_type?(sub_kit[:name], type)
37
- end
38
- elsif pb_doc_has_kit_type?(kit, type)
39
- display_kits << render_pb_doc_kit(kit, type, limit_examples, false, dark_mode)
40
- end
41
- end
42
- raw("<div class='pb--docItem'>" + display_kits.join("</div><div class='pb--docItem'>") + "</div>")
43
- end
44
- # rubocop:enable Style/StringConcatenation
45
-
46
- # rubocop:disable Naming/AccessorMethodName
47
- def get_kits(_type = "rails")
48
- aggregate_kits_with_status || []
49
- end
50
-
51
- def get_kits_pb_website
52
- menu = YAML.load_file(Rails.root.join("config/menu.yml"))
53
- menu["kits"]
54
- end
55
- # rubocop:enable Naming/AccessorMethodName
56
-
57
- # rubocop:disable Style/OptionalBooleanParameter
58
- def render_pb_doc_kit(kit, type, limit_examples, code = true, dark_mode = false)
59
- title = pb_doc_render_clickable_title(kit, type)
60
- ui = raw("<div class='pb--docItem-ui'>
61
- #{pb_kit(kit: kit, type: type, show_code: code, limit_examples: limit_examples, dark_mode: dark_mode)}</div>")
62
- title + ui
63
- end
64
- # rubocop:enable Style/OptionalBooleanParameter
65
-
66
- private
67
-
68
- def pb_doc_kit_path(kit, *args)
69
- Playbook.kit_path(kit, "docs", *args)
70
- end
71
-
72
- def pb_doc_kit_examples(kit, type)
73
- example_file = pb_doc_kit_path(kit, "example.yml")
74
- if File.exist?(example_file)
75
- examples_list = YAML.load_file(example_file)
76
- .inject({}) { |item, (k, v)| item[k.to_sym] = v; item }
77
- examples_list.dig(:examples, type) || []
78
- else
79
- []
80
- end
81
- end
82
-
83
- def pb_doc_render_clickable_title(kit, type)
84
- url = "#"
85
- begin
86
- url = case type
87
- when "react"
88
- kit_show_reacts_path(kit)
89
- when "swift"
90
- kit_show_swift_path(kit)
91
- else
92
- kit_show_path(kit)
93
- end
94
- # FIXME: this is here because this helper generates a link for playbook website,
95
- # but shouldn't do anything when used elsewhere
96
- rescue
97
- puts "Kit Path Not Avaliable"
98
- end
99
- render inline: "<a href='#{url}'>#{pb_rails(:title, props: { text: pb_kit_title(kit), tag: 'h3', size: 2 })}</a>"
100
- end
101
- end
102
- end