Skip to content

Commit 48e3aec

Browse files
GiteaBotsilverwind
andauthored
Enable followCursor for language stats bar (#27713) (#27739)
Backport #27713 by @silverwind Fixes: #27600 ![](https://github.com/go-gitea/gitea/assets/115237/96743d90-0712-4f13-84ec-66f84e6ed2d7) Also tested together with #27704, works well. Co-authored-by: silverwind <[email protected]>
1 parent aabcf2d commit 48e3aec

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

templates/repo/sub_menu.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</div>
3939
<a class="ui segment language-stats show-panel toggle" data-panel=".repository-summary > .sub-menu">
4040
{{range .LanguageStats}}
41-
<div class="bar" style="width: {{.Percentage}}%; background-color: {{.Color}}" data-tooltip-placement="top" data-tooltip-content={{.Language}}></div>
41+
<div class="bar" style="width: {{.Percentage}}%; background-color: {{.Color}}" data-tooltip-placement="top" data-tooltip-content={{.Language}} data-tooltip-follow-cursor="horizontal"></div>
4242
{{end}}
4343
</a>
4444
{{end}}

web_src/js/modules/tippy.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import tippy from 'tippy.js';
1+
import tippy, {followCursor} from 'tippy.js';
22

33
const visibleInstances = new Set();
44

@@ -35,6 +35,7 @@ export function createTippy(target, opts = {}) {
3535
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>`,
3636
role: 'menu', // HTML role attribute, only tooltips should use "tooltip"
3737
theme: other.role || 'menu', // CSS theme, we support either "tooltip" or "menu"
38+
plugins: [followCursor],
3839
...other,
3940
});
4041

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

0 commit comments

Comments
 (0)