lookbook 0.4.0.beta.1 ā 0.4.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -15
- data/app/controllers/lookbook/app_controller.rb +1 -1
- data/lib/lookbook/taggable.rb +2 -2
- data/lib/lookbook/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9dc941aff608e601ffdf5e883aaf65a48ec815b40d01db58e85af66c793539d
|
4
|
+
data.tar.gz: 84e1027d39111c49e101b37dbc9aeaabe63dfcbab2fd3adfaa762de4fd39ee36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
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
|
188
|
+
# @display bg_color "#eee"
|
189
189
|
class FooComponentPreview < ViewComponent::Preview
|
190
190
|
|
191
|
-
# @display max_width
|
192
|
-
# @display wrapper
|
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
|
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
|
253
|
-
# @display wrap_in_container
|
254
|
-
# @display emojis_to_show
|
255
|
-
# @display page_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
|
262
|
-
# @display wrap_in_container
|
263
|
-
# @display page title
|
264
|
-
# @display bg_color
|
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
|
|
data/lib/lookbook/taggable.rb
CHANGED
@@ -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(
|
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
|
32
|
+
Rails.logger.error("\nš [Lookbook] Invalid JSON in @display tag.\nš [Lookbook] (#{err})\n")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/lib/lookbook/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|