coupdoeil 1.0.0.pre.alpha.4 → 1.0.0.pre.alpha.6
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 +4 -4
- data/README.md +84 -2
- data/lib/coupdoeil/version.rb +1 -1
- data/lib/coupdoeil.rb +1 -1
- data/lib/generators/coupdoeil/install/install_generator.rb +13 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2b90ff5e94bfa7b2b0653c2dcb7f97846cf0b8e76602c7c6fa275f3c5d8be90
|
4
|
+
data.tar.gz: c28079fdcf56d63cb67e7d78692e2830272b977983965201d2ae1a28739c654e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c0af99048fb580402bd29858e0881e4facef9f8ee1401f296dc3a35c7e3d1b9ad970decf069ee6da5972fbd9b12c1c8d928cbe618ea939d254d0f1068c1e7cf
|
7
|
+
data.tar.gz: 52a24662d6c205377095e6a1be1cb805b46e8d2e70d0a14c4cdfe98fbc898e286113b81d13abdc6fbe44647abef4436fab082adf0ade014159ec50f8cddfb820
|
data/README.md
CHANGED
@@ -1,6 +1,88 @@
|
|
1
1
|
# Coupdoeil
|
2
2
|
A framework to easily handle hovercards.
|
3
3
|
|
4
|
-
##
|
4
|
+
## Documentation
|
5
|
+
See [coupdoeil.org](https://coupdoeil.org) for full documentation.
|
5
6
|
|
6
|
-
|
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)
|
data/lib/coupdoeil/version.rb
CHANGED
data/lib/coupdoeil.rb
CHANGED
@@ -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
|
-
|
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
|
+
version: 1.0.0.pre.alpha.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PageHey
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-05-
|
10
|
+
date: 2025-05-23 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: actionpack
|
@@ -85,6 +85,20 @@ dependencies:
|
|
85
85
|
- - ">="
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '0'
|
88
|
+
- !ruby/object:Gem::Dependency
|
89
|
+
name: activerecord
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
type: :development
|
96
|
+
prerelease: false
|
97
|
+
version_requirements: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
88
102
|
description: Easy and powerful hovercard system for Ruby On Rails.
|
89
103
|
email:
|
90
104
|
- pagehey@pm.me
|