Skip to content

Commit

Permalink
feat(react-components): adding a fps display
Browse files Browse the repository at this point in the history
  • Loading branch information
mnischay authored and diehbria committed Jan 5, 2024
1 parent 1bff986 commit 48cd9ef
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
16 changes: 16 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions packages/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"react-dnd-html5-backend": "^16.0.1",
"react-dnd-touch-backend": "^16.0.1",
"react-error-boundary": "^4.0.10",
"react-fps": "^1.0.6",
"react-hook-form": "^7.46.1",
"react-hotkeys": "^2.0.0",
"react-popper": "^2.3.0",
Expand Down
41 changes: 23 additions & 18 deletions packages/dashboard/src/components/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import '../../styles/variables.css';
import { queryClient } from '~/data/query-client';
import { PropertiesPanel } from '~/customization/propertiesSections';
import { useDashboardViewport } from '~/hooks/useDashboardViewport';
import { FpsView } from 'react-fps';

export type DashboardProperties = {
onSave: DashboardSave;
Expand All @@ -28,6 +29,7 @@ export type DashboardProperties = {
initialViewMode?: 'preview' | 'edit';
name?: string;
};
const showFPSMonitor = localStorage.getItem('DASHBOARD_SHOW_FPS');

const Dashboard: React.FC<DashboardProperties> = ({
onSave,
Expand All @@ -41,24 +43,27 @@ const Dashboard: React.FC<DashboardProperties> = ({

const readOnly = initialViewMode && initialViewMode === 'preview';
return (
<ClientContext.Provider value={getClients(clientConfiguration)}>
<QueryContext.Provider value={getQueries(clientConfiguration)}>
<QueryClientProvider client={queryClient}>
<Provider store={configureDashboardStore({ ...toDashboardState(dashboardConfiguration), readOnly })}>
<DndProvider
backend={TouchBackend}
options={{
enableMouseEvents: true,
enableKeyboardEvents: true,
}}
>
<InternalDashboard onSave={onSave} editable={true} name={name} propertiesPanel={<PropertiesPanel />} />
</DndProvider>
</Provider>
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
</QueryContext.Provider>
</ClientContext.Provider>
<>
{showFPSMonitor && <FpsView height={50} width={80} />}
<ClientContext.Provider value={getClients(clientConfiguration)}>
<QueryContext.Provider value={getQueries(clientConfiguration)}>
<QueryClientProvider client={queryClient}>
<Provider store={configureDashboardStore({ ...toDashboardState(dashboardConfiguration), readOnly })}>
<DndProvider
backend={TouchBackend}
options={{
enableMouseEvents: true,
enableKeyboardEvents: true,
}}
>
<InternalDashboard onSave={onSave} editable={true} name={name} propertiesPanel={<PropertiesPanel />} />
</DndProvider>
</Provider>
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
</QueryContext.Provider>
</ClientContext.Provider>
</>
);
};

Expand Down

0 comments on commit 48cd9ef

Please sign in to comment.