coupdoeil 1.0.0.pre.alpha.4 → 1.0.0.pre.alpha.5

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: 12d3b61e5972da42e39ac301ef83d8a20a8ff02decc9640385481f60707a9e32
4
- data.tar.gz: 7c90f6aea07ee9af9fc2b1392b42d543c2db1a0fae268f7720819e439ac3803d
3
+ metadata.gz: 8cf1f24d6bf5ecba5a2a0487f53df3ed465135370e1c31c92d011bab992e0329
4
+ data.tar.gz: 741a0143b46f6a624a47833a2bd44eb772d8bb4416db47e43a1f5dd822e781a8
5
5
  SHA512:
6
- metadata.gz: 205c669038b3603c5e261555493a0398891ef7cdcc19ddbfdf5118fb4809af286fb74c2ef5b845a4a1a0e891ee36f9715552c6485406495ef60e0acaf6b24e89
7
- data.tar.gz: 6e598fc91d2a4abc3dba804b08d992e030eb5c7339099bbb2423c544e41b469d7b709b6540ce4cf68567495abaec8af704a7ddbcebd75814509fedce68988e00
6
+ metadata.gz: df2e1ccc9312186ed3cc9a3751f4d07c6c0c9b2ad91e02071c3b68b79586f0d2050581dd7afd2784d13c1204485c4c2ec6d775bcf3a13b1a98f9ff523273faea
7
+ data.tar.gz: 188140fe0cc420094febd3d468fc75b7c3c5d8026dae3c3d10194485f7b359d66046f7aff93a9a56cfa8f797d5a3046215e65a33119e71251cedeed62979bd6a
data/README.md CHANGED
@@ -1,6 +1,88 @@
1
1
  # Coupdoeil
2
2
  A framework to easily handle hovercards.
3
3
 
