Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IntlProvider } from 'react-intl';
import { getMessagesForLocale } from './localization/localization';
import { LayoutContainer } from './components/LayoutContainer';
import { SettingsProvider } from './components/SettingsContext';
import { TemplatesProvider } from './components/TemplatesContext';

const App = () => {
const [locale, setLocale] = useState<Locale>("en");
Expand All @@ -25,7 +26,9 @@ const App = () => {
return (
<IntlProvider locale={locale} messages={messages}>
<SettingsProvider>
<LayoutContainer id='homeContainer' />
<TemplatesProvider>
<LayoutContainer id='homeContainer' />
</TemplatesProvider>
</SettingsProvider>
</IntlProvider>
);
Expand Down
Binary file added src/assets/dyfIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/dynIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/dytIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 13 additions & 7 deletions src/assets/home.ts

Large diffs are not rendered by default.

78 changes: 55 additions & 23 deletions src/components/Common/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,78 @@
import { useState, useRef, useEffect, CSSProperties } from 'react';
import Portal from './Portal'; // Import your Portal component

export const Tooltip = ({ children, content, verticalOffset = 12 }: Tooltip) => {
export const Tooltip = ({ children, content, verticalOffset = 12, position: positionProp }: Tooltip) => {
const [show, setShow] = useState<boolean>(false);
const [position, setPosition] = useState<CSSProperties>({});
const tooltipRef = useRef(null);
const contentRef = useRef(null); // Ref for the tooltip content

useEffect(() => {
if (tooltipRef.current && contentRef.current && show) {
const targetRect = tooltipRef.current.getBoundingClientRect();
const tooltipRect = contentRef.current.getBoundingClientRect();

let left = targetRect.left + window.scrollX + (targetRect.width / 2); // Center align
const top = targetRect.bottom + window.scrollY + verticalOffset;

// Check if the tooltip is going off the right side of the screen
if (left + tooltipRect.width > window.innerWidth) {
left = window.innerWidth - tooltipRect.width / 2 - 10; // Adjust to keep it on screen
}
// Check if the tooltip is going off the left side of the screen
if (left - tooltipRect.width / 2 < 0) {
left += 10; // Adjust to keep it on screen
}

setPosition({
top: top,
left: left,
position: 'absolute'
// Use requestAnimationFrame to ensure tooltip is rendered and measured correctly
requestAnimationFrame(() => {
if (tooltipRef.current && contentRef.current) {
const targetRect = tooltipRef.current.getBoundingClientRect();
const tooltipRect = contentRef.current.getBoundingClientRect();

let left: number;
let top: number;

// If position prop is 'right', position to the right of the element
if (positionProp === 'right') {
left = targetRect.right + window.scrollX + verticalOffset;
top = targetRect.top + window.scrollY + (targetRect.height / 2) - (tooltipRect.height / 2);

// Check if the tooltip is going off the right side of the screen
if (left + tooltipRect.width > window.innerWidth + window.scrollX) {
// If it goes off right, position it to the left of the element instead
left = targetRect.left + window.scrollX - tooltipRect.width - verticalOffset;
}
} else {
// Default: position tooltip below the element (centered)
left = targetRect.left + window.scrollX + (targetRect.width / 2);
top = targetRect.bottom + window.scrollY + verticalOffset;

// Check if the tooltip is going off the right side of the screen
if (left + tooltipRect.width / 2 > window.innerWidth + window.scrollX) {
left = window.innerWidth + window.scrollX - tooltipRect.width / 2 - 10;
}
// Check if the tooltip is going off the left side of the screen
if (left - tooltipRect.width / 2 < window.scrollX) {
left = window.scrollX + tooltipRect.width / 2 + 10;
}
}

// Check if the tooltip is going off the top of the screen
if (top < window.scrollY) {
top = window.scrollY + 10;
}
// Check if the tooltip is going off the bottom of the screen
if (top + tooltipRect.height > window.innerHeight + window.scrollY) {
top = window.innerHeight + window.scrollY - tooltipRect.height - 10;
}

setPosition({
top: top,
left: left,
position: 'absolute',
// For default positioning (below), center using transform
transform: positionProp === 'right' ? 'none' : 'translateX(-50%)'
});
}
});
}
}, [show, content, verticalOffset]); // Added 'content' to dependencies array
}, [show, content, verticalOffset, positionProp]);

return (
<span className="tooltip-wrapper"
<span className="tooltip-wrapper"
onMouseEnter={() => setShow(true)}
onMouseLeave={() => setShow(false)}
ref={tooltipRef}>
{children}
{show && (
<Portal>
<div className={`tooltip-box ${show ? 'show' : ''}`} ref={contentRef} style={position}>
<div className={`tooltip-box ${show ? 'show' : ''} ${positionProp === 'right' ? 'arrow-left' : ''}`} ref={contentRef} style={position}>
Comment thread
johnpierson marked this conversation as resolved.
<div className="tooltip-arrow" />
<div style={{ whiteSpace: 'pre-line' }}>{content}</div>
</div>
Expand Down
13 changes: 3 additions & 10 deletions src/components/LayoutContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import { MainContent } from './MainContent';
import { Sidebar } from './Sidebar/Sidebar';
import SplitPane from 'react-split-pane';
import { useSettings } from './SettingsContext';
import { saveHomePageSettings } from '../functions/utility';

export const LayoutContainer = ({ id }: { id?: string }) => {
const defaultMinSize = 250;
const defaultMaxSize = 500;
const defaultBarWidth = 300;

const { settings, updateSettings } = useSettings();
const { settings, updateSettings, updateAndSaveSettings } = useSettings();
const [isDisabled, setIsDisabled] = useState<boolean>(false);
const [selectedSidebarItem, setSelectedSidebarItem] = useState<SidebarItem>('Recent');
const [sideBarWidth, setSideBarWidth] = useState<number | null>(null);
Expand All @@ -28,8 +27,8 @@ export const LayoutContainer = ({ id }: { id?: string }) => {
const handleSplitPaneResize = (size: number) => {
setSideBarWidth(size);

// Persist the new sidebar width in settings
updateSettings({ sideBarWidth: size.toString() });
// persist the new sidebar width using latest merged settings.
updateAndSaveSettings({ sideBarWidth: size.toString() });
};

useEffect(() => {
Expand All @@ -40,12 +39,6 @@ export const LayoutContainer = ({ id }: { id?: string }) => {
}
}, [settings?.sideBarWidth]);

useEffect(() => {
if (sideBarWidth !== null && settings) {
saveHomePageSettings({ ...settings, sideBarWidth: sideBarWidth.toString() });
}
}, [sideBarWidth]);

const setHomePageSettings = (settingsJson: string) => {
try {
if (settingsJson) {
Expand Down
6 changes: 5 additions & 1 deletion src/components/MainContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export const MainContent = ({ selectedSidebarItem, settings, isDisabled, setIsDi
)}

<div className={`page-container ${selectedSidebarItem === 'Recent' ? '' : 'hidden'}`}>
<RecentPage setIsDisabled={setIsDisabled} recentPageViewMode={settings?.recentPageViewMode || "grid"} />
<RecentPage
setIsDisabled={setIsDisabled}
recentPageViewMode={settings?.recentPageViewMode || 'grid'}
templatesPageViewMode={settings?.templatesPageViewMode || 'grid'}
/>
</div>
<div className={`page-container ${selectedSidebarItem === 'Samples' ? '' : 'hidden'}`}>
<SamplesPage samplesViewMode={settings?.samplesViewMode || "grid"} />
Expand Down
8 changes: 6 additions & 2 deletions src/components/Recent/CustomNameCellRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { img } from '../../assets/home';
import { getPlaceholderImage } from '../../functions/placeholder';
import { Tooltip } from '../Common/Tooltip';
import styles from './CustomCellRenderer.module.css';
import cardStyles from '../Common/CardItems.module.css';
import { img } from '../../assets/home';


/**
Expand All @@ -10,7 +11,10 @@ import cardStyles from '../Common/CardItems.module.css';
* @param row - the data associate with this row containing all the information for the graph
*/
export const CustomNameCellRenderer = ({ value, row }: CellParams) => {
const imgSrc = row.original.Thumbnail || img;
// Use placeholder if Thumbnail is empty, null, undefined, or the default img
const thumbnail = row.original.Thumbnail;
const hasCustomThumbnail = thumbnail && thumbnail !== img && thumbnail.trim() !== '';
const imgSrc = hasCustomThumbnail ? thumbnail : getPlaceholderImage(row.original.ContextData);
const description = row.original.Description;
return (
<div className={styles["title-cell"]}>
Expand Down
12 changes: 9 additions & 3 deletions src/components/Recent/GraphGridItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { img } from '../../assets/home';
import { getPlaceholderImage } from '../../functions/placeholder';
import { openFile } from '../../functions/utility';
import { CardItem } from '../Common/CardItem';
import { img } from '../../assets/home';

export const GraphGridItem = ({ id, Caption, ContextData, Description, DateModified, Thumbnail, setIsDisabled }: GraphItem) => {
const handleClick = (e:MouseEvent) => {
Expand All @@ -11,9 +12,14 @@ export const GraphGridItem = ({ id, Caption, ContextData, Description, DateModif
openFile(ContextData);
};

// Use placeholder if Thumbnail is empty, null, undefined, or the default img
const thumbnail = Thumbnail;
const hasCustomThumbnail = thumbnail && thumbnail !== img && thumbnail.trim() !== '';
const imageSrc = hasCustomThumbnail ? thumbnail : getPlaceholderImage(ContextData);

return (
<CardItem
imageSrc={Thumbnail || img}
imageSrc={imageSrc}
onClick={handleClick}
tooltipContent={
<>
Expand All @@ -26,4 +32,4 @@ export const GraphGridItem = ({ id, Caption, ContextData, Description, DateModif
subtitleText={DateModified}
/>
);
}
};
1 change: 0 additions & 1 deletion src/components/Recent/GraphTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const GraphTable = ({ columns, data, onRowClick }: GraphTable) => {
<div className={styles['table-container']}>
<table {...getTableProps()}>
<thead>
{console.log(headerGroups)}
{headerGroups.map((headerGroup) => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map((column: any, columnIndex: number) => (
Expand Down
Loading
Loading