lookbook 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d855b9a3a2e36fa5e18aa2388ced2c97a8b07dc8cd5b81785cd6ed1b85269bca
4
- data.tar.gz: 3f54dfcf6def53543c8247634ed0b40e6a39807d6e09c59690c50f0f8a0f175d
3
+ metadata.gz: b4a0e938511079a03ed87c74edf15d65798789ed6f149cfe25d528a4a9a8b329
4
+ data.tar.gz: 4d47a5e24f65b5d04beb904cb4c52589547999c20c195c2eed48c9394e3a9a72
5
5
  SHA512:
6
- metadata.gz: f213eb79ea2eab3f01af6be18544c1d59d02905b50d6ff773f54f89e14e0982be43ff948c1eab32819317278a6915070cf1c8259923bb17b195d86d4932f27c5
7
- data.tar.gz: 616c37c62765074f87d79c14313499e9bcec19e8722751f74ce39793693ca3058b60f55ac5e80edb406b9301022d79d55c3bb33f9601281576d3f15eb868109b
6
+ metadata.gz: ce7cd4e60c085c02a631694278b2d64a905aaf8f4d7e636f0fb683842f7efac46c9fe88466a75fc6b2b085bbbb87da9df152a6d81d38cb0a49328d0083bec9d2
7
+ data.tar.gz: 9c8b2e22243e48d56ae592d2bca443ae17bb0b47e08eece6d9620425f2d36e3397e93a61192ca6a921dcfd4f1fa046f25b28f35dcfd0ff9ac04366a025e47eb1
@@ -5,7 +5,7 @@ module Lookbook
5
5
  end
6
6
 
7
7
  def lookbook_data(key, fallback = nil)
8
- Lookbook.data.get(key, fallback)
8
+ Lookbook.data.fetch(key, fallback)
9
9
  end
10
10
  end
11
11
  end
@@ -1,7 +1,7 @@
1
1
  <% if examples.many? %>
2
2
  <%# Render a group of examples %>
3
3
  <% examples.each do |example| %>
4
- <div style="all: unset; margin-bottom: 30px; display: block;">
4
+ <div style="margin-bottom: 30px !important; display: block !important;">
5
5
  <h6 style="all: unset; display: block; color: #999; font-family: sans-serif; font-size: 14px; margin-top: 0; margin-bottom: 10px;">
6
6
  <%= example.label %>
7
7
  </h6>
@@ -1,122 +1,118 @@
1
- require "lookbook/markdown"
2
- require "lookbook/theme"
3
- require "lookbook/store"
4
-
5
1
  module Lookbook
6
2
  class Config
