lookbook 0.4.0.beta.1 → 0.4.0.beta.2

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: 870ef6a17d84bca0a9fbbc421e27c2d6d682965d96c646f44d3db817e5a5e4f2
4
- data.tar.gz: 669ce3b709792be5bdf46ac806efdca269d694349e74f759b0997cbbb456792e
3
+ metadata.gz: b9dc941aff608e601ffdf5e883aaf65a48ec815b40d01db58e85af66c793539d
4
+ data.tar.gz: 84e1027d39111c49e101b37dbc9aeaabe63dfcbab2fd3adfaa762de4fd39ee36
5
5
  SHA512:
6
- metadata.gz: b0293806f0d57b130c07ae84b5d30fad2625df0cbf2477303d924dddfd42ece6e49b10f15fc0b395fa65adfca3de3ab1096e72565a175bdab14df2af1ba57050
7
- data.tar.gz: 2e5ad4ca7957d2684dc367b3a7d89d9922024cfc01cdbcd2567d30b830fe891b815924d64f5b7048783efd42736f41924354255f847850498fd596ba1c25e977
6
+ metadata.gz: 1f1399cdf6ed3f6184208ffaac1aaf36fd18e8abd5dcec96b73cac5d1384a722b6f742a61c7ec404d5faecd255231bf3f54dff33e2825ce5a4dd0f01c5e2a331
7
+ data.tar.gz: 875fb74128ed3cc0f8d72a57245207e8224318d08a8f6f35dc4b627c06e4c0a159501be042917e92340b536a1fbdb81d379fd6b805bccaa70796bfcbbce4dc67
data/README.md CHANGED
@@ -76,7 +76,7 @@ Lookbook parses [Yard-style comment tags](https://rubydoc.info/gems/yard/file/do
76
76
 
77
77
  ```ruby
78
78
  # @label Basic Button
79
- # @display bg_color: "#fff"
79
+ # @display bg_color "#fff"
80
80
  class ButtonComponentPreview < ViewComponent::Preview
81
81
 
82
82
  # Primary button
@@ -94,7 +94,7 @@ class ButtonComponentPreview < ViewComponent::Preview
94
94
  # ---------------
95
95
  # For light-on-dark screens
96
96
  #
97
- # @display bg_color: "#000"
97
+ # @display bg_color "#000"
98
98
  def secondary
99
99
  render ButtonComponent.new(style: :inverted) do
100
100
  "Click me"
@@ -180,16 +180,16 @@ class FooComponentPreview < ViewComponent::Preview
180
180
  end
181
181
  ```
182
182
 
183
- ### šŸ”– `@display <key>: <value>`
183
+ ### šŸ”– `@display <key> <value>`
184
184
 
185
185
  The `@display` tag lets you pass custom parameters to your preview layout so that the component preview can be customised on a per-example basis.
186
186
 
187
187
  ```ruby
188
- # @display bg_color: "#eee"
188
+ # @display bg_color "#eee"
189
189
  class FooComponentPreview < ViewComponent::Preview
190
190
 
191
- # @display max_width: "500px"
192
- # @display wrapper: true
191
+ # @display max_width "500px"
192
+ # @display wrapper true
193
193
  def default
194
194
  end
195
195
  end
@@ -198,7 +198,7 @@ end
198
198
  The `@display` tag can be applied at the preview (class) or at the example (method) level, and takes the following format:
199
199
 
200
200
  ```ruby
201
- # @display <key>: <value>
201
+ # @display <key> <value>
202
202
  ```
203
203
 
204
204
  - `<key>` must be a valid Ruby hash key name, without quotes or spaces
@@ -249,19 +249,19 @@ Globally defined display params will be available to all previews. Any preview o
249
249
  Valid:
250
250
 
251
251
  ```ruby
252
- # @display body_classes: "bg-red border border-4 border-green"
253
- # @display wrap_in_container: true
254
- # @display emojis_to_show: 4
255
- # @display page_title: "Special example title"
252
+ # @display body_classes "bg-red border border-4 border-green"
253
+ # @display wrap_in_container true
254
+ # @display emojis_to_show 4
255
+ # @display page_title "Special example title"
256
256
  ```
257
257
 
258
258
  Invalid:
259
259
 
260
260
  ```ruby
261
- # @display body_classes: 'bg-red border border-4 border-green' [āŒ single quotes]
262
- # @display wrap_in_container: should_wrap [āŒ unquoted string, perhaps trying to call a method]
263
- # @display page title: "Special example title" [āŒ space in key]
264
- # @display bg_color: #fff [āŒ colors need quotes around them, it's not CSS!]
261
+ # @display body_classes 'bg-red border border-4 border-green' [āŒ single quotes]
262
+ # @display wrap_in_container should_wrap [āŒ unquoted string, perhaps trying to call a method]
263
+ # @display page title "Special example title" [āŒ space in key]
264
+ # @display bg_color #fff [āŒ colors need quotes around them, it's not CSS!]
265
265
  ```
266
266
 
267
267
  ### šŸ”– `@!group <name> ... @!endgroup`
@@ -50,7 +50,7 @@ module Lookbook
50
50
  def find_preview
51
51
  candidates = []
52
52
  params[:path].to_s.scan(%r{/|$}) { candidates << $` }
53
- match = candidates.detect { |candidate| Lookbook::Preview.exists?(candidate) }
53
+ match = candidates.reverse.detect { |candidate| Lookbook::Preview.exists?(candidate) }
54
54
  @preview = match ? Lookbook::Preview.find(match) : nil
55
55
  end
56
56
 
@@ -24,12 +24,12 @@ module Lookbook
24
24
  display_params = {}
25
25
  if code_object&.tags(:display).present?
26
26
  code_object.tags(:display).each do |tag|
27
- parts = tag.text.match(/^\s?([^:]*)\s?:\s?(.*)\s?$/)
27
+ parts = tag.text.strip.match(/^([^\s]*)\s?(.*)$/)
28
28
  if parts.present?
29
29
  begin
30
30
  display_params[parts[1]] = JSON.parse parts[2]
31
31
  rescue JSON::ParserError => err
32
- Rails.logger.error("\nšŸ‘€ [Lookbook] Invalid JSON in @display tag.\nšŸ‘€ [Lookbook] (#{err.to_s})\n")
32
+ Rails.logger.error("\nšŸ‘€ [Lookbook] Invalid JSON in @display tag.\nšŸ‘€ [Lookbook] (#{err})\n")
33
33
  end
34
34
  end
35
35
  end
@@ -1,3 +1,3 @@
1
1
  module Lookbook
2
- VERSION = "0.4.0.beta.1"
2
+ VERSION = "0.4.0.beta.2"
3
3
  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.4.0.beta.1
4
+ version: 0.4.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Perkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-19 00:00:00.000000000 Z
11
+ date: 2021-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails