hotwire-debug 0.1.1 → 0.1.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: 71cb728ec966ea0591ae2b03fe356cacf1ca74f6747ae160ceef218d4d14fe49
4
- data.tar.gz: 4ac75708ebb69606e685596c49e61351d3ecbb99ea60b61af904bbe6b4d49042
3
+ metadata.gz: b1026bde2d71a7f1fa6d5cd1df7505fc44f9f1a3a1988047496fb13543bc392d
4
+ data.tar.gz: d59d6b05cad3f001d633e92ed41302cf66b2b170e80aaddfa95918ef0c78bde7
5
5
  SHA512:
6
- metadata.gz: 0a923010b96de7f28058f44b1b969bafdc70b541effbde8bea6c710e69f3fd8151a5c13eb4b05a201f2c82b2288038953206141c80131d04aca3450a8c427cb6
7
- data.tar.gz: 7cff9b4305e92934af2d4bccc88ac9e903ebcfc2e34e190783b0f57407116905e29e490648b39d0c6e89a58f1442bda1ebf7bd52d1b800b4f17ebf3bac7ab967
6
+ metadata.gz: c25c1c89e908fb7e38d268681284063cb0993a57a37bf5b54c465e3893686b93e51f26eaff611138302dc90496bb2024fc2ffb08b27bb3607e86f1b169ca47ae
7
+ data.tar.gz: d41559b1e310564bda32155687a3a8ff4c7db94d27d7c7a9af7ecb775e40fe0c21a88c20d90934e4d4b2165426af9cf81b1c00961ef5ad1038c7f3a76fad39ed
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hotwire-debug (0.1.1)
4
+ hotwire-debug (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Hotwire::Debug
2
-
2
+ ![hotwire-debug v0.1.1 demo](https://user-images.githubusercontent.com/8511/104358150-aa7bba00-54d3-11eb-88b1-a01ef3ee7ae8.gif)
3
3
  ## Installation
4
4
 
5
5
  Add this line to your application's Gemfile:
@@ -18,18 +18,12 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- This gem adds assets into your applications vendor assets javascripts/stylesheets directories.
21
+ ### Asset Pipeline
22
22
 
23
- Update your `application.js`
24
- ```js
25
- //= require hotwire-debug
26
- ```
23
+ Run the generator:
27
24
 
28
- Update your `application.css`
29
- ```css
30
- /*
31
- *= require hotwire-debug
32
- */
25
+ ```
26
+ bin/rails g hotwire_debug:install
33
27
  ```
34
28
 
35
29
  If your application does not already include stylesheets and javascripts in the layout, add them.
@@ -39,6 +33,14 @@ If your application does not already include stylesheets and javascripts in the
39
33
  <%= javascript_include_tag 'application', media: 'all' %>
40
34
  ```
41
35
 
36
+ ### Webpacker
37
+
38
+ Run the generator:
39
+
40
+ ```
41
+ bin/rails g hotwire_debug:webpacker
42
+ ```
43
+
42
44
  # Options
43
45
 
44
46
  By default the color-scheme is a Hotwire-inspired teal and yellow. There's an alternate color scheme available. Add `data-hotwire-scheme-dark` to the root element.
@@ -6,8 +6,8 @@ require "hotwire/debug/version"
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "hotwire-debug"
8
8
  spec.version = Hotwire::Debug::VERSION
9
- spec.authors = ["Jim Remsik", "Jonathan Greenberg"]
10
- spec.email = ["jim@beflagrant.com", "jonathan@beflagrant.com"]
9
+ spec.authors = ["Jim Remsik", "Jonathan Greenberg", "Ben Vandgrift"]
10
+ spec.email = ["jim@beflagrant.com", "jonathan@beflagrant.com", "ben@beflagrant.com"]
11
11
 
12
12
  spec.summary = %q{Hotwire-debug highlights changes that occur via turbo-rails.}
13
13
  spec.homepage = "http://www.github.com/beflagrant/hotwire-debug"
@@ -0,0 +1,31 @@
1
+ module HotwireDebug
2
+ class InstallGenerator < Rails::Generators::Base
3
+
4
+ def append_javascript_imports
5
+ js = 'app/assets/javascripts/application.js'
6
+ File.new(js,File::CREAT) unless File.exists?(js)
7
+ inject_into_file js, "\n//= require hotwire-debug\n"
8
+ end
9
+
10
+ def append_stylesheet_imports
11
+
12
+ css = 'app/assets/stylesheets/application.css'
13
+ scss = 'app/assets/stylesheets/application.scss'
14
+ if File.exists?(css)
15
+ target = css
16
+ elsif File.exists?(scss)
17
+ target = scss
18
+ else
19
+ # if neither exist, create a css file
20
+ File.new(css,File::CREAT) unless File.exists?(css)
21
+ target = css
22
+ end
23
+
24
+ inject_into_file target, <<~STYLE
25
+ /*
26
+ *= require hotwire-debug
27
+ */
28
+ STYLE
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,46 @@
1
+ var turboEvents = [
2
+ "turbo:before-cache",
3
+ "turbo:before-render",
4
+ "turbo:before-visit",
5
+ "turbo:click",
6
+ "turbo:load",
7
+ "turbo:render",
8
+ "turbo:submit-end",
9
+ "turbo:submit-start",
10
+ ]
11
+
12
+ turboEvents.forEach(function(turboEvent) {
13
+ document.addEventListener(turboEvent, function() {
14
+ if (showChanges()) {
15
+ console.log("⚡️ " + turboEvent);
16
+ handleChange();
17
+ }
18
+ });
19
+ })
20
+
21
+ function showChanges () {
22
+ return document.documentElement.hasAttribute('data-hotwire-debug')
23
+ }
24
+
25
+ function handleChange() {
26
+ document.querySelectorAll('turbo-frame:first-child').forEach(function(target) {
27
+ target.setAttribute('data-turbo-frame-id', target.closest('turbo-frame').id);
28
+ });
29
+ }
30
+
31
+ window.addEventListener("turbo:load", () => {
32
+ let hotwireToggle = document.getElementById('hotwire-toggle');
33
+
34
+ if (hotwireToggle == null) {
35
+ hotwireToggle = document.createElement("div");
36
+ hotwireToggle.innerHTML = '<svg viewBox="0 0 196 196" xmlns="http://www.w3.org/2000/svg"> <style> path { fill: #000000; } @media (prefers-color-scheme: dark) { path { fill: #ffffff; } } </style> <path d="m16.38 184.8 109.46-44.72-35.27-3.31 76.73-66.59-44.33-4.16 53.9-55.53-136.52 70.03 54.89 6.44-67.32 54.38 30.07 2.97z"/> </svg>';
37
+ hotwireToggle.id = "hotwire-toggle";
38
+ document.body.append(hotwireToggle);
39
+
40
+ hotwireToggle.addEventListener("click", function() {
41
+ document.documentElement.toggleAttribute("data-hotwire-debug");
42
+ handleChange();
43
+ });
44
+ }
45
+ });
46
+
@@ -0,0 +1,78 @@
1
+ :root {
2
+ --color-highlight: rgba(255, 232, 1, 1);
3
+ --color-main: rgba(95, 206, 214, 1);
4
+ }
5
+ :root[data-hotwire-scheme-dark] {
6
+ --color-highlight: rgba(200, 200, 200, 1);
7
+ --color-main: rgba(0, 0, 0, 1);
8
+ }
9
+ #hotwire-toggle {
10
+ height: 2rem;
11
+ position: fixed;
12
+ right: 2rem;
13
+ bottom: 1rem;
14
+ width: 2rem;
15
+ z-index: 20;
16
+
17
+ svg path {
18
+ fill: var(--color-main) !important;
19
+ transition: fill ease-in-out 0.3s;
20
+ }
21
+ &:hover svg {
22
+ fill: var(--color-highlight) !important;
23
+ filter: drop-shadow(0 0 0.5rem var(--color-main));
24
+ }
25
+ }
26
+ :root[data-hotwire-debug] #hotwire-toggle {
27
+ svg path {
28
+ fill: var(--color-highlight) !important;
29
+ }
30
+
31
+ &:hover {
32
+ svg path {
33
+ stroke-width: 0.5rem;
34
+ filter: drop-shadow(0 0 0.5rem var(--color-highlight));
35
+ }
36
+ }
37
+ }
38
+ [data-hotwire-debug] {
39
+ turbo-frame {
40
+ border: 1px solid var(--color-main);
41
+ display: block;
42
+ padding-top: 1rem;
43
+ transition: all ease-in-out 0.3s;
44
+ &:hover {
45
+ display: block;
46
+ position: relative;
47
+
48
+ &:after {
49
+ color: var(--color-main) !important;
50
+ content: attr(id);
51
+ display: block;
52
+ font-weight: bold;
53
+ position: absolute;
54
+ right: 1rem;
55
+ top: 0;
56
+ z-index: 10;
57
+ }
58
+ }
59
+
60
+ & > :not(turbo-frame) {
61
+ animation-duration: 0.25s;
62
+ animation-name: highlight-frame-change;
63
+ border-radius: 0 1rem 1rem 0;
64
+ }
65
+ }
66
+ @keyframes highlight-frame-change {
67
+ 0% {
68
+ box-shadow: unset;
69
+ }
70
+ 50% {
71
+ box-shadow:inset 0 0 4rem var(--color-main);
72
+ }
73
+ 100% {
74
+ box-shadow: unset;
75
+ }
76
+ }
77
+ }
78
+
@@ -0,0 +1,13 @@
1
+ module HotwireDebug
2
+ class WebpackerGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('templates', __dir__)
4
+ def copy_assets
5
+ template "hotwire-debug.js", "app/javascript/vendor/hotwire-debug.js"
6
+ template "hotwire-debug.scss", "app/javascript/vendor/hotwire-debug.scss"
7
+ end
8
+ def append_imports
9
+ inject_into_file 'app/javascript/packs/application.js', "\nimport '../vendor/hotwire-debug';\n"
10
+ inject_into_file 'app/javascript/stylesheets/application.scss', "\n@import '../vendor/hotwire-debug';\n"
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  module Hotwire
2
2
  module Debug
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotwire-debug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Remsik
8
8
  - Jonathan Greenberg
9
+ - Ben Vandgrift
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2021-01-12 00:00:00.000000000 Z
13
+ date: 2021-01-14 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: bundler
@@ -43,6 +44,7 @@ description:
43
44
  email:
44
45
  - jim@beflagrant.com
45
46
  - jonathan@beflagrant.com
47
+ - ben@beflagrant.com
46
48
  executables: []
47
49
  extensions: []
48
50
  extra_rdoc_files: []
@@ -57,6 +59,12 @@ files:
57
59
  - bin/console
58
60
  - bin/setup
59
61
  - hotwire-debug.gemspec
62
+ - lib/generators/hotwire_debug/.DS_Store
63
+ - lib/generators/hotwire_debug/install/install_generator.rb
64
+ - lib/generators/hotwire_debug/webpacker/.DS_Store
65
+ - lib/generators/hotwire_debug/webpacker/templates/hotwire-debug.js
66
+ - lib/generators/hotwire_debug/webpacker/templates/hotwire-debug.scss
67
+ - lib/generators/hotwire_debug/webpacker/webpacker_generator.rb
60
68
  - lib/hotwire/debug.rb
61
69
  - lib/hotwire/debug/version.rb
62
70
  - package.json