Skip to content

Commit 3da1788

Browse files
authored
refactor: clean-up unused imports & fix types errors (#100)
* refactor: remove debug log from useAppConfig hook - Removed the console log statement for 'data' in the useAppConfig hook to clean up the code and improve performance. * refactor: clean up index.tsx by removing commented-out code - Removed commented-out PostHogProvider and related code to streamline the index.tsx file. - Ensured the StrictMode wrapper is correctly applied around the QueryClientProvider and application components for better performance and debugging. * refactor: clean up import statement in AuthGate.tsx - Removed unnecessary comment from the import statement for useAppConfig to improve code clarity. * refactor: simplify handleOnScrollChange function in App component - Updated the handleOnScrollChange function to remove unnecessary parameters, enhancing code clarity and maintainability. * chore: add TypeScript types for React and ReactDOM - Added `@types/react` and `@types/react-dom` as devDependencies in package.json for improved TypeScript support. - Updated yarn.lock to include the new type definitions and their dependencies. * refactor: remove hover styles from dropdown menu button in Excalidraw overrides - Eliminated hover background color styles for the dropdown menu button in the _excalidraw-overrides.scss file to streamline the CSS and improve maintainability. * refactor: update AuthDialog component and styles - Removed unnecessary comment from AuthDialog.scss to streamline the styles. - Changed the type of `warningText` prop in AuthDialog from string to React.ReactNode for better flexibility in rendering content. * refactor: reorganize imports and enhance MainMenu component - Moved the import statements for AccountDialog and MainMenu.scss to improve code organization. - Added spacing for better readability in the MainMenu.tsx file. * feat: add default CSS variables for consistent styling - Introduced a new _defaults.scss file to define CSS variables for slider and range track styles. - Updated index.scss to include the new defaults for improved styling consistency across components. * refactor: remove CSS variables from Range.scss for cleaner styling - Eliminated default CSS variables for slider and range track styles from Range.scss to streamline the styling process. - Added appearance property to the range input for improved cross-browser compatibility. * refactor: clean up imports in TabContextMenu component - Removed unused useState import from TabContextMenu.tsx to enhance code clarity and reduce unnecessary dependencies. * refactor: improve tab title reference assignment in Tabs component - Updated the ref assignment for tab titles to use a block statement for better readability and consistency in the Tabs.tsx file. * refactor: enhance type safety in Collab component - Updated the type casting for user_id in the Collab component to ensure proper type handling of SocketId, improving code reliability and clarity. * refactor: update App and MainMenu components for settings management - Removed unused state and handlers related to the SettingsDialog in App.tsx to streamline the component. - Added state management and conditional rendering for SettingsDialog in MainMenu.tsx, enhancing user experience and functionality. * refactor: introduce UserSettings type and update constants - Added UserSettings interface in a new types.ts file to define user settings structure. - Introduced DEFAULT_SETTINGS constant in constants.ts for default user settings. - Updated imports in SettingsDialog and canvas files to reference the new constants and types, enhancing code organization and type safety. * refactor: clean up App component by removing unused settings-related code - Removed commented-out imports, state, and handlers related to SettingsDialog in App.tsx to streamline the component and improve code clarity.
1 parent e26d47a commit 3da1788

20 files changed

+78
-86
lines changed

src/frontend/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@import 'src/css/_colors.scss';
22
@import 'src/css/_excalidraw-overrides.scss';
33
@import 'src/css/_fonts.scss';
4+
@import 'src/css/_defaults.scss';
45

56
/* Makes excalidraw fill the entire screen */
67
#root {

src/frontend/index.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,28 @@
11
import React, { StrictMode } from "react";
22
import { createRoot } from "react-dom/client";
3+
34
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
45
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
56

6-
// import posthog from "./src/lib/posthog";
7-
// import { PostHogProvider } from 'posthog-js/react';
8-
97
import "@atyrode/excalidraw/index.css";
108
import "./index.scss";
119

1210
import App from "./src/App";
1311
import AuthGate from "./src/AuthGate";
1412

15-
16-
// Create a client
1713
const queryClient = new QueryClient();
1814

1915
async function initApp() {
2016
const rootElement = document.getElementById("root")!;
2117
const root = createRoot(rootElement);
2218
root.render(
23-
// <StrictMode>
19+
<StrictMode>
2420
<QueryClientProvider client={queryClient}>
25-
{/* <PostHogProvider client={posthog}> */}
26-
<AuthGate />
27-
<App />
28-
{/* </PostHogProvider> */}
21+
<AuthGate />
22+
<App />
2923
<ReactQueryDevtools initialIsOpen={false} />
3024
</QueryClientProvider>
31-
// </StrictMode>,
25+
</StrictMode>,
3226
);
3327
}
3428

src/frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
},
2727
"devDependencies": {
2828
"@types/node": "^22.14.0",
29+
"@types/react": "^19.0.0",
30+
"@types/react-dom": "^19.0.0",
2931
"typescript": "^5",
3032
"vite": "5.2.0"
3133
},

