Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#55581] lookbook proposal

Tobias Dillmann69a2eee83d30
diff --git a/lookbook/docs/patterns/25-hover-cards.md.erb b/lookbook/docs/patterns/25-hover-cards.md.erb
index 2bb9f2bc0a9..219ccad1830 100644
--- a/lookbook/docs/patterns/25-hover-cards.md.erb
+++ b/lookbook/docs/patterns/25-hover-cards.md.erb
@@ -1,4 +1,4 @@
-The HoverCard is a pattern related to the `Primer::Beta::Popover` and is used to show additional contexual information on certain kinds of resources like work packages and users. The hover card is opened by hovering over a certain trigger. When hovering outside of the card or its trigger, the popover is closed again.
+The HoverCard is a pattern related to the `Primer::Beta::Popover` and is used to show additional contextual information on certain kinds of resources like work packages and users. The hover card is opened by hovering over a certain trigger. When hovering outside of the card or its trigger, the popover is closed again.
## Overview
@@ -27,7 +27,7 @@ The HoverCard always consists of two basic parts:
## Used in
- WorkPackage preview when linking via `#ID`
-- Soon: User preview when hovering the avatar
+- User preview when hovering the avatar
## Technical notes
@@ -61,13 +61,27 @@ Additionally, the trigger element needs to pass the URL for the `turboFrame` as
class="op-hover-card--preview-trigger">
#14
</a>
+
+ <!-- This is how it would look like to provide a hover card trigger to a picture of a user. In reality, you would
+ probably apply the trigger to an <op-principal> tag. -->
+ <a href="users/14"
+ data-hover-card-url="users/14/hover_card"
+ class="op-hover-card--preview-trigger">
+ <img src="user_avatar.png" alt="">
+ </a>
```
+Note that the user example is simplified. For actual use in the application, it is recommended to use the `AvatarComponent`, which offers an option for hover cards.
+
**Actually rendered card content**:
```html
<!-- app/components/work_packages/hover_card/show.html.erb -->
<turbo-frame id="op-hover-card-body">
&lt;%= render WorkPackages::HoverCardComponent.new(id: 14) %&gt;
</turbo-frame>
- %&gt;
+
+ <!-- app/components/users/hover_card/show.html.erb -->
+ <turbo-frame id="op-hover-card-body">
+ &lt;%= render Users::HoverCardComponent.new(id: 14) %&gt;
+ </turbo-frame>
```
diff --git a/lookbook/previews/open_project/users/avatar_component_preview.rb b/lookbook/previews/open_project/users/avatar_component_preview.rb
index afc90b99f79..fe647903a0c 100644
--- a/lookbook/previews/open_project/users/avatar_component_preview.rb
+++ b/lookbook/previews/open_project/users/avatar_component_preview.rb
@@ -7,9 +7,12 @@ module OpenProject::Users
# @param size select { choices: [default, medium, mini] }
# @param link toggle
# @param show_name toggle
- def default(size: :default, link: true, show_name: true)
+ # @param hover_card toggle
+ # @param hover_card_target select { choices: [default, custom] }
+ def default(size: :default, link: true, show_name: true, hover_card: true, hover_card_target: :default)
user = FactoryBot.build_stubbed(:user)
- render(Users::AvatarComponent.new(user:, size:, link:, show_name:))
+ render(Users::AvatarComponent.new(user:, size:, link:, show_name:,
+ hover_card: { active: hover_card, target: hover_card_target }))
end
def sizes