showcase-rails 0.3.0 → 0.3.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: 3acbdb8f9aafaadded728f1f43bd2b834424a9ccd764605a093f3fa08019b9e7
4
- data.tar.gz: 5fe6fde3e533bb60540ea1b47b69953de2d40234560f2b55cdb47bab43e9ed37
3
+ metadata.gz: 151c0562d98ae25ac207acf0921c0f299fb60ca37ca325b6f2ccc117e32ed09b
4
+ data.tar.gz: 5d532b1992e910ff03a4e4bde0ae41c1e32d83c3e58a17be68378d0e6b6380a1
5
5
  SHA512:
6
- metadata.gz: fd7b71e810edb02e6f411f628ed80745944b36c920e7c86588b42544575fb8805a97e35bb30119b3d3a02ea9c127b8ced65d44a61808e5c30046e8ac90253719
7
- data.tar.gz: a5ef78400af5a631f38c57a51bc2ea900007213d6fe018da459b7d104d8f36132d8c7a51f3c8a8d3a078b4d4f837110bf0ffaf777a5885b15ea8a18061965318
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;
@@ -4,7 +4,7 @@ window.customElements.define("showcase-sample", class extends HTMLElement {
4
4
  }
5
5
 
6
6
  disconnectedCallback() {
7
- this.events.forEach(this.removeEventListener)
7
+ this.events.forEach((name) => this.removeEventListener(name, this.emit))
8
8
  }
9
9
 
10
10
  emit(event) {
@@ -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.2"
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.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-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