Skip to content

Commit 15543b1

Browse files
committed
Revert "Dyn 10225 add default placeholder images in dynamo app home (#71)"
This reverts commit 2adc45b.
1 parent 183be9f commit 15543b1

23 files changed

Lines changed: 87 additions & 367 deletions

package-lock.json

Lines changed: 1 addition & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { IntlProvider } from 'react-intl';
44
import { getMessagesForLocale } from './localization/localization';
55
import { LayoutContainer } from './components/LayoutContainer';
66
import { SettingsProvider } from './components/SettingsContext';
7-
import { TemplatesProvider } from './components/TemplatesContext';
87

98
const App = () => {
109
const [locale, setLocale] = useState<Locale>("en");
@@ -26,9 +25,7 @@ const App = () => {
2625
return (
2726
<IntlProvider locale={locale} messages={messages}>
2827
<SettingsProvider>
29-
<TemplatesProvider>
30-
<LayoutContainer id='homeContainer' />
31-
</TemplatesProvider>
28+
<LayoutContainer id='homeContainer' />
3229
</SettingsProvider>
3330
</IntlProvider>
3431
);

src/assets/dyfIcon.png

-40.7 KB
Binary file not shown.

src/assets/dynIcon.png

-41.8 KB
Binary file not shown.

src/assets/dytIcon.png

-40.1 KB
Binary file not shown.

src/assets/home.ts

Lines changed: 7 additions & 13 deletions
Large diffs are not rendered by default.

src/components/Common/Tooltip.tsx

Lines changed: 23 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,46 @@
11
import { useState, useRef, useEffect, CSSProperties } from 'react';
22
import Portal from './Portal'; // Import your Portal component
33

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

1010
useEffect(() => {
1111
if (tooltipRef.current && contentRef.current && show) {
12-
// Use requestAnimationFrame to ensure tooltip is rendered and measured correctly
13-
requestAnimationFrame(() => {
14-
if (tooltipRef.current && contentRef.current) {
15-
const targetRect = tooltipRef.current.getBoundingClientRect();
16-
const tooltipRect = contentRef.current.getBoundingClientRect();
17-
18-
let left: number;
19-
let top: number;
20-
21-
// If position prop is 'right', position to the right of the element
22-
if (positionProp === 'right') {
23-
left = targetRect.right + window.scrollX + verticalOffset;
24-
top = targetRect.top + window.scrollY + (targetRect.height / 2) - (tooltipRect.height / 2);
25-
26-
// Check if the tooltip is going off the right side of the screen
27-
if (left + tooltipRect.width > window.innerWidth + window.scrollX) {
28-
// If it goes off right, position it to the left of the element instead
29-
left = targetRect.left + window.scrollX - tooltipRect.width - verticalOffset;
30-
}
31-
} else {
32-
// Default: position tooltip below the element (centered)
33-
left = targetRect.left + window.scrollX + (targetRect.width / 2);
34-
top = targetRect.bottom + window.scrollY + verticalOffset;
35-
36-
// Check if the tooltip is going off the right side of the screen
37-
if (left + tooltipRect.width / 2 > window.innerWidth + window.scrollX) {
38-
left = window.innerWidth + window.scrollX - tooltipRect.width / 2 - 10;
39-
}
40-
// Check if the tooltip is going off the left side of the screen
41-
if (left - tooltipRect.width / 2 < window.scrollX) {
42-
left = window.scrollX + tooltipRect.width / 2 + 10;
43-
}
44-
}
45-
46-
// Check if the tooltip is going off the top of the screen
47-
if (top < window.scrollY) {
48-
top = window.scrollY + 10;
49-
}
50-
// Check if the tooltip is going off the bottom of the screen
51-
if (top + tooltipRect.height > window.innerHeight + window.scrollY) {
52-
top = window.innerHeight + window.scrollY - tooltipRect.height - 10;
53-
}
54-
55-
setPosition({
56-
top: top,
57-
left: left,
58-
position: 'absolute',
59-
// For default positioning (below), center using transform
60-
transform: positionProp === 'right' ? 'none' : 'translateX(-50%)'
61-
});
62-
}
12+
const targetRect = tooltipRef.current.getBoundingClientRect();
13+
const tooltipRect = contentRef.current.getBoundingClientRect();
14+
15+
let left = targetRect.left + window.scrollX + (targetRect.width / 2); // Center align
16+
const top = targetRect.bottom + window.scrollY + verticalOffset;
17+
18+
// Check if the tooltip is going off the right side of the screen
19+
if (left + tooltipRect.width > window.innerWidth) {
20+
left = window.innerWidth - tooltipRect.width / 2 - 10; // Adjust to keep it on screen
21+
}
22+
// Check if the tooltip is going off the left side of the screen
23+
if (left - tooltipRect.width / 2 < 0) {
24+
left += 10; // Adjust to keep it on screen
25+
}
26+
27+
setPosition({
28+
top: top,
29+
left: left,
30+
position: 'absolute'
6331
});
6432
}
65-
}, [show, content, verticalOffset, positionProp]);
33+
}, [show, content, verticalOffset]); // Added 'content' to dependencies array
6634

6735
return (
68-
<span className="tooltip-wrapper"
36+
<span className="tooltip-wrapper"
6937
onMouseEnter={() => setShow(true)}
7038
onMouseLeave={() => setShow(false)}
7139
ref={tooltipRef}>
7240
{children}
7341
{show && (
7442
<Portal>
75-
<div className={`tooltip-box ${show ? 'show' : ''} ${positionProp === 'right' ? 'arrow-left' : ''}`} ref={contentRef} style={position}>
43+
<div className={`tooltip-box ${show ? 'show' : ''}`} ref={contentRef} style={position}>
7644
<div className="tooltip-arrow" />
7745
<div style={{ whiteSpace: 'pre-line' }}>{content}</div>
7846
</div>

src/components/LayoutContainer.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import { MainContent } from './MainContent';
33
import { Sidebar } from './Sidebar/Sidebar';
44
import SplitPane from 'react-split-pane';
55
import { useSettings } from './SettingsContext';
6+
import { saveHomePageSettings } from '../functions/utility';
67

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

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

30-
// persist the new sidebar width using latest merged settings.
31-
updateAndSaveSettings({ sideBarWidth: size.toString() });
31+
// Persist the new sidebar width in settings
32+
updateSettings({ sideBarWidth: size.toString() });
3233
};
3334

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

43+
useEffect(() => {
44+
if (sideBarWidth !== null && settings) {
45+
saveHomePageSettings({ ...settings, sideBarWidth: sideBarWidth.toString() });
46+
}
47+
}, [sideBarWidth]);
48+
4249
const setHomePageSettings = (settingsJson: string) => {
4350
try {
4451
if (settingsJson) {

src/components/MainContent.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ export const MainContent = ({ selectedSidebarItem, settings, isDisabled, setIsDi
1717
)}
1818

1919
<div className={`page-container ${selectedSidebarItem === 'Recent' ? '' : 'hidden'}`}>
20-
<RecentPage
21-
setIsDisabled={setIsDisabled}
22-
recentPageViewMode={settings?.recentPageViewMode || 'grid'}
23-
templatesPageViewMode={settings?.templatesPageViewMode || 'grid'}
24-
/>
20+
<RecentPage setIsDisabled={setIsDisabled} recentPageViewMode={settings?.recentPageViewMode || "grid"} />
2521
</div>
2622
<div className={`page-container ${selectedSidebarItem === 'Samples' ? '' : 'hidden'}`}>
2723
<SamplesPage samplesViewMode={settings?.samplesViewMode || "grid"} />

src/components/Recent/CustomNameCellRenderer.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { getPlaceholderImage } from '../../functions/placeholder';
1+
import { img } from '../../assets/home';
22
import { Tooltip } from '../Common/Tooltip';
33
import styles from './CustomCellRenderer.module.css';
44
import cardStyles from '../Common/CardItems.module.css';
5-
import { img } from '../../assets/home';
65

76

87
/**
@@ -11,10 +10,7 @@ import { img } from '../../assets/home';
1110
* @param row - the data associate with this row containing all the information for the graph
1211
*/
1312
export const CustomNameCellRenderer = ({ value, row }: CellParams) => {
14-
// Use placeholder if Thumbnail is empty, null, undefined, or the default img
15-
const thumbnail = row.original.Thumbnail;
16-
const hasCustomThumbnail = thumbnail && thumbnail !== img && thumbnail.trim() !== '';
17-
const imgSrc = hasCustomThumbnail ? thumbnail : getPlaceholderImage(row.original.ContextData);
13+
const imgSrc = row.original.Thumbnail || img;
1814
const description = row.original.Description;
1915
return (
2016
<div className={styles["title-cell"]}>

0 commit comments

Comments
 (0)