showcase-rails 0.4.1 → 0.4.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: 0c5d33100bd6414501e65b9739978d060032490a480bcf17cac74b689c556605
4
- data.tar.gz: ac2cf1b91db211cce86ad10ac4b9acc9dbfd5c19a7d4fdda17e853b3e81ebade
3
+ metadata.gz: 29e0e0059cf53cd0d451d1f5018bee11ee70957dbe6c01bd286cfc38647922c1
4
+ data.tar.gz: fa52f4fb277dd3236fa8f831d6ab124094206dbcc5b7b88b84f5717ec82dd349
5
5
  SHA512:
6
- metadata.gz: 754d2bfcd10de161792834a56b470dc88652ac393429295d794e05b6c97b8da6a309af9aad284456742f34fde3faa6f7de50583f43f341178e2a0f22f13e314d
7
- data.tar.gz: 2bb6891dd5236ce84728bb6c86db146de9724152f471b5e7f71fd1149941866572e9e2d5fd23e575e87019db5c62eb4597ef3807e28b3c20c33265cc896c479d
6
+ metadata.gz: f6c4dea89446707034687d3677bf9960fccb8aacec4ddec9a7827ee1e7979fe6c48b987cb7e82858ca7ec32b03cb2194c5aba6d68603f271fd44efe204a91cd8
7
+ data.tar.gz: b14391d1b133b50b11c396cdc076041dd0a8791141191233736c475db2d617701504a37e85dd5799da77bd5a960ecd2ae6706fe8578f7bdac8976030a5fe21df
@@ -17,6 +17,10 @@ class Showcase::Path
17
17
  Showcase.tree_opens.call(self)
18
18
  end
19
19
 
20
+ def active?(id)
21
+ children.any? { _1.active?(id) }
22
+ end
23
+
20
24
  def ordered_children
21
25
  children.partition { !_1.is_a?(Tree) }.flatten
22
26
  end
@@ -62,6 +66,10 @@ class Showcase::Path
62
66
  cached_partial_path = "showcase/engine/path/path"
63
67
  define_method(:to_partial_path) { cached_partial_path }
64
68
 
69
+ def active?(id)
70
+ self.id == id
71
+ end
72
+
65
73
  def preview_for(view_context)
66
74
  Showcase::Preview.new(view_context, id: id, title: basename.titleize).tap(&:render_associated_partial)
67
75
  end
@@ -1,3 +1,3 @@
1
- <article class="hover:sc-bg-indigo-50 dark:hover:sc-bg-neutral-700/50 <%= "sc-bg-indigo-50 dark:sc-bg-neutral-700/50" if path.id == params[:id] %>">
1
+ <article class="hover:sc-bg-indigo-50 dark:hover:sc-bg-neutral-700/50 <%= "sc-bg-indigo-50 dark:sc-bg-neutral-700/50" if path.active? params[:id] %>">
2
2
  <%= link_to path.basename.titleize, preview_path(path.id), class: "sc-inline-block sc-py-2 sc-px-8 sc-w-full !sc-text-inherit !sc-no-underline" %>
3
3
  </article>
@@ -1,4 +1,4 @@
1
- <%= tag.details open: tree.open?, class: ["sc-flex sc-flex-col", "sc-pl-4" => !tree.root?] do %>
1
+ <%= tag.details open: tree.active?(params[:id]) || tree.open?, class: ["sc-flex sc-flex-col", "sc-pl-4" => !tree.root?] do %>
2
2
  <%= tag.summary tree.name.titleize, class: "sc-list-item hover:sc-bg-indigo-50 dark:hover:sc-bg-neutral-700/50 sc-font-medium sc-text-base sc-py-2 sc-pl-4 sc-cursor-pointer" %>
3
3
  <%= render tree.ordered_children %>
4
4
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module Showcase
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
data/lib/showcase.rb CHANGED
@@ -12,16 +12,12 @@ module Showcase
12
12
  autoload :RouteHelper, "showcase/route_helper"
13
13
  autoload :Options, "showcase/options"
14
14
 
15
- class << self
16
- attr_reader :tree_opens
15
+ singleton_class.attr_reader :tree_opens
17
16
 
18
- def tree_opens=(opens)
19
- @tree_opens = opens.respond_to?(:call) ? opens : proc { opens }
20
- end
17
+ def self.tree_opens=(opens)
18
+ @tree_opens = opens.respond_to?(:call) ? opens : proc { opens }
21
19
  end
22
20
  self.tree_opens = true # All open by default
23
- # self.tree_opens = false # All closed by default
24
- # self.tree_opens = ->(tree) { tree.root? } # Just keep the root-level trees open.
25
21
 
26
22
  singleton_class.attr_accessor :sample_renderer
27
23
  @sample_renderer = proc { _1 }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: showcase-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pence