Skip to content

Commit 9adda61

Browse files
authored
Fixed linting. Added dark mode fix for graphs (#743)
1 parent f02c147 commit 9adda61

File tree

3 files changed

+86
-41
lines changed

3 files changed

+86
-41
lines changed

src/chart/graph/GraphChart.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ const NeoGraphChart = (props: ChartProps) => {
125125
});
126126

127127
const pageNames = getPageNumbersAndNamesList();
128-
129128
const chartProps: GraphChartVisualizationProps = {
130129
data: {
131130
nodes: data.nodes,
@@ -142,12 +141,12 @@ const NeoGraphChart = (props: ChartProps) => {
142141
style: {
143142
width: width,
144143
height: height,
145-
backgroundColor: settings.backgroundColor,
144+
backgroundColor: theme == 'dark' && settings.backgroundColor == '#fafafa' ? '#040404' : settings.backgroundColor, // Temporary fix for default color adjustment in dark mode
146145
linkDirectionalParticles: linkDirectionalParticles,
147146
linkDirectionalArrowLength: arrowLengthProp,
148147
linkDirectionalParticleSpeed: settings.linkDirectionalParticleSpeed,
149148
nodeLabelFontSize: settings.nodeLabelFontSize,
150-
nodeLabelColor: settings.nodeLabelColor,
149+
nodeLabelColor: theme == 'dark' && settings.nodeLabelColor == 'black' ? 'white' : settings.nodeLabelColor, // Temporary fix for default color adjustment in dark mode
151150
relLabelFontSize: settings.relLabelFontSize,
152151
relLabelColor: settings.relLabelColor,
153152
defaultNodeSize: settings.defaultNodeSize,

src/dashboard/header/DashboardHeaderPageTitle.tsx

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import classnames from 'classnames';
44
import debounce from 'lodash/debounce';
55
import { setPageTitle } from '../../page/PageActions';
66
import { removePageThunk } from '../DashboardThunks';
7-
import { Tab, Menu, MenuItems, MenuItem, IconButton, TextInput } from '@neo4j-ndl/react';
7+
import { Tab, Menu, MenuItems, MenuItem, IconButton } from '@neo4j-ndl/react';
88
import { EllipsisHorizontalIconOutline, PencilIconOutline, TrashIconOutline } from '@neo4j-ndl/react/icons';
99
import { NeoDeletePageModal } from '../../modal/DeletePageModal';
1010
import { useSortable } from '@dnd-kit/sortable';
@@ -17,12 +17,9 @@ export const DashboardHeaderPageTitle = ({ title, tabIndex, removePage, setPageT
1717
const menuOpen = Boolean(anchorEl);
1818
const [deleteModalOpen, setDeleteModalOpen] = React.useState(false);
1919
const [editing, setEditing] = React.useState(false);
20-
20+
const [inputWidth, setInputWidth] = React.useState(125);
2121
const handleMenuEditClick = (event: MenuEditEvent) => {
2222
event.preventDefault();
23-
if (editing) {
24-
debouncedSetPageTitle(tabIndex, titleText);
25-
}
2623
setEditing(!editing);
2724
setAnchorEl(null);
2825
};
@@ -49,7 +46,7 @@ export const DashboardHeaderPageTitle = ({ title, tabIndex, removePage, setPageT
4946
transition,
5047
};
5148

52-
const debouncedSetPageTitle = useCallback(debounce(setPageTitle, 250), []);
49+
const debouncedSetPageTitle = useCallback(debounce(setPageTitle, 200), []);
5350

5451
const [titleText, setTitleText] = React.useState(title);
5552
useEffect(() => {
@@ -69,24 +66,46 @@ export const DashboardHeaderPageTitle = ({ title, tabIndex, removePage, setPageT
6966
'(no title)'
7067
)
7168
) : (
72-
<TextInput
73-
data-no-dnd='true'
74-
autoFocus={true}
75-
value={titleText}
76-
onChange={(event) => {
77-
if (disabled) {
78-
return;
69+
<form
70+
onSubmit={(event) => {
71+
if (editing) {
72+
handleMenuEditClick(event);
7973
}
80-
setTitleText(event.target.value);
8174
}}
82-
style={{
83-
textAlign: 'center',
84-
height: '1.9rem',
85-
}}
86-
placeholder='Page name...'
87-
/>
75+
>
76+
<input
77+
data-no-dnd='true'
78+
autoFocus={true}
79+
value={titleText}
80+
className=''
81+
onBlur={(event) => {
82+
if (editing) {
83+
handleMenuEditClick(event);
84+
}
85+
}}
86+
onChange={(event) => {
87+
const {target} = event;
88+
target.style.width = '125px';
89+
setInputWidth(target.scrollWidth);
90+
91+
if (disabled) {
92+
return;
93+
}
94+
setTitleText(event.target.value);
95+
debouncedSetPageTitle(tabIndex, event.target.value);
96+
}}
97+
style={{
98+
height: '1.9rem',
99+
marginBottom: -5,
100+
width: inputWidth,
101+
paddingLeft: 5,
102+
paddingRight: 5,
103+
}}
104+
placeholder='Page name...'
105+
/>
106+
</form>
88107
)}
89-
{!disabled && (
108+
{!disabled && !editing && (
90109
<>
91110
<IconButton
92111
aria-label='Page actions'
@@ -107,9 +126,12 @@ export const DashboardHeaderPageTitle = ({ title, tabIndex, removePage, setPageT
107126
<MenuItems>
108127
<MenuItem
109128
icon={<PencilIconOutline />}
110-
title={editing ? 'Stop Editing' : 'Edit name'}
129+
title={'Edit name'}
111130
onClick={(e) => {
112131
e.stopPropagation();
132+
if (editing) {
133+
debouncedSetPageTitle(tabIndex, titleText);
134+
}
113135
!disabled && handleMenuEditClick(e);
114136
}}
115137
/>

src/dashboard/header/DashboardTitle.tsx

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import { getDashboardTitle, getDashboardExtensions, getDashboardSettings } from
77
import { getDashboardIsEditable } from '../../settings/SettingsSelectors';
88
import { updateDashboardSetting } from '../../settings/SettingsActions';
99
import { Typography, IconButton, Menu, MenuItems, TextInput } from '@neo4j-ndl/react';
10-
import { CheckBadgeIconOutline, EllipsisHorizontalIconOutline, PencilSquareIconOutline } from '@neo4j-ndl/react/icons';
10+
import {
11+
CheckBadgeIconOutline,
12+
CheckIconOutline,
13+
EllipsisHorizontalIconOutline,
14+
PencilSquareIconOutline,
15+
} from '@neo4j-ndl/react/icons';
1116
import NeoSettingsModal from '../../settings/SettingsModal';
1217
import NeoExtensionsModal from '../../extensions/ExtensionsModal';
1318
import { EXTENSIONS_DRAWER_BUTTONS } from '../../extensions/ExtensionConfig';
@@ -31,7 +36,7 @@ export const NeoDashboardTitle = ({
3136
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
3237
const [editing, setEditing] = React.useState(false);
3338
const debouncedDashboardTitleUpdate = useCallback(debounce(setDashboardTitle, 250), []);
34-
39+
const [inputWidth, setInputWidth] = React.useState(350);
3540
const handleSettingsMenuOpen = (event: SettingsMenuOpenEvent) => {
3641
setAnchorEl(event.currentTarget);
3742
};
@@ -70,21 +75,40 @@ export const NeoDashboardTitle = ({
7075
{/* only allow edit title if dashboard is not standalone - here we are in Title edit mode*/}
7176
{editing && !standaloneSettings.standalone ? (
7277
<div className={'n-flex n-flex-row n-flex-wrap n-justify-between n-items-center'}>
73-
<TextInput
74-
autoFocus={true}
75-
value={dashboardTitleText}
76-
style={{
77-
textAlign: 'center',
78-
height: '1.9rem',
79-
}}
80-
placeholder='Dashboard name...'
81-
onChange={(event) => {
82-
if (editable) {
83-
setDashboardTitleText(event.target.value);
84-
debouncedDashboardTitleUpdate(event.target.value);
78+
<form
79+
onSubmit={() => {
80+
if (editing) {
81+
setEditing(false);
8582
}
8683
}}
87-
/>
84+
>
85+
<input
86+
autoFocus={true}
87+
value={dashboardTitleText}
88+
style={{
89+
height: '1.9rem',
90+
fontSize: '1.875rem', // h3
91+
fontWeight: 700, // h3
92+
padding: 10,
93+
width: inputWidth,
94+
}}
95+
placeholder='Dashboard name...'
96+
onBlur={() => {
97+
if (editing) {
98+
setEditing(false);
99+
}
100+
}}
101+
onChange={(event) => {
102+
if (editable) {
103+
const {target} = event;
104+
target.style.width = '350px';
105+
setInputWidth(target.scrollWidth);
106+
setDashboardTitleText(event.target.value);
107+
debouncedDashboardTitleUpdate(event.target.value);
108+
}
109+
}}
110+
/>
111+
</form>
88112
<Tooltip title={'Stop Editing'} disableInteractive>
89113
<IconButton
90114
className='logo-btn n-p-1'
@@ -93,7 +117,7 @@ export const NeoDashboardTitle = ({
93117
onClick={() => setEditing(false)}
94118
clean
95119
>
96-
<CheckBadgeIconOutline className='header-icon' type='outline' />
120+
<CheckIconOutline className='header-icon' type='outline' />
97121
</IconButton>
98122
</Tooltip>
99123
</div>

0 commit comments

Comments
 (0)