Files
xyflow/examples/nextjs/pages/_app.tsx
Moritz Klack 7a96817114 Refactor: Better routing for smoothstep and step edge (#2407)
* refactor(step/smoothstep-edge): better default routing
* chore(edges): pass options
* chore(exports): add BaseEdge
2022-09-07 17:40:18 +02:00

78 lines
1.8 KiB
TypeScript
Executable File

import React, { ChangeEventHandler } from 'react';
import { useRouter } from 'next/router';
import { AppProps } from 'next/app';
import '../styles/globals.css';
// Unfortunately this doesn't work because preconsruct clears the dist folder and there is
// no way to hook into the watch process to copy the files back to the dist folder
// import '@reactflow/core/dist/theme-default.css';
// this is a workaround for testing the theme. See explanation above.
import '../styles/rf-style.css';
const routes = [
'/',
'/Backgrounds',
'/ControlledUncontrolled',
'/CustomConnectionLine',
'/CustomNode',
'/DefaultNodes',
'/DragHandle',
'/DragNDrop',
'/EdgeRouting',
'/EdgeTypes',
'/Edges',
'/Empty',
'/FloatingEdges',
'/Hidden',
'/Interaction',
'/Layouting',
'/MultiFlows',
'/NestedNodes',
'/NodeTypeChange',
'/NodeTypesObjectChange',
'/Overview',
'/Provider',
'/SaveRestore',
'/Stress',
'/Subflow',
'/Switch',
'/TouchDevice',
'/Undirectional',
'/UpdatableEdge',
'/UpdateNode',
'/UseKeyPress',
'/UseReactFlow',
'/UseUpdateNodeInternals',
'/Validation',
];
function App({ Component, pageProps }: AppProps) {
const router = useRouter();
const onRouteChange: ChangeEventHandler<HTMLSelectElement> = (evt) => {
router.push(evt.target.value);
};
return (
<>
<header>
<a className="logo" href="https://github.com/wbkd/react-flow">
React Flow Dev
</a>
<select defaultValue={router.pathname} onChange={onRouteChange}>
{routes.map((route) => (
<option value={route} key={route}>
{route === '/' ? 'Basic' : route.substring(1, route.length)}
</option>
))}
</select>
</header>
<Component {...pageProps} />
</>
);
}
export default App;