4
- ## Usage
4
+ ## Documentation
5
+ See [coupdoeil.org](https://coupdoeil.org) for full documentation.
5
6
 
6
- See [documentation](https://coupdoeil.org)
7
+ ## Overview
8
+
9
+ ### What is a Coupdoeil::Hovercard?
10
+
11
+ Hovercards are ruby objects used to easily build powerful popups (from basic tooltips to full dialog hovercards).
12
+ They are mostly inspired by GitHub hovercards (like hovering on a link to a repo, or a username)
13
+ and Wikipedia popups (when hovering a link to another wikipedia article).
14
+
15
+ Click to toggle examples
16
+ <details>
17
+ <summary><i>A quick look on a contact details</i></summary>
18
+ <img src="https://coupdoeil.org/overview-example.gif" alt="hovercard example" />
19
+ </details>
20
+ <details>
21
+ <summary><i>A form in a popup</i></summary>
22
+ <img src="https://coupdoeil.org/overview-example-2.gif" alt="hovercard example" />
23
+ </details>
24
+ [See more use-cases](https://coupdoeil.org/case-studies.html)
25
+
26
+ The current implementation takes inspiration from both ViewComponent and ActionMailer, to make it as easy as possible to use while offering a wide range of possibilities.
27
+
28
+ ```ruby
29
+ # app/hovercards/contact_hovercard.rb
30
+ class ContactHovercard < Coupdoeil::Hovercard
31
+ def details
32
+ @contact = params[:contact]
33
+ end
34
+ end
35
+ ```
36
+
37
+ ```erb
38
+ <%# app/hovercards/contact_hovercard/details.html.erb %>
39
+ <div class="contact-details">
40
+ <%= image_tag @contact.avatar %>
41
+ <strong><%= @contact.first_name %> <%= @contact.last_name %></strong>
42
+ <!-- ... -->
43
+ </div>
44
+ ```
45
+
46
+ Which is embedded by doing so:
47
+
48
+ ```erb
49
+ <%# app/views/messages/show.html.erb %>
50
+ <div>
51
+ <span>From: </span>
52
+ <%= coupdoeil_hovercard_tag ContactHovercard.with(contact: @contact).details do %>
53
+ <span class="contact-pill"><%= @contact.email %></span>
54
+ <% end %>
55
+ </div>
56
+ ```
57
+
58
+ ### Why use Coupdoeil hovercards?
59
+
60
+ The concept of 'quick look' allowed by hovercards can really improve UX by avoiding the need to navigate to another page and back again just to check summary for a resource.
61
+ It also permits to hiding until use some parts of UI like small forms, or quick actions in a list of elements.
62
+
63
+ The most common examples of such hovercard are on GitHub (when hovering over a link to a repo, user profile, a PR, etc.) or on
64
+ Wikipedia (when hovering over a link to another article).
65
+
66
+ While basic popups implementations can be made with simple helpers, data-attributes, and a bit of JavaScript,
67
+ it tends to get too complex over time and often not handle enough edge-cases to be used everywhere it could improve UX.
68
+
69
+ `Coupdoeil::Hovercard` offers a way to easily encapsulate and power up hovercards rendering logic.
70
+ It allows a lot of customization possibilities (see [options](https://coupdoeil.org/opts.html)) and promotes re-usability by using an API similar to
71
+ parameterized ActionMailer (see [Why does it look like a mailer?](https://coupdoeil.org/architectural-decisions.html#why-does-it-look-like-a-mailer)).
72
+
73
+ This gem also tries to handle all known issues of such hovercards, such as
74
+ the user's mouse quickly leaving and re-entering hovercard without closing it,
75
+ preventing opening of an hovercard if mouse did not stop on it, etc.
76
+
77
+ ### Performances
78
+
79
+ By default, an hovercard content is not loaded until it is needed.
80
+ It means the DOM is not cluttered with 'maybe to be used' HTML, hidden in template tags or data-attributes.
81
+ However, params have to be present in HTML so they are sent for rendering the hovercard (eg: a record id),
82
+ so try passing as few as required to build it later during render.
83
+ Also, hovercards are cached so the fetch happens only the first time an hovercard is open.
84
+
85
+ When needed, hovercards can still be preloaded and included in DOM on initial page load. See [preload option](https://coupdoeil.org/options/loading.html).
86
+
87
+ ## Licence
88
+ Coupdoeil is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT)
@@ -1,3 +1,3 @@
1
1
  module Coupdoeil
2
- VERSION = "1.0.0-alpha.4"
2
+ VERSION = "1.0.0-alpha.5"
3
3
  end
@@ -19,7 +19,7 @@ class Coupdoeil::InstallGenerator < Rails::Generators::Base
19
19
  if Rails.root.join("config/importmap.rb").exist?
20
20
  append_to_importmap
21
21
  elsif Rails.root.join("package.json").exist?
22
- raise "package.json not supported yet!"
22
+ add_with_node
23
23
  else
24
24
  puts "You must either be running with node (package.json) or importmap-rails (config/importmap.rb) to use this gem."
25
25
  end
@@ -42,6 +42,18 @@ class Coupdoeil::InstallGenerator < Rails::Generators::Base
42
42
  append_to_file "app/javascript/application.js", %(import "coupdoeil"\n)
43
43
  end
44
44
 
45
+ def add_with_node
46
+ if Rails.root.join("app/javascript/application.js").exist?
47
+ say "Import Coupdoeil"
48
+ append_to_file "app/javascript/application.js", %(import "coupdoeil"\n)
49
+ else
50
+ say "You must import coupdoeil in your JavaScript entrypoint file", :red
51
+ end
52
+
53
+ say "Install Coupdoeil"
54
+ run "yarn add coupdoeil"
55
+ end
56
+
45
57
  def import_stylesheet
46
58
  puts "To use Coupdoeil hovercard style, add to your layout's head:"
47
59
  puts ""
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coupdoeil
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.alpha.4
4
+ version: 1.0.0.pre.alpha.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - PageHey
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-22 00:00:00.000000000 Z
10
+ date: 2025-05-23 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: actionpack