src/frontend/src/App.tsx

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { useAppConfig } from "./hooks/useAppConfig";
1313
import DiscordButton from './ui/DiscordButton';
1414
import { MainMenuConfig } from './ui/MainMenu';
1515
import AuthDialog from './ui/AuthDialog';
16-
import SettingsDialog from './ui/SettingsDialog';
1716
import Collab from './lib/collab/Collab';
1817

1918
// Utils
@@ -39,15 +38,9 @@ export default function App() {
3938
leaveSharedPad
4039
} = usePadTabs(isAuthenticated);
4140

42-
const [showSettingsModal, setShowSettingsModal] = useState(false);
4341
const [excalidrawAPI, excalidrawRefCallback] = useCallbackRefState<ExcalidrawImperativeAPI>();
4442

45-
46-
const handleCloseSettingsModal = () => {
47-
setShowSettingsModal(false);
48-
};
49-
50-
const handleOnScrollChange = (scrollX: number, scrollY: number) => {
43+
const handleOnScrollChange = () => {
5144
lockEmbeddables(excalidrawAPI?.getAppState());
5245
};
5346

@@ -84,19 +77,10 @@ export default function App() {
8477
<MainMenuConfig
8578
MainMenu={MainMenu}
8679
excalidrawAPI={excalidrawAPI}
87-
showSettingsModal={showSettingsModal}
88-
setShowSettingsModal={setShowSettingsModal}
8980
/>
9081

9182
{!isLoadingAuth && !isAuthenticated && (
92-
<AuthDialog onClose={() => { }} />
93-
)}
94-
95-
{showSettingsModal && (
96-
<SettingsDialog
97-
excalidrawAPI={excalidrawAPI}
98-
onClose={handleCloseSettingsModal}
99-
/>
83+
<AuthDialog />
10084
)}
10185

10286
{excalidrawAPI && (

src/frontend/src/AuthGate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useRef, useState } from "react";
2-
import { useAppConfig } from "./hooks/useAppConfig"; // Import useAppConfig
2+
import { useAppConfig } from "./hooks/useAppConfig";
33
import { useAuthStatus } from "./hooks/useAuthStatus";
44

55
/**

src/frontend/src/constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { UserSettings } from "./ui/types";
2+
13
// Default app values
24
export const INITIAL_APP_DATA = {
35
appState: {
@@ -24,3 +26,8 @@ export const HIDDEN_UI_ELEMENTS = {
2426
export const POINTER_MOVE_THROTTLE_MS = 30; // Throttle pointer move events to reduce the number of updates sent to the server
2527
export const ENABLE_PERIODIC_FULL_SYNC = false; // Set to false to disable periodic scene_update full sync
2628
export const PERIODIC_FULL_SYNC_INTERVAL_MS = 60000; // Sync scene_update every 60 seconds if ENABLE_PERIODIC_FULL_SYNC is true
29+
30+
// Pad constants
31+
export const DEFAULT_SETTINGS: UserSettings = {
32+
embedLockDebounceTime: 350,
33+
};

src/frontend/src/css/_defaults.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
:root {
2+
--slider-thumb-size: 16px;
3+
--range-track-filled: #{$accent};
4+
--range-track-unfilled: #{$grey-800};
5+
--range-thumb-color: #{$accent-dark};
6+
}

src/frontend/src/css/_excalidraw-overrides.scss

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@
4848
--color-surface-primary-container: #{$accent-light} !important;
4949
--color-selection: #{$accent-lighter} !important;
5050

51-
.dropdown-menu-button {
52-
&:hover {
53-
background-color: $accent-faded-light !important;
54-
}
55-
}
56-
5751
.dropdown-menu-group-title {
5852
color: $accent-lighter !important;
5953
}
@@ -67,11 +61,6 @@
6761
--color-surface-primary-container: #{$accent} !important;
6862
--color-selection: #{$accent-darker} !important;
6963

70-
.dropdown-menu-button {
71-
&:hover {
72-
background-color: $accent-faded-dark !important;
73-
}
74-
}
7564
.dropdown-menu-group-title {
7665
color: $accent-darker !important;
7766
}

src/frontend/src/hooks/useAppConfig.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const useAppConfig = () => {
3232
gcTime: Infinity, // Renamed from cacheTime in v5
3333
});
3434

35-
console.log('data', data);
3635
return {
3736
config: data,
3837
isLoadingConfig: isLoading,

src/frontend/src/lib/canvas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DEFAULT_SETTINGS } from '../types/settings';
1+
import { DEFAULT_SETTINGS } from '../constants';
22

33
/**
44
*

0 commit comments

Comments
 (0)