-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Replace hint.css with a stimulus js tippy.js wrapper. (#4723)
Because: - It gives us more control over tool tips - It means we won't need to load in a second stylesheet generated by the JS bundler This commit: - Removes hint.css - Adds tippy.js - Adds a Stimulus JS tooltip controller
- Loading branch information
1 parent
503e1d8
commit a0af480
Showing
6 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
15 changes: 13 additions & 2 deletions
15
app/components/project_submissions/like_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
<%= turbo_frame_tag dom_id(project_submission, :likes) do %> | ||
<%= button_to project_submission_like_path(project_submission), method: :put, disabled: current_users_submission, class: "mr-4 flex items-center #{'hint--top' unless current_users_submission}", data: { test_id: 'like-submission' }, aria: { label: tooltip_text } do %> | ||
<%= button_to( | ||
project_submission_like_path(project_submission), | ||
method: :put, | ||
disabled: current_users_submission, | ||
class: 'mr-4 flex items-center', | ||
data: { | ||
controller: 'tooltip', | ||
tooltip_message_value: tooltip_text, | ||
test_id: 'like-submission' | ||
}, | ||
aria: { label: tooltip_text } | ||
) do %> | ||
<span class="mr-1 text-sm text-gray-500 dark:text-gray-300" data-project-submissions--item-target="likeCount" data-test-id="like-count"> | ||
<%= project_submission.likes_count %> | ||
</span> | ||
|
||
<%= inline_svg_tag 'icons/heart.svg', class: "h-5 w-5 #{bg_color_class}", aria: true, title: 'heart', desc: 'heart icon' %> | ||
<%= inline_svg_tag 'icons/heart.svg', class: "h-5 w-5 #{bg_color_class}", aria: true, desc: 'heart icon' %> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Controller } from '@hotwired/stimulus'; | ||
import tippy from 'tippy.js'; | ||
import 'tippy.js/dist/tippy.css'; | ||
|
||
export default class TooltipController extends Controller { | ||
static values = { message: String }; | ||
|
||
connect() { | ||
this.tippyInstance = tippy(this.element, { | ||
content: this.messageValue, | ||
}); | ||
} | ||
|
||
destroy() { | ||
this.tippyInstance.destroy(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.