lookbook 0.9.0 → 0.9.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71adea21d969026f205c494f5ebdfd5b1546a8dce639733da69bf8eeaa7f371d
4
- data.tar.gz: dbd8406a04e3b6be61a97fba2daf96ce1bb005b0c7c0f9bdfc85e7443301d7d1
3
+ metadata.gz: 32c809771b3d81b6622d1624bd3197efb2cc55d825f1543dd444454b18bcd980
4
+ data.tar.gz: 424739885629f6ca7870322a962934abf80cceb0e849e94ebf9284c093044c6a
5
5
  SHA512:
6
- metadata.gz: 4913a862f29674edaa775ed2171b37d80f32a7d57b44efea92ee2901a7a122c2bfd941fe776cbc0338de72f0ed2f63c28f108a04d699e944cf93a03456b376c1
7
- data.tar.gz: f6f914053d0d2db782537180a6193ce24e19641407c156d46ffe48179ca4d60a4d48609b01da58318e4bb8e727ccc86356269f5e96f7746e961516291c771a8e
6
+ metadata.gz: ab5ba4963b759623cbfafdd3270a03f2be2282ffd817466f821dbcc92c36360f72c3766b894b1f1013681392c569479c19263af95bebd1028a0bd2d265117d4a
7
+ data.tar.gz: db263a69c03239c9865aeb068c31c9ba60e475aa5b685a17128599fe5cba2aa0d4b501047a95e9650191bc57557b896328390c24d821e77eff41f51c8923c075
data/README.md CHANGED
@@ -52,7 +52,7 @@ If you'd rather dig in a bit more and run the demo app locally, the [demo repo](
52
52
  Add Lookbook to your `Gemfile` somewhere **after** the ViewComponent gem. For example:
53
53
 
54
54
  ```ruby
55
- gem "view_component", require: "view_component/engine"
55
+ gem "view_component"
56
56
  gem "lookbook"
57
57
  ```
58
58
 
@@ -802,6 +802,14 @@ If you wish to add additional paths to listen for changes in, you can use the `l
802
802
  config.lookbook.listen_paths << Rails.root.join('app/other/directory')
803
803
  ```
804
804
 
805
+ By default Lookbook listens for changes to files with the extensions `rb` and `html.*` (i.e. `.html.erb`).
806
+
807
+ You can add additional extensions by using the `listen_extensions` option:
808
+
809
+ ```ruby
810
+ config.lookbook.listen_extensions = ['js', 'scss'] # Will not overwrite default extensions
811
+ ```
812
+
805
813
  ### Custom favicon
806
814
 
807
815
  If you want to change the favicon used by the Lookbook UI, you can provide a path to your own (or a data-uri string) using the `ui_favicon` option:
@@ -11,7 +11,7 @@ module Lookbook
11
11
  def landing_path
12
12
  landing = feature_enabled?(:pages) ? Lookbook.pages.find(&:landing) || Lookbook.pages.first : nil
13
13
  if landing.present?
14
- page_path(landing.lookup_path)
14
+ lookbook_page_path landing.lookup_path
15
15
  else
16
16
  lookbook_home_path
17
17
  end
@@ -2,6 +2,6 @@
2
2
  name="<%= name %>"
3
3
  class="form-input"
4
4
  x-model="value"
5
- x-data="param('<%= name %>', '<%= value %>')">
5
+ x-data="param('<%= name %>', '<%= j(value) %>')">
6
6
  <%= options_for_select(options, value) %>
7
7
  </select>
@@ -3,6 +3,6 @@
3
3
  type="<%= input_type %>"
4
4
  name="<%= name %>"
5
5
  value="<%= value %>"
6
- x-data="param('<%= name %>', '<%= value %>', {debounce: 300})"
6
+ x-data="param('<%= name %>', '<%= j(value) %>', {debounce: 300})"
7
7
  x-model="value"
8
8
  @keyup.stop>
@@ -4,5 +4,5 @@
4
4
  rows="4"
5
5
  @keyup.stop
6
6
  x-model="value"
7
- x-data="param('<%= name %>', '<%= value %>', {debounce: 300})"
7
+ x-data="param('<%= name %>', '<%= j(value) %>', {debounce: 300})"
8
8
  ><%= value %></textarea>
