showcase-rails 0.2.1 → 0.2.2

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: a546309faa4499b63781df854aa283c3d3a382f91f0c9be8e00a37a5dcbd0b04
4
- data.tar.gz: 1a7b269de49a2015c7ad9bc037de1e68aed4b33217771322f8345e859bdc5bc0
3
+ metadata.gz: 24a9dbd46ccbe35d34075383efeb99bedb2825c56976b7b5ce2bb5fba294ffcc
4
+ data.tar.gz: 28dc05bf705b386845aa630a188d87295ba6069445583af781478e10052d5ae8
5
5
  SHA512:
6
- metadata.gz: 2779fe6f14b9a07db6a161dc4915a90aa2c1419f19dede0822d8009730b06a3b3006ec0eabcf8d008000d48a4997bdd4342b49dd59b35d4dfb205b520493ffcd
7
- data.tar.gz: f1bd8f9effd8ee3af53ab9bddf3456c3bff072e4cfb75d4e6b110a0925f35d996b2dce12f6adeb9e236ae5d5aa8f93eb3c93900b2d53f17c0930b44117b5e043
6
+ metadata.gz: e62b4977a6c7f8cb53fe74373e17de88870cf245ddcb449be791afb5cab22197a03aabe263aa543bde5d86bbd683e8914002ba133178825542abfe455bdbbda9
7
+ data.tar.gz: 77213dbf5e976b366ec64947b0e0a0efcf50eb8b0360a7d6698e72ea452512c5d8a37f91e838c9546a98c5b6f3d6b54cca4215bb8f301ad80e31029103de068c
data/README.md CHANGED
@@ -29,7 +29,7 @@ Which will then render the following:
29
29
 
30
30
  ![](/readme/example.png?raw=true "Showcase showing a button component")
31
31
 
32
- ## Automatic smokescreen testing
32
+ ## Automatic integration testing
33
33
 
34
34
  Showcase automatically runs integration tests for all your Showcases by rendering them and asserting they respond with `200 OK`. As long as `gem "showcase-rails"` is in the `:test` group you're set.
35
35
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- ! tailwindcss v3.2.4 | MIT License | https://tailwindcss.com
2
+ ! tailwindcss v3.2.6 | MIT License | https://tailwindcss.com
3
3
  */
4
4
 