7
- def initialize
8
- @options = Store.new({}, true)
9
-
10
- @options.set({
11
- project_name: "Lookbook",
12
- log_level: 2,
13
- log_use_rails_logger: true,
14
- auto_refresh: true,
15
-
16
- components_path: "app/components",
17
-
18
- page_controller: "Lookbook::PageController",
19
- page_route: "pages",
20
- page_paths: ["test/components/docs"],
21
- page_options: {},
22
- markdown_options: Markdown::DEFAULT_OPTIONS,
23
-
24
- preview_paths: [],
25
- preview_display_params: {},
26
- preview_srcdoc: nil,
27
- preview_tags: {},
28
- preview_disable_action_view_annotations: true,
29
- preview_param_inputs: {
30
- select: "lookbook/previews/inputs/select",
31
- textarea: "lookbook/previews/inputs/textarea",
32
- toggle: "lookbook/previews/inputs/toggle",
33
- color: "lookbook/previews/inputs/color",
34
- range: "lookbook/previews/inputs/range",
35
- text: "lookbook/previews/inputs/text",
36
- email: "lookbook/previews/inputs/text",
37
- number: "lookbook/previews/inputs/text",
38
- tel: "lookbook/previews/inputs/text",
39
- url: "lookbook/previews/inputs/text",
40
- date: "lookbook/previews/inputs/text",
41
- datetime_local: "lookbook/previews/inputs/text"
3
+ DEFAULTS = {
4
+ project_name: "Lookbook",
5
+ log_level: 2,
6
+ log_use_rails_logger: true,
7
+ auto_refresh: true,
8
+
9
+ components_path: "app/components",
10
+
11
+ page_controller: "Lookbook::PageController",
12
+ page_route: "pages",
13
+ page_paths: ["test/components/docs"],
14
+ page_options: {},
15
+ markdown_options: Markdown::DEFAULT_OPTIONS,
16
+
17
+ preview_paths: [],
18
+ preview_display_params: {},
19
+ preview_srcdoc: nil,
20
+ preview_tags: {},
21
+ preview_disable_action_view_annotations: true,
22
+ preview_param_inputs: {
23
+ select: "lookbook/previews/inputs/select",
24
+ textarea: "lookbook/previews/inputs/textarea",
25
+ toggle: "lookbook/previews/inputs/toggle",
26
+ color: "lookbook/previews/inputs/color",
27
+ range: "lookbook/previews/inputs/range",
28
+ text: "lookbook/previews/inputs/text",
29
+ email: "lookbook/previews/inputs/text",
30
+ number: "lookbook/previews/inputs/text",
31
+ tel: "lookbook/previews/inputs/text",
32
+ url: "lookbook/previews/inputs/text",
33
+ date: "lookbook/previews/inputs/text",
34
+ datetime_local: "lookbook/previews/inputs/text"
35
+ },
36
+ preview_params_options_eval: false,
37
+ sort_examples: false,
38
+
39
+ listen: Rails.env.development?,
40
+ listen_paths: [],
41
+ listen_extensions: ["rb", "html.*"],
42
+ listen_use_polling: false,
43
+
44
+ cable_mount_path: "/cable",
45
+
46
+ parser_registry_path: "tmp/storage/.yardoc",
47
+
48
+ ui_theme: "indigo",
49
+ ui_theme_overrides: {},
50
+ ui_favicon: true,
51
+
52
+ hooks: {
53
+ after_initialize: [],
54
+ before_exit: [],
55
+ after_change: []
56
+ },
57
+
58
+ debug_menu: Rails.env.development?,
59
+
60
+ experimental_features: false,
61
+
62
+ inspector_panels: {
63
+ preview: {
64
+ pane: :main,
65
+ position: 1,
66
+ partial: "lookbook/previews/panels/preview",
67
+ hotkey: "v",
68
+ panel_classes: "overflow-hidden",
69
+ padded: false,
70
+ system: true
42
71
  },
43
- preview_params_options_eval: false,
44
- sort_examples: false,
45
-
46
- listen: Rails.env.development?,
47
- listen_paths: [],
48
- listen_extensions: ["rb", "html.*"],
49
- listen_use_polling: false,
50
-
51
- cable_mount_path: "/cable",
52
-
53
- parser_registry_path: "tmp/storage/.yardoc",
54
-
55
- ui_theme: "indigo",
56
- ui_theme_overrides: {},
57
- ui_favicon: true,
58
-
59
- hooks: {
60
- after_initialize: [],
61
- before_exit: [],
62
- after_change: []
72
+ output: {
73
+ pane: :main,
74
+ position: 2,
75
+ partial: "lookbook/previews/panels/output",
76
+ label: "HTML",
77
+ hotkey: "h",
78
+ padded: false,
79
+ system: true
63
80
  },
64
-
65
- debug_menu: Rails.env.development?,
66
-
67
- experimental_features: false,
68
-
69
- inspector_panels: {
70
- preview: {
71
- pane: :main,
72
- position: 1,
73
- partial: "lookbook/previews/panels/preview",
74
- hotkey: "v",
75
- panel_classes: "overflow-hidden",
76
- padded: false,
77
- system: true
78
- },
79
- output: {
80
- pane: :main,
81
- position: 2,
82
- partial: "lookbook/previews/panels/output",
83
- label: "HTML",
84
- hotkey: "h",
85
- padded: false,
86
- system: true
87
- },
88
- source: {
89
- pane: :drawer,
90
- position: 1,
91
- partial: "lookbook/previews/panels/source",
92
- label: "Source",
93
- hotkey: "s",
94
- copy: ->(data) { data.examples.map { |e| e.source }.join("\n") },
95
- padded: false,
96
- system: true
97
- },
98
- notes: {
99
- pane: :drawer,
100
- position: 2,
101
- partial: "lookbook/previews/panels/notes",
102
- label: "Notes",
103
- hotkey: "n",
104
- disabled: ->(data) { data.examples.select { |e| e.notes.present? }.none? },
105
- padded: false,
106
- system: true
107
- },
108
- params: {
109
- pane: :drawer,
110
- position: 3,
111
- partial: "lookbook/previews/panels/params",
112
- label: "Params",
113
- hotkey: "p",
114
- disabled: ->(data) { data.preview.params.none? },
115
- padded: false,
116
- system: true
117
- }
81
+ source: {
82
+ pane: :drawer,
83
+ position: 1,
84
+ partial: "lookbook/previews/panels/source",
85
+ label: "Source",
86
+ hotkey: "s",
87
+ copy: ->(data) { data.examples.map { |e| e.source }.join("\n") },
88
+ padded: false,
89
+ system: true
90
+ },
91
+ notes: {
92
+ pane: :drawer,
93
+ position: 2,
94
+ partial: "lookbook/previews/panels/notes",
95
+ label: "Notes",
96
+ hotkey: "n",
97
+ disabled: ->(data) { data.examples.select { |e| e.notes.present? }.none? },
98
+ padded: false,
99
+ system: true
100
+ },
101
+ params: {
102
+ pane: :drawer,
103
+ position: 3,
104
+ partial: "lookbook/previews/panels/params",
105
+ label: "Params",
106
+ hotkey: "p",
107
+ disabled: ->(data) { data.preview.params.none? },
108
+ padded: false,
109
+ system: true
118
110
  }
119
- })
111
+ }
112
+ }
113
+
114
+ def initialize
115
+ @options = Store.new(Config::DEFAULTS, recursive: true)
120
116
  end
121
117
 
122
118
  def runtime_parsing=(value)
@@ -3,77 +3,11 @@ require "action_cable/engine"
3
3
  require "listen"
4
4
 
5
5
  module Lookbook
6
- autoload :Config, "lookbook/config"
7
- autoload :Data, "lookbook/data"
8
- autoload :Hooks, "lookbook/hooks"
9
- autoload :Panels, "lookbook/panels"
10
- autoload :Tags, "lookbook/tags"
11
-
12
- class << self
13
- include Lookbook::Data
14
- include Lookbook::Hooks
15
- include Lookbook::Panels
16
- include Lookbook::Tags
17
-
18
- def version
19
- Lookbook::VERSION
20
- end
21
-
22
- def config
23
- @config ||= Config.new
24
- end
25
-
26
- def configure
27
- yield(config)
28
- end
29
-
30
- def logger
31
- @logger ||= if Rails.logger.present? && config.log_use_rails_logger
32
- Rails.logger
33
- else
34
- logger = Logger.new($stdout)
35
- logger.level = config.log_level
36
- logger
37
- end
38
- end
39
-
40
- def debug_data
41
- {
42
- version: version,
43
- env: Rails.env.to_s,
44
- config: config.to_h
45
- }
46
- end
47
-
48
- def previews
49
- Preview.all
50
- end
51
-
52
- def pages
53
- Page.all
54
- end
55
-
56
- def broadcast(event_name, data = {})
57
- Engine.websocket&.broadcast(event_name.to_s, data)
58
- end
59
-
60
- def theme
61
- @theme ||= Lookbook::Theme.new(config.ui_theme, config.ui_theme_overrides)
62
- end
63
-
64
- def define_param_input(input, partial, input_options = nil)
65
- config.preview_param_inputs[input.to_sym] = {
66
- partial: partial,
67
- input_options: input_options || {}
68
- }
69
- end
70
- end
71
-
72
6
  class Engine < Rails::Engine
73
7
  isolate_namespace Lookbook
74
8
 
75
- config.lookbook = Lookbook.config
76
9
  config.autoload_paths << File.expand_path(Lookbook::Engine.root.join("app/components"))
10
+ config.lookbook = Lookbook.config
77
11
 
78
12
  initializer "lookbook.viewcomponent.config" do
79
13
  config.lookbook.preview_paths += config.view_component.preview_paths
@@ -134,7 +68,6 @@ module Lookbook
134
68
  def init_listeners
135
69
  config = Lookbook.config
136
70
  return unless config.listen == true
137
- Listen.logger = Lookbook.logger
138
71
 
139
72
  listen_paths = config.listen_paths.uniq
140
73
  if listen_paths.any?
@@ -1,48 +1,34 @@
1
1
  module Lookbook
2
2
  class Store < ActiveSupport::OrderedOptions
3
- def initialize(data = {}, deep = false)
3
+ def initialize(data = {}, opts = {})
4
+ @recursive = opts[:recursive] || false
5
+ data.each { |key, value| self[key] = value }
4
6
  super()
5
- @deep = deep
6
- set(data) if data.present?
7
- end
8
-
9
- def [](key)
10
- super(normalize_key(key))
11
7
  end
12
8
 
13
9
  def []=(key, value)
14
- super(normalize_key(key), normalize_value(value))
15
- end
16
-
17
- def set(data)
18
- data.keys.each do |key|
19
- self[normalize_key(key)] = normalize_value(data[key])
20
- end
21
- self
10
+ super(key, normalize_value(value))
22
11
  end
23
12
 
24
- def get(key, fallback = nil)
25
- if key?(normalize_key(key))
26
- self[normalize_key(key)]
27
- else
28
- fallback
29
- end
13
+ def fetch(name, *args)
14
+ super(name.to_sym, *args)
30
15
  end
31
16
 
32
17
  def method_missing(name, *args)
33
- super(normalize_key(name), *args.map { |arg| normalize_value(arg) })
18
+ if name.to_s.end_with?("=")
19
+ args[0] = normalize_value(args[0])
20
+ end
21
+ super(name, *args)
34
22
  end
35
23
 
36
- def respond_to_missing?(name, *)
37
- key?(name)
24
+ def respond_to_missing?(name, include_private)
25
+ true
38
26
  end
39
27
 
40
- def normalize_key(key)
41
- key.to_s.downcase.tr("-", "_").to_sym
42
- end
28
+ private
43
29
 
44
30
  def normalize_value(value)
45
- @deep && !value.is_a?(Store) && value.is_a?(Hash) ? Store.new(value, @deep) : value
31
+ @recursive && !value.is_a?(Store) && value.is_a?(Hash) ? Store.new(value, recursive: @recursive) : value
46
32
  end
47
33
  end
48
34
  end
@@ -1,3 +1,3 @@
1
1
  module Lookbook
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
data/lib/lookbook.rb CHANGED
@@ -1,34 +1,79 @@
1
- require "active_support/dependencies/autoload"
2
- require "lookbook/engine"
1
+ require "zeitwerk"
2
+ require "ostruct"
3
3
  require "lookbook/version"
4
- require "view_component/engine"
4
+
5
+ loader = Zeitwerk::Loader.for_gem
6
+ loader.ignore("#{__dir__}/lookbook.rb")
7
+ loader.push_dir("#{__dir__}/lookbook", namespace: Lookbook)
8
+ loader.setup
5
9
 
6
10
  module Lookbook
7
- extend ActiveSupport::Autoload
8
-
9
- autoload :Error, "lookbook/error"
10
- autoload :Utils, "lookbook/utils"
11
- autoload :Lang, "lookbook/lang"
12
- autoload :Params, "lookbook/params"
13
- autoload :TagOptions, "lookbook/tag_options"
14
- autoload :Page, "lookbook/page"
15
- autoload :Tag, "lookbook/tag"
16
- autoload :PageSection, "lookbook/page_section"
17
- autoload :PageCollection, "lookbook/page_collection"
18
- autoload :Features, "lookbook/features"
19
- autoload :Collection, "lookbook/collection"
20
- autoload :Entity, "lookbook/entity"
21
- autoload :Parser, "lookbook/parser"
22
- autoload :Preview, "lookbook/preview"
23
- autoload :PreviewCollection, "lookbook/preview_collection"
24
- autoload :PreviewController, "lookbook/preview_controller"
25
- autoload :PreviewExample, "lookbook/preview_example"
26
- autoload :PreviewGroup, "lookbook/preview_group"
27
- autoload :SourceInspector, "lookbook/source_inspector"
28
- autoload :TemplateParser, "lookbook/template_parser"
29
- autoload :CodeFormatter, "lookbook/code_formatter"
30
- autoload :Markdown, "lookbook/markdown"
31
- autoload :Theme, "lookbook/theme"
32
- autoload :Store, "lookbook/store"
33
- autoload :Component, "lookbook/component"
11
+ class << self
12
+ include Lookbook::Hooks
13
+ include Lookbook::Panels
14
+ include Lookbook::Tags
15
+
16
+ def version
17
+ Lookbook::VERSION
18
+ end
19
+
20
+ def config
21
+ @config ||= Config.new
22
+ end
23
+
24
+ def configure
25
+ yield(config)
26
+ end
27
+
28
+ def data
29
+ @data ||= Store.new
30
+ end
31
+
32
+ def data=(new_data)
33
+ @data = Store.new(new_data)
34
+ end
35
+
36
+ def logger
37
+ @logger ||= if Rails.logger.present? && config.log_use_rails_logger
38
+ Rails.logger
39
+ else
40
+ logger = Logger.new($stdout)
41
+ logger.level = config.log_level
42
+ logger
43
+ end
44
+ end
45
+
46
+ def debug_data
47
+ {
48
+ version: version,
49
+ env: Rails.env.to_s,
50
+ config: config.to_h
51
+ }
52
+ end
53
+
54
+ def previews
55
+ Preview.all
56
+ end
57
+
58
+ def pages
59
+ Page.all
60
+ end
61
+
62
+ def broadcast(event_name, data = {})
63
+ Engine.websocket&.broadcast(event_name.to_s, data)
64
+ end
65
+
66
+ def theme
67
+ @theme ||= Lookbook::Theme.new(config.ui_theme, config.ui_theme_overrides)
68
+ end
69
+
70
+ def define_param_input(input, partial, input_options = nil)
71
+ config.preview_param_inputs[input.to_sym] = {
72
+ partial: partial,
73
+ input_options: input_options || {}
74
+ }
75
+ end
76
+ end
34
77
  end
78
+
79
+ require "lookbook/engine"
@@ -623,6 +623,10 @@ var $caa9439642c6336c$var$directiveOrder = [
623
623
  "ref",
624
624
  "data",
625
625
  "id",
626
+ "tabs",
627
+ "radio",
628
+ "switch",
629
+ "disclosure",
626
630
  "bind",
627
631
  "init",
628
632
  "for",
@@ -1238,11 +1242,11 @@ function $caa9439642c6336c$var$getBinding(el, name, fallback) {
1238
1242
  if (el._x_bindings && el._x_bindings[name] !== void 0) return el._x_bindings[name];
1239
1243
  let attr = el.getAttribute(name);
1240
1244
  if (attr === null) return typeof fallback === "function" ? fallback() : fallback;
1245
+ if (attr === "") return true;
1241
1246
  if ($caa9439642c6336c$var$isBooleanAttr(name)) return !![
1242
1247
  name,
1243
1248
  "true"
1244
1249
  ].includes(attr);
1245
- if (attr === "") return true;
1246
1250
  return attr;
1247
1251
  }
1248
1252
  // packages/alpinejs/src/utils/debounce.js
@@ -1361,7 +1365,7 @@ var $caa9439642c6336c$var$Alpine = {
1361
1365
  get raw () {
1362
1366
  return $caa9439642c6336c$var$raw;
1363
1367
  },
1364
- version: "3.10.3",
1368
+ version: "3.10.4",
1365
1369
  flushAndStopDeferringMutations: $caa9439642c6336c$var$flushAndStopDeferringMutations,
1366
1370
  dontAutoEvaluateFunctions: $caa9439642c6336c$var$dontAutoEvaluateFunctions,
1367
1371
  disableEffectScheduling: $caa9439642c6336c$var$disableEffectScheduling,
@@ -2390,7 +2394,7 @@ $caa9439642c6336c$var$directive("bind", (el, { value: value , modifiers: modifie
2390
2394
  if (value === "key") return $caa9439642c6336c$var$storeKeyForXFor(el, expression);
2391
2395
  let evaluate2 = $caa9439642c6336c$var$evaluateLater(el, expression);
2392
2396
  effect3(()=>evaluate2((result)=>{
2393
- if (result === void 0 && expression.match(/\./)) result = "";
2397
+ if (result === void 0 && typeof expression === "string" && expression.match(/\./)) result = "";
2394
2398
  $caa9439642c6336c$var$mutateDom(()=>$caa9439642c6336c$var$bind(el, value, result, modifiers));
2395
2399
  }));
2396
2400
  });
@@ -7821,7 +7825,7 @@ function $5439cede634b2921$var$toCamel(s) {
7821
7825
  }
7822
7826
 
7823
7827
 
7824
- var $205fb3dd9870d001$exports = {};
7828
+ var $1f889267678ff167$exports = {};
7825
7829
  var $cbd28b10fa9798c7$exports = {};
7826
7830
 
7827
7831
  $parcel$defineInteropFlag($cbd28b10fa9798c7$exports);
@@ -11485,6 +11489,16 @@ function $cbd28b10fa9798c7$export$2e2bcd8739ae039() {
11485
11489
  }
11486
11490
 
11487
11491
 
11492
+ var $99486586f6691564$exports = {};
11493
+
11494
+ $parcel$defineInteropFlag($99486586f6691564$exports);
11495
+
11496
+ $parcel$export($99486586f6691564$exports, "default", () => $99486586f6691564$export$2e2bcd8739ae039);
11497
+ function $99486586f6691564$export$2e2bcd8739ae039() {
11498
+ return {};
11499
+ }
11500
+
11501
+
11488
11502
  var $47a1c62621be0c54$exports = {};
11489
11503
 
11490
11504
  $parcel$defineInteropFlag($47a1c62621be0c54$exports);
@@ -11541,16 +11555,6 @@ function $47a1c62621be0c54$export$2e2bcd8739ae039() {
11541
11555
  }
11542
11556
 
11543
11557
 
11544
- var $99486586f6691564$exports = {};
11545
-
11546
- $parcel$defineInteropFlag($99486586f6691564$exports);
11547
-
11548
- $parcel$export($99486586f6691564$exports, "default", () => $99486586f6691564$export$2e2bcd8739ae039);
11549
- function $99486586f6691564$export$2e2bcd8739ae039() {
11550
- return {};
11551
- }
11552
-
11553
-
11554
11558
  var $e398acaded942bbe$exports = {};
11555
11559
 
11556
11560
  $parcel$defineInteropFlag($e398acaded942bbe$exports);
@@ -13326,10 +13330,10 @@ function $6d64716f0b34fdf4$export$2e2bcd8739ae039(store) {
13326
13330
  }
13327
13331
 
13328
13332
 
13329
- $205fb3dd9870d001$exports = {
13333
+ $1f889267678ff167$exports = {
13330
13334
  "button": $cbd28b10fa9798c7$exports,
13331
- "copy_button": $47a1c62621be0c54$exports,
13332
13335
  "code": $99486586f6691564$exports,
13336
+ "copy_button": $47a1c62621be0c54$exports,
13333
13337
  "dimensions_display": $e398acaded942bbe$exports,
13334
13338
  "embed": $e1f51f020443edd4$exports,
13335
13339
  "filter": $e9904a14dabf652d$exports,
@@ -13505,7 +13509,7 @@ const $d73574cc5e9b9e72$var$prefix = window.APP_NAME;
13505
13509
  // Components
13506
13510
  (0, $caa9439642c6336c$export$2e2bcd8739ae039).data("app", (0, $d709d0f4027033b2$export$2e2bcd8739ae039));
13507
13511
  [
13508
- $205fb3dd9870d001$exports,
13512
+ $1f889267678ff167$exports,
13509
13513
  $c43230a66e7bc31a$exports,
13510
13514
  $6c10158820e535ef$exports
13511
13515
  ].forEach((scripts)=>{