@@ -1,4 +1,4 @@
1
- <div x-data="param('<%= name %>', <%= value %>)" data-morph-strategy="replace">
1
+ <div x-data="param('<%= name %>', <%= j(value) %>)" data-morph-strategy="replace">
2
2
  <button type="button"
3
3
  class="relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-400"
4
4
  :class="{'bg-indigo-500': value, 'bg-gray-300': !value}"
@@ -23,6 +23,7 @@ module Lookbook
23
23
 
24
24
  config.lookbook = ActiveSupport::OrderedOptions.new
25
25
  config.lookbook.listen_paths ||= []
26
+ config.lookbook.listen_extensions ||= []
26
27
  config.lookbook.preview_paths ||= []
27
28
  config.lookbook.page_paths ||= ["test/components/docs"]
28
29
 
@@ -55,6 +56,9 @@ module Lookbook
55
56
  options.listen_paths << (vc_options.view_component_path || Rails.root.join("app/components"))
56
57
  options.listen_paths.select! { |path| Dir.exist? path }
57
58
 
59
+ options.listen_extensions += ["rb", "html.*"]
60
+ options.listen_extensions.uniq!
61
+
58
62
  options.cable_mount_path ||= "/lookbook-cable"
59
63
  options.cable_logger ||= Rails.logger
60
64
 
@@ -80,7 +84,7 @@ module Lookbook
80
84
  @preview_controller.include(Lookbook::PreviewController)
81
85
 
82
86
  if config.lookbook.listen
83
- @preview_listener = Listen.to(*config.lookbook.listen_paths, only: /\.(rb|html.*)$/) do |modified, added, removed|
87
+ @preview_listener = Listen.to(*config.lookbook.listen_paths, only: /\.(#{config.lookbook.listen_extensions.join("|")})$/) do |modified, added, removed|
84
88
  begin
85
89
  parser.parse
86
90
  rescue
@@ -126,6 +130,7 @@ module Lookbook
126
130
 
127
131
  class << self
128
132
  def websocket
133
+ return @websocket unless @websocket.nil?
129
134
  if config.lookbook.auto_refresh
130
135
  cable = ActionCable::Server::Configuration.new
131
136
  cable.cable = {adapter: "async"}.with_indifferent_access
@@ -136,9 +141,9 @@ module Lookbook
136
141
  @websocket ||= if Rails.version.to_f >= 6.0
137
142
  ActionCable::Server::Base.new(config: cable)
138
143
  else
139
- websocket ||= ActionCable::Server::Base.new
140
- websocket.config = cable
141
- websocket
144
+ @websocket ||= ActionCable::Server::Base.new
145
+ @websocket.config = cable
146
+ @websocket
142
147
  end
143
148
  end
144
149
  end
@@ -12,6 +12,7 @@ module Lookbook
12
12
  }
13
13
 
14
14
  def self.render(text)
15
+ text&.gsub!("<!-- BEGIN inline template -->", "")&.gsub!("<!-- END inline template -->", "")
15
16
  markdown = Redcarpet::Markdown.new(Renderer, Lookbook.config.markdown_options)
16
17
  markdown.render(text).html_safe
17
18
  end
@@ -23,10 +23,6 @@ module Lookbook
23
23
  registry.get(path)
24
24
  end
25
25
 
26
- # def yardoc_file_path
27
- # Rails&.root ? Rails.root.join(YARDOC_FILE_PATH) : YARDOC_FILE_PATH
28
- # end
29
-
30
26
  class << self
31
27
  def define_tags
32
28
  YARD::Tags::Library.define_tag("Hidden status", :hidden)
@@ -1,3 +1,3 @@
1
1
  module Lookbook
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.3"
3
3
  end
@@ -4,7 +4,7 @@ namespace :lookbook do
4
4
 
5
5
  namespace :previews do
6
6
  desc "Preparse the previews"
7
- task :preparse do
7
+ task :preparse => :environment do
8
8
  Lookbook::Engine.parser.parse
9
9
  puts "Lookbook preview parsing complete"
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lookbook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Perkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-15 00:00:00.000000000 Z
11
+ date: 2022-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actioncable