forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use tippy.js for context popup (go-gitea#20393)
By appending the tooltips to `document.body`, we can avoid any stacking context issues caused by surrounding element's CSS. This uses [tippy.js](https://github.com/atomiks/tippyjs) instead of Fomantic popups. We should aim to replace all Fomantic popups with this eventually and then get rid of the Fomantic `popup` module completely.
- Loading branch information
1 parent
08a65f5
commit fbdf774
Showing
6 changed files
with
135 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,12 @@ | ||
import tippy from 'tippy.js'; | ||
|
||
export function createTippy(target, opts) { | ||
return tippy(target, { | ||
appendTo: document.body, | ||
placement: 'top-start', | ||
animation: false, | ||
allowHTML: true, | ||
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>`, | ||
...opts, | ||
}); | ||
} |
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,84 @@ | ||
/* styles are based on node_modules/tippy.js/dist/tippy.css */ | ||
|
||
.tippy-box[data-animation="fade"][data-state="hidden"] { | ||
opacity: 0; | ||
} | ||
|
||
[data-tippy-root] { | ||
max-width: calc(100vw - 10px); | ||
} | ||
|
||
.tippy-box { | ||
position: relative; | ||
background-color: var(--color-body); | ||
color: var(--color-secondary-dark-6); | ||
border: 1px solid var(--color-secondary); | ||
border-radius: var(--border-radius); | ||
font-size: 1rem; | ||
transition-property: transform, visibility, opacity; | ||
} | ||
|
||
.tippy-content { | ||
position: relative; | ||
padding: 1rem; | ||
z-index: 1; | ||
} | ||
|
||
.tippy-box[data-placement^="top"] > .tippy-svg-arrow { | ||
bottom: 0; | ||
} | ||
|
||
.tippy-box[data-placement^="top"] > .tippy-svg-arrow::after, | ||
.tippy-box[data-placement^="top"] > .tippy-svg-arrow > svg { | ||
top: 16px; | ||
transform: rotate(180deg); | ||
} | ||
|
||
.tippy-box[data-placement^="bottom"] > .tippy-svg-arrow { | ||
top: 0; | ||
} | ||
|
||
.tippy-box[data-placement^="bottom"] > .tippy-svg-arrow > svg { | ||
bottom: 16px; | ||
} | ||
|
||
.tippy-box[data-placement^="left"] > .tippy-svg-arrow { | ||
right: 0; | ||
} | ||
|
||
.tippy-box[data-placement^="left"] > .tippy-svg-arrow::after, | ||
.tippy-box[data-placement^="left"] > .tippy-svg-arrow > svg { | ||
transform: rotate(90deg); | ||
top: calc(50% - 3px); | ||
left: 11px; | ||
} | ||
|
||
.tippy-box[data-placement^="right"] > .tippy-svg-arrow { | ||
left: 0; | ||
} | ||
|
||
.tippy-box[data-placement^="right"] > .tippy-svg-arrow::after, | ||
.tippy-box[data-placement^="right"] > .tippy-svg-arrow > svg { | ||
transform: rotate(-90deg); | ||
top: calc(50% - 3px); | ||
right: 11px; | ||
} | ||
|
||
.tippy-svg-arrow { | ||
width: 16px; | ||
height: 16px; | ||
text-align: initial; | ||
} | ||
|
||
.tippy-svg-arrow, | ||
.tippy-svg-arrow > svg { | ||
position: absolute; | ||
} | ||
|
||
.tippy-svg-arrow-outer { | ||
fill: var(--color-secondary); | ||
} | ||
|
||
.tippy-svg-arrow-inner { | ||
fill: var(--color-body); | ||
} |