showcase-rails 0.3.0 → 0.3.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: 3acbdb8f9aafaadded728f1f43bd2b834424a9ccd764605a093f3fa08019b9e7
4
- data.tar.gz: 5fe6fde3e533bb60540ea1b47b69953de2d40234560f2b55cdb47bab43e9ed37
3
+ metadata.gz: 1fcccbcd02f9ffc40e5c1555b816250dd78dace039662c5302ae4149f37a8fed
4
+ data.tar.gz: b4591324e7afa694e34bc412ae5d4442ecc5308d834b6874a29750e1b522a578
5
5
  SHA512:
6
- metadata.gz: fd7b71e810edb02e6f411f628ed80745944b36c920e7c86588b42544575fb8805a97e35bb30119b3d3a02ea9c127b8ced65d44a61808e5c30046e8ac90253719
7
- data.tar.gz: a5ef78400af5a631f38c57a51bc2ea900007213d6fe018da459b7d104d8f36132d8c7a51f3c8a8d3a078b4d4f837110bf0ffaf777a5885b15ea8a18061965318
6
+ metadata.gz: 4719a8283d75170d95c789469824aab301df3d822b0d2da6f89a3ecd60c1e0a660c4af275dfffcf1b4967a546799e7193ab1ebedd2c11715e240ac7f4c1fc28d
7
+ data.tar.gz: b5d74c620b87ca6860d4a7356196ce8f7dd25a0ac2d71caa37b1d9cd440cb6b8f79eea28384dde8cd955766c8d5468b7cc3c6e2f389d81cf4c09914e3089e87a
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:
@@ -4,7 +4,7 @@ module.exports = {
4
4
  prefix: 'sc-',
5
5
  content: [
6
6
  './public/*.html',
7
- './app/helpers/**/*.rb',
7
+ './app/{models,helpers}/**/*.rb',
8
8
  './app/javascript/**/*.js',
9
9
  './app/views/**/*.{erb,haml,html,slim}'
10
10
  ],
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Showcase
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
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.0
4
+ version: 0.3.1
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-26 00:00:00.000000000 Z
12
+ date: 2023-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails