showcase-rails 0.3.0 → 0.3.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 +12 -0
- data/app/assets/builds/showcase.css +9 -0
- data/app/assets/javascripts/showcase.js +1 -1
- data/app/models/showcase/preview.rb +16 -0
- data/config/tailwind.config.js +1 -1
- data/lib/showcase/previews_test.rb +3 -2
- data/lib/showcase/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: 151c0562d98ae25ac207acf0921c0f299fb60ca37ca325b6f2ccc117e32ed09b
|
4
|
+
data.tar.gz: 5d532b1992e910ff03a4e4bde0ae41c1e32d83c3e58a17be68378d0e6b6380a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c65a5683153a76fe6410ab0e4140b311100ea5843da37a056f3ae70f02a13565ee58e2f9624d07a8969f8676093a59eab30bdf69b6a2d9d06852b8ab9640d6a
|
7
|
+
data.tar.gz: 77d2f23c5f9a0871f14713d46637bb326d48b9caa8610cf50654f5da05092d062d3ba0dd03500678e0af1902573b6c79f8c12e8998cbcd6ae3aa313fbda5ec58
|
data/README.md
CHANGED
@@ -111,6 +111,18 @@ class ShowcaseTest < Showcase::PreviewsTest
|
|
111
111
|
end
|
112
112
|
```
|
113
113
|
|
114
|
+
## Linking to previews
|
115
|
+
|
116
|
+
Call `showcase.link_to` with the URL path to the other Showcase:
|
117
|
+
|
118
|
+
```erb
|
119
|
+
<%= showcase.link_to "stimulus_controllers/welcome" %>
|
120
|
+
<%= showcase.link_to "components/button", id: "extra-large" %> <%# Pass an id to link to a specific sample %>
|
121
|
+
|
122
|
+
<%# You can also pass just an id: to target a sample on the current showcase %>
|
123
|
+
<%= showcase.link_to id: "extra-large" %>
|
124
|
+
```
|
125
|
+
|
114
126
|
## Full Rails engine support
|
115
127
|
|
116
128
|
Any Rails engines in your app that ships previews in their `app/views/showcase/previews` directory will automatically be surfaced in your app. Here's an example from the [bullet_train-themes-light Rails engine](https://github.com/bullet-train-co/bullet_train-core/tree/main/bullet_train-themes-light/app/views/showcase/previews).
|
@@ -916,6 +916,10 @@ select {
|
|
916
916
|
padding-top: 1.75rem;
|
917
917
|
}
|
918
918
|
|
919
|
+
.sc-font-mono {
|
920
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
921
|
+
}
|
922
|
+
|
919
923
|
.sc-text-2xl {
|
920
924
|
font-size: 1.5rem;
|
921
925
|
line-height: 2rem;
|
@@ -931,6 +935,11 @@ select {
|
|
931
935
|
line-height: 1.5rem;
|
932
936
|
}
|
933
937
|
|
938
|
+
.sc-text-sm {
|
939
|
+
font-size: 0.875rem;
|
940
|
+
line-height: 1.25rem;
|
941
|
+
}
|
942
|
+
|
934
943
|
.sc-text-xl {
|
935
944
|
font-size: 1.25rem;
|
936
945
|
line-height: 1.75rem;
|
@@ -32,6 +32,22 @@ class Showcase::Preview
|
|
32
32
|
@badges.concat badges
|
33
33
|
end
|
34
34
|
|
35
|
+
# Allows linking out to other Showcases
|
36
|
+
#
|
37
|
+
# <%= showcase.link_to "components/button", id: "extra-large" %>
|
38
|
+
# # => <a href="components/button#extra-large"><showcase components/button#extra-large></a>
|
39
|
+
#
|
40
|
+
# Can link to other samples on the current showcase too:
|
41
|
+
#
|
42
|
+
# # If we're within app/views/showcase/previews/components/_button.html.erb
|
43
|
+
# <%= showcase.link_to id: "extra-large" %>
|
44
|
+
# # => <a href="components/button#extra-large"><showcase components/button#extra-large></a>
|
45
|
+
def link_to(preview_id = id, id: nil)
|
46
|
+
@view_context.link_to @view_context.preview_path(preview_id, anchor: id), class: "sc-font-mono sc-text-sm" do
|
47
|
+
"<showcase #{[preview_id, id].compact.join("#").squish}>"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
35
51
|
# Adds a named sample to demonstrate with the Showcase can do.
|
36
52
|
#
|
37
53
|
# By default, sample takes a block that'll automatically have its source extracted, like this:
|
data/config/tailwind.config.js
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
class Showcase::PreviewsTest < ActionView::TestCase
|
2
|
+
extensions = [ Showcase::EngineController._helpers, Showcase::Engine.routes.url_helpers ]
|
3
|
+
setup { view.extend *extensions }
|
4
|
+
|
2
5
|
def self.inherited(test_class)
|
3
6
|
super
|
4
|
-
|
5
|
-
test_class.tests Showcase::EngineController._helpers
|
6
7
|
test_class.prepare
|
7
8
|
end
|
8
9
|
|
data/lib/showcase/version.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Pence
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-03-
|
12
|
+
date: 2023-03-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|