playbook_ui 12.23.0.pre.alpha.movemarkdown712 → 12.23.0.pre.alpha.play698responsivespacingglobalprop701

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "redcarpet"
4
+ require "rouge"
5
+ require "rouge/plugins/redcarpet"
6
+ require "action_view"
7
+
8
+ module Playbook
9
+ module Markdown
10
+ module Helper
11
+ def self.call(template, _source)
12
+ markdown(template.source)
13
+ end
14
+
15
+ def render_markdown(text)
16
+ # rubocop:disable Security/Eval
17
+ eval(Playbook::Markdown::Helper.markdown(text))
18
+ # rubocop:enable Security/Eval
19
+ end
20
+
21
+ def self.markdown(text)
22
+ options = {
23
+ filter_html: false,
24
+ hard_wrap: true,
25
+ link_attributes: { rel: "nofollow", target: "_blank" },
26
+ space_after_headers: true,
27
+ fenced_code_blocks: true,
28
+ no_styles: false,
29
+ safe_links_only: true,
30
+ }
31
+
32
+ extensions = {
33
+ lax_spacing: true,
34
+ no_intra_emphasis: true,
35
+ autolink: true,
36
+ superscript: true,
37
+ fenced_code_blocks: true,
38
+ tables: true,
39
+ disable_indented_code_blocks: false,
40
+ strikethrough: true,
41
+ underline: true,
42
+ highlight: true,
43
+ footnotes: true,
44
+ with_toc_data: true,
45
+ }
46
+
47
+ renderer = HTMLBlockCode.new(options)
48
+ # toc_renderer = Redcarpet::Render::HTML_TOC.new(with_toc_data: true)
49
+ # @TOC = Redcarpet::Markdown.new(toc_renderer)
50
+ # puts "TOC: #{@TOC.inspect}"
51
+ markdown = Redcarpet::Markdown.new(renderer, extensions)
52
+ "#{markdown.render(text).inspect}.html_safe;"
53
+ end
54
+
55
+ def rouge(text, language)
56
+ formatter = Rouge::Formatters::HTML.new(scope: ".highlight")
57
+ lexer = Rouge::Lexer.find(language)
58
+ formatter.format(lexer.lex(text))
59
+ end
60
+
61
+ class HTML < Redcarpet::Render::HTML
62
+ include Rouge::Plugins::Redcarpet
63
+ end
64
+
65
+ def rouge_markdown(text)
66
+ render_options = {
67
+ filter_html: true,
68
+ hard_wrap: true,
69
+ link_attributes: { rel: "nofollow" },
70
+ }
71
+ renderer = HTML.new(render_options)
72
+
73
+ extensions = {
74
+ autolink: true,
75
+ fenced_code_blocks: true,
76
+ lax_spacing: true,
77
+ no_intra_emphasis: true,
78
+ strikethrough: true,
79
+ superscript: true,
80
+ }
81
+ markdown = Redcarpet::Markdown.new(renderer, extensions)
82
+ markdown.render(text)
83
+ end
84
+ end
85
+
86
+ class HTMLWithPants < Redcarpet::Render::HTML
87
+ include Redcarpet::Render::SmartyPants
88
+ end
89
+
90
+ class HTML < Redcarpet::Render::HTML
91
+ include Rouge::Plugins::Redcarpet
92
+ end
93
+
94
+ class HTMLBlockCode < Redcarpet::Render::HTML
95
+ include ActionView::Helpers::AssetTagHelper
96
+
97
+ # def block_code(code, language)
98
+ # "\n.nf\n#{normal_text(rouge(code, language))}\n.fi\n"
99
+ # end
100
+
101
+ def table(header, body)
102
+ "<table class='pb_table table-sm table-responsive-collapse table-card table-collapse-sm'>" \
103
+ "<thead>#{header}</thead>" \
104
+ "<tbody>#{body}</tbody>" \
105
+ "</table>"
106
+ end
107
+
108
+ def header(title, level)
109
+ @headers ||= []
110
+ permalink = title.gsub(/\W+/, "-")
111
+ if @headers.include?(permalink)
112
+ permalink += "_1"
113
+ loop do
114
+ break unless @headers.include?(permalink)
115
+
116
+ permalink.gsub!(/_(\d+)$/, "_#{Regexp.last_match(1).to_i + 1}")
117
+ end
118
+ end
119
+ @headers << permalink
120
+ permalink_markup = %(<a name="#{permalink}" class="markdown-header-anchor" )
121
+ permalink_markup += %(href="##{permalink}"><span class="far fa-link markdown-header-anchor-icon"></span></a>)
122
+ %(\n<h#{level} id="#{permalink}">#{title} #{permalink_markup}</h#{level}>\n)
123
+ end
124
+
125
+ def image(link, title, alt_text)
126
+ return nil if link.nil?
127
+
128
+ %(<a href="#{link}" target="_blank">#{image_tag(link, title: title, alt: alt_text, class: 'imageloader lazyload')}</a>)
129
+ end
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "playbook/markdown/helper"
@@ -50,17 +50,32 @@ module Playbook
50
50
  end
51
51
 
52
52
  def spacing_values
53
- %w[none xxs xs sm md lg xl]
53
+ %w[none xxs xs sm md lg xl auto initial inherit]
54
+ end
55
+
56
+ def screen_size_values
57
+ %w[xs sm md lg xl]
54
58
  end
55
59
 
56
60
  def spacing_props
57
61
  selected_props = spacing_options.keys.select { |sk| try(sk) }
58
62
  return nil unless selected_props.present?
59
63
 
60
- selected_props.map do |k|
61
- spacing_value = send(k)
62
- "#{spacing_options[k]}_#{spacing_value}" if spacing_values.include? spacing_value
63
- end.compact.join(" ")
64
+ responsive = selected_props.present? && try(selected_props.first).is_a?(::Hash)
65
+ css = ""
66
+ selected_props.each do |prop|
67
+ spacing_value = send(prop)
68
+ prefix = spacing_options[prop]
69
+ if responsive
70
+ spacing_value.each do |key, value|
71
+ css += "#{prefix}_#{key}_#{value} " if screen_size_values.include?(key.to_s) && spacing_values.include?(value.to_s)
72
+ end
73
+ elsif spacing_values.include?(spacing_value)
74
+ css += "#{prefix}_#{spacing_value} "
75
+ end
76
+ end
77
+
78
+ css.strip unless css.blank?
64
79
  end
65
80
 
66
81
  def max_width_props
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Playbook
4
4
  PREVIOUS_VERSION = "12.23.0"
5
- VERSION = "12.23.0.pre.alpha.movemarkdown712"
5
+ VERSION = "12.23.0.pre.alpha.play698responsivespacingglobalprop701"
6
6
  end
data/lib/playbook.rb CHANGED
@@ -8,9 +8,10 @@ require "playbook/props"
8
8
  require "playbook/forms"
9
9
  require "playbook/pb_forms_helper"
10
10
  require "playbook/pb_kit_helper"
11
- require "playbook/pb_doc_helper" # Duplicated from website (Temp)
11
+ require "playbook/pb_doc_helper"
12
12
  require "playbook/kit_base"
13
13
  require "playbook/kit_resolver"
14
+ require "playbook/markdown"
14
15
 
15
16
  module Playbook
16
17
  ROOT_PATH = Pathname.new(File.join(__dir__, ".."))
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: 12.23.0.pre.alpha.movemarkdown712
4
+ version: 12.23.0.pre.alpha.play698responsivespacingglobalprop701
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-05-25 00:00:00.000000000 Z
12
+ date: 2023-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -67,6 +67,34 @@ dependencies:
67
67
  - - '='
68
68
  - !ruby/object:Gem::Version
69
69
  version: 2.6.1
70
+ - !ruby/object:Gem::Dependency
71
+ name: redcarpet
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '3.6'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '3.6'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rouge
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '3.15'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '3.15'
70
98
  - !ruby/object:Gem::Dependency
71
99
  name: view_component
72
100
  requirement: !ruby/object:Gem::Requirement
@@ -255,9 +283,7 @@ dependencies:
255
283
  - - '='
256
284
  - !ruby/object:Gem::Version
257
285
  version: 3.3.1
258
- description: Playbook UI is built out in Ruby View Components and React Components.
259
- Playbook takes a modern design approach and applies it in a way that makes it easy
260
- to support bleeding edge or legacy systems.
286
+ description: Playbook Design System. Built for Nitro, but powering all.
261
287
  email:
262
288
  - nitroux@powerhrg.com
263
289
  - dev@powerhrg.com
@@ -878,6 +904,8 @@ files:
878
904
  - app/pb_kits/playbook/pb_distribution_bar/docs/_distribution_bar_default.jsx
879
905
  - app/pb_kits/playbook/pb_distribution_bar/docs/example.yml
880
906
  - app/pb_kits/playbook/pb_distribution_bar/docs/index.js
907
+ - app/pb_kits/playbook/pb_docs/kit_api.html.erb
908
+ - app/pb_kits/playbook/pb_docs/kit_api.rb
881
909
  - app/pb_kits/playbook/pb_docs/kit_example.html.erb
882
910
  - app/pb_kits/playbook/pb_docs/kit_example.rb
883
911
  - app/pb_kits/playbook/pb_enhanced_element/element_observer.ts
@@ -2402,7 +2430,6 @@ files:
2402
2430
  - app/pb_kits/playbook/utilities/test/globalProps/order.test.js
2403
2431
  - app/pb_kits/playbook/utilities/text.ts
2404
2432
  - dist/menu.yml
2405
- - dist/playbook-rails.js
2406
2433
  - dist/reset.css
2407
2434
  - lib/playbook.rb
2408
2435
  - lib/playbook/align_content.rb
@@ -2431,6 +2458,8 @@ files:
2431
2458
  - lib/playbook/kit_base.rb
2432
2459
  - lib/playbook/kit_resolver.rb
2433
2460
  - lib/playbook/line_height.rb
2461
+ - lib/playbook/markdown.rb
2462
+ - lib/playbook/markdown/helper.rb
2434
2463
  - lib/playbook/number_spacing.rb
2435
2464
  - lib/playbook/order.rb
2436
2465
  - lib/playbook/pagination_renderer.rb
@@ -2458,7 +2487,7 @@ files:
2458
2487
  - lib/playbook/version.rb
2459
2488
  - lib/playbook/z_index.rb
2460
2489
  - lib/playbook_ui.rb
2461
- homepage: https://playbook.powerapp.cloud/
2490
+ homepage: http://playbook.powerapp.cloud
2462
2491
  licenses:
2463
2492
  - ISC
2464
2493
  metadata: {}