mirror of
https://github.com/zadam/trilium.git
synced 2025-10-30 11:09:05 +01:00
feat(react/checkbox): use bootstrap tooltip
This commit is contained in:
parent
523c7ac273
commit
f196a78728
@ -642,6 +642,10 @@ table.promoted-attributes-in-tooltip th {
|
|||||||
z-index: calc(var(--ck-z-panel) - 1) !important;
|
z-index: calc(var(--ck-z-panel) - 1) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tooltip.tooltip-top {
|
||||||
|
z-index: 32767 !important;
|
||||||
|
}
|
||||||
|
|
||||||
.tooltip-trigger {
|
.tooltip-trigger {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
import { Tooltip } from "bootstrap";
|
||||||
|
import { useEffect, useRef } from "preact/compat";
|
||||||
|
import { escapeQuotes } from "../../services/utils";
|
||||||
|
|
||||||
interface FormCheckboxProps {
|
interface FormCheckboxProps {
|
||||||
name: string;
|
name: string;
|
||||||
label: string;
|
label: string;
|
||||||
@ -11,11 +15,29 @@ interface FormCheckboxProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function FormCheckbox({ name, disabled, label, currentValue, onChange, hint }: FormCheckboxProps) {
|
export default function FormCheckbox({ name, disabled, label, currentValue, onChange, hint }: FormCheckboxProps) {
|
||||||
|
const labelRef = useRef<HTMLLabelElement>(null);
|
||||||
|
|
||||||
|
if (hint) {
|
||||||
|
useEffect(() => {
|
||||||
|
let tooltipInstance: Tooltip | null = null;
|
||||||
|
if (labelRef.current) {
|
||||||
|
tooltipInstance = Tooltip.getOrCreateInstance(labelRef.current, {
|
||||||
|
html: true,
|
||||||
|
template: '<div class="tooltip tooltip-top" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return () => tooltipInstance?.dispose();
|
||||||
|
}, [labelRef.current]);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="form-checkbox">
|
<div className="form-checkbox">
|
||||||
<label
|
<label
|
||||||
className="form-check-label tn-checkbox"
|
className="form-check-label tn-checkbox"
|
||||||
style={hint && { textDecoration: "underline dotted var(--main-text-color)" }} title={hint}>
|
style={hint && { textDecoration: "underline dotted var(--main-text-color)" }}
|
||||||
|
title={hint && escapeQuotes(hint)}
|
||||||
|
ref={labelRef}
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
className="form-check-input"
|
className="form-check-input"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user