5
5
  /*
@@ -691,6 +691,10 @@ select {
691
691
  grid-column: span 9 / span 9;
692
692
  }
693
693
 
694
+ .sc-m-2 {
695
+ margin: 0.5rem;
696
+ }
697
+
694
698
  .sc-mb-2 {
695
699
  margin-bottom: 0.5rem;
696
700
  }
@@ -699,6 +703,10 @@ select {
699
703
  margin-bottom: 1rem;
700
704
  }
701
705
 
706
+ .sc-mt-1 {
707
+ margin-top: 0.25rem;
708
+ }
709
+
702
710
  .sc-inline-block {
703
711
  display: inline-block;
704
712
  }
@@ -765,10 +773,13 @@ select {
765
773
  align-items: center;
766
774
  }
767
775
 
768
- .sc-space-y-8 > :not([hidden]) ~ :not([hidden]) {
769
- --tw-space-y-reverse: 0;
770
- margin-top: calc(2rem * calc(1 - var(--tw-space-y-reverse)));
771
- margin-bottom: calc(2rem * var(--tw-space-y-reverse));
776
+ .sc-justify-between {
777
+ justify-content: space-between;
778
+ }
779
+
780
+ .sc-gap-x-2 {
781
+ -moz-column-gap: 0.5rem;
782
+ column-gap: 0.5rem;
772
783
  }
773
784
 
774
785
  .sc-space-x-2 > :not([hidden]) ~ :not([hidden]) {
@@ -783,6 +794,12 @@ select {
783
794
  margin-bottom: calc(1rem * var(--tw-space-y-reverse));
784
795
  }
785
796
 
797
+ .sc-space-y-8 > :not([hidden]) ~ :not([hidden]) {
798
+ --tw-space-y-reverse: 0;
799
+ margin-top: calc(2rem * calc(1 - var(--tw-space-y-reverse)));
800
+ margin-bottom: calc(2rem * var(--tw-space-y-reverse));
801
+ }
802
+
786
803
  .sc-overflow-scroll {
787
804
  overflow: scroll;
788
805
  }
@@ -801,6 +818,10 @@ select {
801
818
  white-space: nowrap;
802
819
  }
803
820
 
821
+ .sc-rounded-full {
822
+ border-radius: 9999px;
823
+ }
824
+
804
825
  .sc-rounded-md {
805
826
  border-radius: 0.375rem;
806
827
  }
@@ -813,16 +834,20 @@ select {
813
834
  border-width: 0px;
814
835
  }
815
836
 
816
- .sc-border-t {
817
- border-top-width: 1px;
837
+ .sc-border-2 {
838
+ border-width: 2px;
839
+ }
840
+
841
+ .sc-border-b {
842
+ border-bottom-width: 1px;
818
843
  }
819
844
 
820
845
  .sc-border-r {
821
846
  border-right-width: 1px;
822
847
  }
823
848
 
824
- .sc-border-b {
825
- border-bottom-width: 1px;
849
+ .sc-border-t {
850
+ border-top-width: 1px;
826
851
  }
827
852
 
828
853
  .sc-border-gray-200 {
@@ -830,26 +855,36 @@ select {
830
855
  border-color: rgb(229 231 235 / var(--tw-border-opacity));
831
856
  }
832
857
 
833
- .sc-bg-slate-50 {
858
+ .sc-border-indigo-300 {
859
+ --tw-border-opacity: 1;
860
+ border-color: rgb(165 180 252 / var(--tw-border-opacity));
861
+ }
862
+
863
+ .sc-bg-indigo-50 {
834
864
  --tw-bg-opacity: 1;
835
- background-color: rgb(248 250 252 / var(--tw-bg-opacity));
865
+ background-color: rgb(238 242 255 / var(--tw-bg-opacity));
836
866
  }
837
867
 
838
868
  .sc-bg-slate-100\/50 {
839
869
  background-color: rgb(241 245 249 / 0.5);
840
870
  }
841
871
 
842
- .sc-bg-indigo-50 {
872
+ .sc-bg-slate-50 {
843
873
  --tw-bg-opacity: 1;
844
- background-color: rgb(238 242 255 / var(--tw-bg-opacity));
874
+ background-color: rgb(248 250 252 / var(--tw-bg-opacity));
875
+ }
876
+
877
+ .sc-p-12 {
878
+ padding: 3rem;
845
879
  }
846
880
 
847
881
  .sc-p-4 {
848
882
  padding: 1rem;
849
883
  }
850
884
 
851
- .sc-p-12 {
852
- padding: 3rem;
885
+ .sc-px-2 {
886
+ padding-left: 0.5rem;
887
+ padding-right: 0.5rem;
853
888
  }
854
889
 
855
890
  .sc-px-4 {
@@ -857,6 +892,11 @@ select {
857
892
  padding-right: 1rem;
858
893
  }
859
894
 
895
+ .sc-px-8 {
896
+ padding-left: 2rem;
897
+ padding-right: 2rem;
898
+ }
899
+
860
900
  .sc-py-2 {
861
901
  padding-top: 0.5rem;
862
902
  padding-bottom: 0.5rem;
@@ -867,11 +907,6 @@ select {
867
907
  padding-bottom: 1.25rem;
868
908
  }
869
909
 
870
- .sc-px-8 {
871
- padding-left: 2rem;
872
- padding-right: 2rem;
873
- }
874
-
875
910
  .sc-pl-4 {
876
911
  padding-left: 1rem;
877
912
  }
@@ -880,9 +915,9 @@ select {
880
915
  padding-top: 1.75rem;
881
916
  }
882
917
 
883
- .sc-text-xl {
884
- font-size: 1.25rem;
885
- line-height: 1.75rem;
918
+ .sc-text-2xl {
919
+ font-size: 1.5rem;
920
+ line-height: 2rem;
886
921
  }
887
922
 
888
923
  .sc-text-3xl {
@@ -895,17 +930,14 @@ select {
895
930
  line-height: 1.5rem;
896
931
  }
897
932
 
898
- .sc-text-2xl {
899
- font-size: 1.5rem;
900
- line-height: 2rem;
901
- }
902
-
903
- .sc-font-semibold {
904
- font-weight: 600;
933
+ .sc-text-xl {
934
+ font-size: 1.25rem;
935
+ line-height: 1.75rem;
905
936
  }
906
937
 
907
- .sc-font-normal {
908
- font-weight: 400;
938
+ .sc-text-xs {
939
+ font-size: 0.75rem;
940
+ line-height: 1rem;
909
941
  }
910
942
 
911
943
  .sc-font-black {
@@ -916,6 +948,14 @@ select {
916
948
  font-weight: 500;
917
949
  }
918
950
 
951
+ .sc-font-normal {
952
+ font-weight: 400;
953
+ }
954
+
955
+ .sc-font-semibold {
956
+ font-weight: 600;
957
+ }
958
+
919
959
  .sc-italic {
920
960
  font-style: italic;
921
961
  }
@@ -929,6 +969,11 @@ select {
929
969
  color: rgb(0 0 0 / var(--tw-text-opacity));
930
970
  }
931
971
 
972
+ .sc-text-slate-500 {
973
+ --tw-text-opacity: 1;
974
+ color: rgb(100 116 139 / var(--tw-text-opacity));
975
+ }
976
+
932
977
  .hover\:sc-select-all:hover {
933
978
  -webkit-user-select: all;
934
979
  -moz-user-select: all;
@@ -948,11 +993,11 @@ select {
948
993
  }
949
994
 
950
995
  @media (min-width: 1280px) {
951
- .xl\:sc-col-span-2 {
952
- grid-column: span 2 / span 2;
953
- }
954
-
955
996
  .xl\:sc-col-span-10 {
956
997
  grid-column: span 10 / span 10;
957
998
  }
999
+
1000
+ .xl\:sc-col-span-2 {
1001
+ grid-column: span 2 / span 2;
1002
+ }
958
1003
  }
@@ -1,6 +1,6 @@
1
1
  class Showcase::Sample
2
2
  attr_reader :name, :id, :events, :details
3
- attr_reader :source
3
+ attr_reader :source, :instrumented
4
4
 
5
5
  def initialize(view_context, name, description: nil, id: name.parameterize, events: nil, **details)
6
6
  @view_context = view_context
@@ -24,7 +24,13 @@ class Showcase::Sample
24
24
  end
25
25
 
26
26
  def preview(&block)
27
- block_given? ? @preview = @view_context.capture(&block) : @preview
27
+ return @preview unless block_given?
28
+
29
+ # TODO: Remove `is_a?` check when Rails 6.1 support is dropped.
30
+ assigns = proc { @instrumented = _1 if _1.is_a?(ActiveSupport::Notifications::Event) }
31
+ ActiveSupport::Notifications.subscribed(assigns, "render_partial.action_view") do
32
+ @preview = @view_context.capture(&block)
33
+ end
28
34
  end
29
35
 
30
36
  def extract(&block)
@@ -4,7 +4,9 @@
4
4
  <div class="sc-flex sc-items-center sc-space-x-2 sc-mb-2">
5
5
  <h2 class="sc-font-semibold sc-text-3xl"><%= preview.title %></h2>
6
6
 
7
- <%# TODO: Insert default badge support here. %>
7
+ <% preview.badges.each do |badge| %>
8
+ <span class="sc-border-2 sc-border-indigo-300 sc-rounded-full sc-px-2 sc-mt-1"><%= badge.to_s.titleize %></span>
9
+ <% end %>
8
10
  </div>
9
11
  <% end %>
10
12
 
@@ -1,7 +1,16 @@
1
1
  <section class="sc-mb-4 sc-border sc-border-gray-200 sc-rounded-md" aria-labelledby="showcase_<%= sample.id %>_title">
2
2
  <showcase-sample id="<%= sample.id %>" events="<%= sample.events %>">
3
3
  <header class="sc-bg-slate-100/50">
4
- <h3 id="showcase_<%= sample.id %>_title" class="sc-px-4 sc-py-2 sc-font-medium sc-text-base md:sc-text-lg sc-leading-snug sc-truncate"><%= link_to sample.name, "##{sample.id}" %></h3>
4
+ <div class="sc-flex sc-justify-between">
5
+ <h3 id="showcase_<%= sample.id %>_title" class="sc-px-4 sc-py-2 sc-font-medium sc-text-base md:sc-text-lg sc-leading-snug sc-truncate"><%= link_to sample.name, "##{sample.id}" %></h3>
6
+
7
+ <% if event = sample.instrumented %>
8
+ <div class="sc-text-xs sc-grid sc-gap-x-2 sc-m-2 sc-italic sc-text-slate-500">
9
+ <span><%= event.duration.round(1) %>ms</span>
10
+ <span><%= event.allocations %> allocs</span>
11
+ </div>
12
+ <% end %>
13
+ </div>
5
14
 
6
15
  <% if sample.description %>
7
16
  <p class="sc-px-4 sc-py-2 sc-text-base"><%= sample.description %></p>
@@ -1,3 +1,3 @@
1
1
  module Showcase
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -2,9 +2,9 @@ namespace :showcase do
2
2
  namespace :install do
3
3
  INTEGRATION_TEST_PATH = "test/integration/showcase_test.rb"
4
4
 
5
- desc "Install Showcase smokescreen testing in #{INTEGRATION_TEST_PATH}"
6
- task :smokescreen_test do
7
- mkdir_p INTEGRATION_TEST_PATH
5
+ desc "Install Showcase integration testing in #{INTEGRATION_TEST_PATH}"
6
+ task :integration_test do
7
+ mkdir_p File.dirname(INTEGRATION_TEST_PATH)
8
8
  File.write INTEGRATION_TEST_PATH, <<~RUBY
9
9
  require "test_helper"
10
10
 
@@ -16,15 +16,4 @@ namespace :showcase do
16
16
  RUBY
17
17
  end
18
18
  end
19
-
20
- # desc "Pass a directory relative to app/views to copy over"
21
- # task :copy do |t, directory|
22
- # prefix = "app/views/#{directory}"
23
- #
24
- # Dir.glob(File.join(Dir.pwd, prefix, "**/*.*")).each do |filename|
25
- # new_filename = filename.sub(directory, Showcase.templates_path).sub(/\/_/, "/")
26
- # mkdir_p File.dirname(new_filename)
27
- # copy_file filename, new_filename
28
- # end
29
- # end
30
19
  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.2.1
4
+ version: 0.2.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-02-07 00:00:00.000000000 Z
12
+ date: 2023-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -53,7 +53,6 @@ files:
53
53
  - app/assets/config/showcase_manifest.js
54
54
  - app/assets/javascripts/showcase.js
55
55
  - app/controllers/showcase/engine_controller.rb
56
- - app/controllers/showcase/pages_controller.rb
57
56
  - app/controllers/showcase/previews_controller.rb
58
57
  - app/models/showcase/options.rb
59
58
  - app/models/showcase/path.rb
@@ -1,5 +0,0 @@
1
- class Showcase::PagesController < Showcase::EngineController
2
- def show
3
- @page = Showcase::Path.new(params[:id]).page_for view_context
4
- end
5
- end