Skip to content

Commit

Permalink
Enable followCursor for language stats bar (go-gitea#27713)
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind authored and GiteaBot committed Oct 22, 2023
1 parent aabcf2d commit 4c15009
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion templates/repo/sub_menu.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</div>
<a class="ui segment language-stats show-panel toggle" data-panel=".repository-summary > .sub-menu">
{{range .LanguageStats}}
<div class="bar" style="width: {{.Percentage}}%; background-color: {{.Color}}" data-tooltip-placement="top" data-tooltip-content={{.Language}}></div>
<div class="bar" style="width: {{.Percentage}}%; background-color: {{.Color}}" data-tooltip-placement="top" data-tooltip-content={{.Language}} data-tooltip-follow-cursor="horizontal"></div>
{{end}}
</a>
{{end}}
Expand Down
4 changes: 3 additions & 1 deletion web_src/js/modules/tippy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import tippy from 'tippy.js';
import tippy, {followCursor} from 'tippy.js';

const visibleInstances = new Set();

Expand Down Expand Up @@ -35,6 +35,7 @@ export function createTippy(target, opts = {}) {
arrow: `<svg width="16" height="7"><path d="m0 7 8-7 8 7Z" class="tippy-svg-arrow-outer"/><path d="m0 8 8-7 8 7Z" class="tippy-svg-arrow-inner"/></svg>`,
role: 'menu', // HTML role attribute, only tooltips should use "tooltip"
theme: other.role || 'menu', // CSS theme, we support either "tooltip" or "menu"
plugins: [followCursor],
...other,
});

Expand Down Expand Up @@ -78,6 +79,7 @@ function attachTooltip(target, content = null) {
theme: 'tooltip',
hideOnClick,
placement: target.getAttribute('data-tooltip-placement') || 'top-start',
followCursor: target.getAttribute('data-tooltip-follow-cursor') || false,
...(target.getAttribute('data-tooltip-interactive') === 'true' ? {interactive: true, aria: {content: 'describedby', expanded: false}} : {}),
};

Expand Down

0 comments on commit 4c15009

Please sign in to comment.