Skip to content

Commit

Permalink
Reserve space in hovercard using CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
cheap-glitch committed Jun 2, 2021
1 parent ca3acf3 commit 5964125
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions source/features/user-local-time.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* Reserve some space in the hovercard to fix #4345 */
.js-hovercard-content .Popover-message div.d-flex.mt-3 > div.overflow-hidden.ml-3:not(.rgh-user-local-time-container-added) {
/* 26px is the height of the div that is being inserted plus its margin TODO */
padding-bottom: 26px !important;
}
5 changes: 3 additions & 2 deletions source/features/user-local-time.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-await-in-loop */

import './user-local-time.css';
import React from 'dom-chef';
import cache from 'webext-storage-cache';
import delay from 'delay';
Expand Down Expand Up @@ -78,7 +79,7 @@ function parseOffset(date: string): number {
}

function init(): void {
observe('.js-hovercard-content div.d-flex.mt-3 > div.overflow-hidden.ml-3:not(.rgh-user-local-time-added)', {
observe('.js-hovercard-content .Popover-message div.d-flex.mt-3 > div.overflow-hidden.ml-3:not(.rgh-user-local-time-container-added)', {
add: async hovercardContainer => {
const hovercard = hovercardContainer.closest<HTMLElement>('.Popover-message')!;
if (!select.exists('[data-hydro-view*="user-hovercard-hover"]', hovercard)) {
Expand All @@ -91,7 +92,7 @@ function init(): void {
return;
}

hovercardContainer.classList.add('rgh-user-local-time-added');
hovercardContainer.classList.add('rgh-user-local-time-container-added');

const datePromise = getLastCommitDate(login);
const race = await Promise.race([delay(300), datePromise]);
Expand Down

1 comment on commit 5964125

@yakov116
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a GIF of this working?

Please sign in to comment.