playbook_ui_docs 13.29.0.pre.alpha.removeduplicatekitexampleclass3063 → 13.30.0.pre.alpha.PLAY1328fixtimelinekitglobalpropsreact3096
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_horizontal.html.erb +58 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_horizontal.jsx +68 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.md +1 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers.jsx +8 -7
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers.md +1 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.jsx +13 -32
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.md +3 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.jsx +5 -5
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.md +1 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list.jsx +5 -5
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_default.jsx +40 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_default.md +7 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_multi_directional.jsx +36 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_multi_directional.md +5 -0
- data/app/pb_kits/playbook/pb_overlay/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_overlay/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_column_rails.html.erb +32 -33
- data/dist/app/components/playbook/pb_docs/kit_example.rb +94 -0
- data/dist/menu.yml +5 -1
- data/dist/playbook-doc.js +9 -9
- metadata +13 -2
@@ -0,0 +1,94 @@
|
|
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, file_name)
|
71
|
+
name_array = file_name.split(".")
|
72
|
+
path = ::Playbook.kit_path(kit, folder, file_name)
|
73
|
+
if name_array[1] != "md"
|
74
|
+
(path.exist? ? path.read : "")
|
75
|
+
else
|
76
|
+
if path.exist?
|
77
|
+
path.read
|
78
|
+
elsif type == "rails"
|
79
|
+
name_array[0] += "_rails"
|
80
|
+
file_name = name_array.join(".")
|
81
|
+
path = ::Playbook.kit_path(kit, folder, file_name)
|
82
|
+
elsif type == "react"
|
83
|
+
name_array[0] += "_react"
|
84
|
+
file_name = name_array.join(".")
|
85
|
+
path = ::Playbook.kit_path(kit, folder, file_name)
|
86
|
+
end
|
87
|
+
(path.exist? ? path.read : "")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# rubocop:enable Style/CaseLikeIf
|
data/dist/menu.yml
CHANGED
@@ -352,6 +352,9 @@ kits:
|
|
352
352
|
platforms: *web
|
353
353
|
description:
|
354
354
|
status: "stable"
|
355
|
+
- name: "overlay"
|
356
|
+
platforms: *react_only
|
357
|
+
status: "beta"
|
355
358
|
- name: "draggable"
|
356
359
|
platforms: *react_only
|
357
360
|
description:
|
@@ -467,4 +470,5 @@ kits:
|
|
467
470
|
status: "stable"
|
468
471
|
- name: "user"
|
469
472
|
platforms: *web
|
470
|
-
description: This kit was created for having a systematic way of displaying users with avatar, titles, name and territory. This is a versatile kit with features than can be added to display more info.
|
473
|
+
description: This kit was created for having a systematic way of displaying users with avatar, titles, name and territory. This is a versatile kit with features than can be added to display more info.
|
474
|
+
status: "stable"
|