hotwire-debug 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f94c65f6c5769077e4d8d7961e3f2ba2e81aaf6f1da72e424b8bfae12832d763
4
+ data.tar.gz: f84644d64c5edfee0e97f0cfad7f554780d8931f129885a953bca1447380c472
5
+ SHA512:
6
+ metadata.gz: 528b98024db5acbdc1e934fe13bcc34cf8e22f07e56e4914d17bb51f7a6e0b57819f93883426facad76b40d1c8fa48a87a4fe0cd3b393cae2f43c1509ac14ae0
7
+ data.tar.gz: 98df50002c62a9c42781650c6c14f0989faba3fe7c58bf4ef7ed04eb9fe4edebc6f9a2a72c5e9220e7cfb1c1d391fea7be77ae8b8d3a01d566916e25aa49e3b8
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at jim@beflagrant.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in hotwire-debug.gemspec
6
+ gemspec
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hotwire-debug (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.5.0)
10
+
11
+ PLATFORMS
12
+ x86_64-darwin-20
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 2.0)
16
+ hotwire-debug!
17
+ rake (~> 10.0)
18
+
19
+ BUNDLED WITH
20
+ 2.2.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Jim Remsik
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,58 @@
1
+ # Hotwire::Debug
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'hotwire-debug'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install hotwire-debug
18
+
19
+ ## Usage
20
+
21
+ This gem adds assets into your applications vendor assets javascripts/stylesheets directories.
22
+
23
+ Update your `application.js`
24
+ ```js
25
+ //= require hotwire-debug
26
+ ```
27
+
28
+ Update your `application.css`
29
+ ```css
30
+ /*
31
+ *= require hotwire-debug
32
+ */
33
+ ```
34
+
35
+ If your application does not already include stylesheets and javascripts in the layout, add them.
36
+
37
+ ```erb
38
+ <%= stylesheet_link_tag 'application', media: 'all' %>
39
+ <%= javascript_include_tag 'application', media: 'all' %>
40
+ ```
41
+
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/beflagrant/hotwire-debug. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
51
+
52
+ ## License
53
+
54
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
55
+
56
+ ## Code of Conduct
57
+
58
+ Everyone interacting in the Hotwire::Debug project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/beflagrant/hotwire-debug/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "hotwire/debug"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,20 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "hotwire/debug/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hotwire-debug"
8
+ spec.version = Hotwire::Debug::VERSION
9
+ spec.authors = ["Jim Remsik", "Jonathan Greenberg"]
10
+ spec.email = ["jim@beflagrant.com", "jonathan@beflagrant.com"]
11
+
12
+ spec.summary = %q{Hotwire-debug highlights changes that occur via turbo-rails.}
13
+ spec.homepage = "http://www.github.com/beflagrant/hotwire-debug"
14
+ spec.license = "MIT"
15
+
16
+ spec.add_development_dependency "bundler", "~> 2.0"
17
+ spec.add_development_dependency "rake", "~> 10.0"
18
+
19
+ spec.files = `git ls-files`.split("\n")
20
+ end
@@ -0,0 +1,5 @@
1
+ require "hotwire/debug/version"
2
+
3
+ module Hotwire::Debug
4
+ class Engine < ::Rails::Engine; end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Hotwire
2
+ module Debug
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@beflagrant/hotwire-debug",
3
+ "version": "0.1.0",
4
+ "description": "Hotwire-debug highlights changes that occur via turbo.",
5
+ "main": "index.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+ssh://git@github.com/beflagrant/hotwire-debug.git"
9
+ },
10
+ "author": "Jim Remsik <jim@beflagrant.com>",
11
+ "license": "MIT",
12
+ "bugs": {
13
+ "url": "https://github.com/beflagrant/hotwire-debug/issues"
14
+ },
15
+ "homepage": "https://github.com/beflagrant/hotwire-debug#readme",
16
+ "directories": {
17
+ "lib": "lib"
18
+ },
19
+ "scripts": {
20
+ "test": "echo \"Error: no test specified\" && exit 1"
21
+ },
22
+ "keywords": [
23
+ "hotwire",
24
+ "rails",
25
+ "debug"
26
+ ]
27
+ }
@@ -0,0 +1,45 @@
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 > div, turbo-frame > form').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
+ });
@@ -0,0 +1,79 @@
1
+ :root {
2
+ --color-teal: rgba(95, 206, 214, 1);
3
+ --color-teal-trans: rgba(95, 206, 214, 0.4);
4
+ --color-pink: rgba(223, 116, 168, 1);
5
+ --color-pink-trans: rgba(223, 116, 168, 0.4);
6
+ --color-yellow: rgba(255, 224, 0, 1);
7
+ }
8
+ body > #hotwire-toggle {
9
+ position: fixed;
10
+ top: 1rem;
11
+ right: 2rem;
12
+ height: 2rem;
13
+ width: 2rem;
14
+ z-index: 20;
15
+
16
+ svg path {
17
+ fill: var(--color-black) !important;
18
+ transition: fill ease-in-out 0.3s;
19
+ }
20
+ &:hover svg path {
21
+ fill: var(--color-pink) !important;
22
+ }
23
+ }
24
+ html[data-hotwire-debug] #hotwire-toggle {
25
+ svg path {
26
+ fill: var(--color-yellow) !important;
27
+ stroke: var(--color-pink);
28
+ }
29
+
30
+ &:hover {
31
+ svg path {
32
+ stroke-width: 4px;
33
+ }
34
+ }
35
+ }
36
+ [data-hotwire-debug] {
37
+ turbo-frame {
38
+ display: block;
39
+ transition: all ease-in-out 0.3s;
40
+
41
+ &:hover {
42
+ display: block;
43
+ position: relative;
44
+ box-shadow: inset 0 0 3rem var(--color-teal-trans);
45
+
46
+ &:after {
47
+ color: rgb(30, 120, 120) !important;
48
+ content: attr(id);
49
+ font-weight: bold;
50
+ position: absolute;
51
+ display: block;
52
+ top: 49%;
53
+ right: 1rem;
54
+ -webkit-transform: translateY(-50%);
55
+ -moz-transform: translateY(-50%);
56
+ -ms-transform: translateY(-50%);
57
+ transform: translateY(-50%);
58
+ z-index: 10;
59
+ }
60
+ }
61
+
62
+ & > :not(turbo-frame) {
63
+ animation-name: highlight-frame-change;
64
+ animation-duration: 0.25s;
65
+ border-radius: 0 1rem 1rem 0;
66
+ }
67
+ }
68
+ @keyframes highlight-frame-change {
69
+ 0% {
70
+ box-shadow: unset;
71
+ }
72
+ 50% {
73
+ box-shadow:inset 0 0 4rem var(--color-teal);
74
+ }
75
+ 100% {
76
+ box-shadow: unset;
77
+ }
78
+ }
79
+ }
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hotwire-debug
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jim Remsik
8
+ - Jonathan Greenberg
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2021-01-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '2.0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '2.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ description:
43
+ email:
44
+ - jim@beflagrant.com
45
+ - jonathan@beflagrant.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - CODE_OF_CONDUCT.md
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - bin/console
58
+ - bin/setup
59
+ - hotwire-debug.gemspec
60
+ - lib/hotwire/debug.rb
61
+ - lib/hotwire/debug/version.rb
62
+ - package.json
63
+ - vendor/assets/javascripts/hotwire-debug.js
64
+ - vendor/assets/stylesheets/hotwire-debug.scss
65
+ homepage: http://www.github.com/beflagrant/hotwire-debug
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubygems_version: 3.1.4
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: Hotwire-debug highlights changes that occur via turbo-rails.
88
+ test_files: []