playbook_ui_docs 13.29.0.pre.alpha.PBNTR329draggablev33060 → 13.29.0.pre.alpha.removeduplicatekitexampleclass3063

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui_docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.29.0.pre.alpha.PBNTR329draggablev33060
4
+ version: 13.29.0.pre.alpha.removeduplicatekitexampleclass3063
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -1893,7 +1893,6 @@ files:
1893
1893
  - dist/app/components/playbook/pb_docs/kit_api.html.erb
1894
1894
  - dist/app/components/playbook/pb_docs/kit_api.rb
1895
1895
  - dist/app/components/playbook/pb_docs/kit_example.html.erb
1896
- - dist/app/components/playbook/pb_docs/kit_example.rb
1897
1896
  - dist/menu.yml
1898
1897
  - dist/pb_doc_helper.rb
1899
1898
  - dist/playbook-doc.js
@@ -1,78 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # rubocop:disable Style/CaseLikeIf
4
- module Playbook
5
- module PbDocs
6
- class KitExample < Playbook::KitBase
7
- prop :kit, type: Playbook::Props::String, required: true
8
- prop :example_title, type: Playbook::Props::String, required: true
9
- prop :example_key, type: Playbook::Props::String, required: true
10
- prop :show_code, type: Playbook::Props::Boolean, default: true
11
- prop :type, type: Playbook::Props::Enum, values: %w[rails react swift], default: "rails"
12
- prop :dark, type: Playbook::Props::Boolean, default: false
13
-
14
- include PlaybookWebsite::Markdown::Helper
15
-
16
- def example
17
- if type == "rails"
18
- render inline: source
19
- elsif type == "react"
20
- react_component example_key.camelize, { dark: dark }
21
- elsif type == "swift"
22
- ## render the markdown file
23
- render inline: source
24
- end
25
- end
26
-
27
- def description
28
- @description ||= read_kit_file("docs", "_#{example_key}.md")
29
- end
30
-
31
- def highlighter
32
- type.eql?("rails") ? "erb" : "react"
33
- end
34
-
35
- def source
36
- @source ||= begin
37
- extension = if type == "rails"
38
- "html.erb"
39
- else
40
- type == "swift" ? "swift" : "jsx"
41
- end
42
- stringified_code = read_kit_file("docs", "_#{example_key}.#{extension}")
43
- sanitize_code(stringified_code)
44
- end
45
- end
46
-
47
- def tsx_source
48
- read_kit_file("", "_#{example_key}.tsx")
49
- end
50
-
51
- private
52
-
53
- def sanitize_code(stringified_code)
54
- stringified_code = stringified_code.gsub('"../.."', '"playbook-ui"')
55
- .gsub('"../../"', '"playbook-ui"')
56
- .gsub("'../../'", "'playbook-ui'")
57
- .gsub("'../..'", "'playbook-ui'")
58
- .gsub(%r{from "../.*}, "from 'playbook-ui'")
59
- .gsub(%r{from '../.*}, "from 'playbook-ui'")
60
- .gsub("'../../../../../../playbook-website/app/javascript/scripts/custom-icons'", "'your-directory/custom-icons.js'")
61
- stringified_code = dark ? stringified_code.gsub("{...props}", "dark") : stringified_code.gsub(/\s*{...props}\s*\n/, "\n")
62
- if stringified_code.include?("props: { ")
63
- stringified_code = stringified_code.gsub("props: {", "props: {dark: true,") if type == "rails" && dark
64
- elsif type == "rails" && dark
65
- stringified_code = stringified_code.gsub("props: {", "props: {\n dark: true,")
66
- end
67
- stringified_code.gsub(" {...props}", "")
68
- end
69
-
70
- def read_kit_file(folder, *args)
71
- path = ::Playbook.kit_path(kit, folder, *args)
72
- path.exist? ? path.read : ""
73
- end
74
- end
75
- end
76
- end
77
-
78
- # rubocop:enable Style/CaseLikeIf