Skip to content

Commit

Permalink
-feat: global tooltip
Browse files Browse the repository at this point in the history
-style: decrease padding
-style: correct navigation button text
  • Loading branch information
crfmc committed Jul 30, 2024
1 parent f251d69 commit 57470cc
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 43 deletions.
46 changes: 24 additions & 22 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ a:hover {
}

.title-doc-link {
color: black;
display: inline-block;
position: fixed;
right: 20px;
Expand Down Expand Up @@ -493,6 +494,7 @@ a:hover {
z-index: 998;
opacity: 0.5;
border: none;
border-radius: 4px;
background: none;
padding: 0px;
}
Expand Down Expand Up @@ -830,35 +832,35 @@ a:hover {
}
}

.track-tooltips-container {
top: 100px;
width: 3%;
height: min-content;
position: relative;
z-index: 997;
}

.track-tooltip {
padding: 0px;
border: none;

.button.question-mark {
width: 12px;
height: 12px;
fill: black;
}
}
.track-tooltip:hover {
cursor: pointer;
}

/* Minimal Mode styles */
.minimal_mode {
.gosling-panel {
overflow-y: scroll;
overflow-x: hidden;
}

.track-tooltips-container {
top: 100px;
width: 3%;
height: 100%;
position: relative;
z-index: 997;
}

.track-tooltip {
padding: 0px;
border: none;

.button.question-mark {
width: 12px;
height: 12px;
fill: black;
}
}
.track-tooltip:hover {
cursor: pointer;
}

.sample-label {
left: 300px;
top: 8px;
Expand Down
38 changes: 18 additions & 20 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { VariantViewModal } from './ui/VariantViewModal';
import 'bootstrap/dist/css/bootstrap.min.css';
import * as bootstrap from 'bootstrap/dist/js/bootstrap.bundle.min';

import { Track, getTrackData } from './ui/trackData.js';
import { Track, getTrackDocData } from './ui/trackData.js';

const db = new Database();
const log = new BrowserDatabase();
Expand Down Expand Up @@ -59,7 +59,7 @@ function App(props: RouteComponentProps) {
const VIS_PADDING = {
top: isMinimalMode ? 0 : 60,
right: isMinimalMode ? 0 : 60,
bottom: isMinimalMode ? 0 : 60,
bottom: 0,
left: isMinimalMode ? 0 : 60
};

Expand Down Expand Up @@ -323,6 +323,10 @@ function App(props: RouteComponentProps) {
}, 500)
);

// Enable Bootstrap popovers for track tooltips
const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]');
const popoverList = [...popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl));

// Lower opacity of legend image as it leaves viewport
if (isMinimalMode) {
const legendElement = document.querySelector<HTMLElement>('.genome-view-legend');
Expand All @@ -338,12 +342,6 @@ function App(props: RouteComponentProps) {
}, options);

observer.observe(legendElement);

// Enable Bootstrap popovers for track tooltips
const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]');
const popoverList = [...popoverTriggerList].map(
popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl)
);
}
}, []);

Expand Down Expand Up @@ -549,7 +547,7 @@ function App(props: RouteComponentProps) {
const trackTooltips = useMemo(() => {
// calculate the offset by the Genome View
const genomeViewHeight = Math.min(600, visPanelWidth);
const TRACK_DATA = getTrackData(isMinimalMode);
const TRACK_DATA = getTrackDocData(isMinimalMode);
const offset = genomeViewHeight + (isMinimalMode ? 100 : 40) - 2;

// Infer the tracks shown
Expand Down Expand Up @@ -588,19 +586,19 @@ function App(props: RouteComponentProps) {
key={i}
tabIndex={4}
role="button"
className="track-tooltip btn btn-sm"
className="track-tooltip"
data-bs-trigger="focus"
data-bs-toggle="popover"
data-bs-template={`
<div class="popover" role="tooltip">
<div class="popover-arrow">
</div>
<h2 class="popover-header">
</h2>
<div class="popover-body">
</div>
</div>
`}
<div class="popover" role="tooltip">
<div class="popover-arrow">
</div>
<h2 class="popover-header">
</h2>
<div class="popover-body">
</div>
</div>
`}
data-bs-title={d.title}
data-bs-custom-class={'track-tooltip-popover popover-for-' + d.type}
data-bs-html="true"
Expand Down Expand Up @@ -1100,7 +1098,7 @@ function App(props: RouteComponentProps) {
}}
>
{goslingComponent}
{isMinimalMode && trackTooltips}
{trackTooltips}
{jumpButtonInfo ? (
<button
className="jump-to-bp-btn"
Expand Down
2 changes: 1 addition & 1 deletion src/ui/trackData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type Track =

// TODO: Not ideal to hard coded!
// The heights of each track
export const getTrackData = (
export const getTrackDocData = (
isMinimalMode: boolean
): { height: number; type: Track; title: string; popover_content?: string }[] => {
return [
Expand Down

0 comments on commit 57470cc

Please sign in to comment.