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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29e0e0059cf53cd0d451d1f5018bee11ee70957dbe6c01bd286cfc38647922c1
|
4
|
+
data.tar.gz: fa52f4fb277dd3236fa8f831d6ab124094206dbcc5b7b88b84f5717ec82dd349
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6c4dea89446707034687d3677bf9960fccb8aacec4ddec9a7827ee1e7979fe6c48b987cb7e82858ca7ec32b03cb2194c5aba6d68603f271fd44efe204a91cd8
|
7
|
+
data.tar.gz: b14391d1b133b50b11c396cdc076041dd0a8791141191233736c475db2d617701504a37e85dd5799da77bd5a960ecd2ae6706fe8578f7bdac8976030a5fe21df
|
data/app/models/showcase/path.rb
CHANGED
@@ -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.
|
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 %>
|
data/lib/showcase/version.rb
CHANGED
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
|
-
|
16
|
-
attr_reader :tree_opens
|
15
|
+
singleton_class.attr_reader :tree_opens
|
17
16
|
|
18
|
-
|
19
|
-
|
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 }
|