feat(examples): add source link
This commit is contained in:
@@ -10,7 +10,7 @@ const onLoad = (graph) => {
|
|||||||
console.log('graph loaded:', graph);
|
console.log('graph loaded:', graph);
|
||||||
};
|
};
|
||||||
|
|
||||||
const initBgColor = '#8888e8';
|
const initBgColor = '#f0e742';
|
||||||
|
|
||||||
const CustomNodeGraph = () => {
|
const CustomNodeGraph = () => {
|
||||||
const [elements, setElements] = useState([]);
|
const [elements, setElements] = useState([]);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const EmptyGraph = () => {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={addRandomNode}
|
onClick={addRandomNode}
|
||||||
style={{ position: 'absolute', right: 10, top: 10, zIndex: 4 }}
|
style={{ position: 'absolute', left: 10, top: 10, zIndex: 4 }}
|
||||||
>
|
>
|
||||||
add node
|
add node
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const EmptyGraph = () => {
|
|||||||
<MiniMap />
|
<MiniMap />
|
||||||
<Controls />
|
<Controls />
|
||||||
<div
|
<div
|
||||||
style={{ position: 'absolute', right: 10, top: 10, zIndex: 4 }}
|
style={{ position: 'absolute', left: 10, top: 10, zIndex: 4 }}
|
||||||
>
|
>
|
||||||
<label>
|
<label>
|
||||||
interactive
|
interactive
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ const RichGraph = () => {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={addRandomNode}
|
onClick={addRandomNode}
|
||||||
style={{ position: 'absolute', right: 10, top: 10, zIndex: 4 }}
|
style={{ position: 'absolute', left: 15, top: 10, zIndex: 4 }}
|
||||||
>
|
>
|
||||||
add node
|
add node
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
+30
-1
@@ -25,6 +25,18 @@ header {
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
header a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
header a, header a:focus, header a:active, header a:visited {
|
||||||
|
color: #111;
|
||||||
|
}
|
||||||
|
|
||||||
|
header a:hover {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
header nav {
|
header nav {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
@@ -41,7 +53,7 @@ nav a {
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
nav a, nav a:focus, nav a:active {
|
nav a, nav a:focus, nav a:active, nav a:visited {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,3 +73,20 @@ nav a.active:before {
|
|||||||
top:50%;
|
top:50%;
|
||||||
transform: translateY(-50%);
|
transform: translateY(-50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sourcedisplay {
|
||||||
|
position: absolute;
|
||||||
|
top: 45px;
|
||||||
|
right: 15px;
|
||||||
|
z-index: 4;
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sourcedisplay, .sourcedisplay:focus, .sourcedisplay:active, .sourcedisplay:visited {
|
||||||
|
color: #777;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sourcedisplay:hover {
|
||||||
|
color: #111;
|
||||||
|
}
|
||||||
+15
-3
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { BrowserRouter as Router, Route, Switch, NavLink } from 'react-router-dom';
|
import { BrowserRouter as Router, Route, Switch, NavLink, withRouter } from 'react-router-dom';
|
||||||
|
|
||||||
import Rich from './Rich';
|
import Rich from './Rich';
|
||||||
import Basic from './Basic';
|
import Basic from './Basic';
|
||||||
@@ -26,7 +26,7 @@ const routes = [{
|
|||||||
}, {
|
}, {
|
||||||
path: '/stress',
|
path: '/stress',
|
||||||
component: Stress,
|
component: Stress,
|
||||||
label: 'StressTest'
|
label: 'Stress'
|
||||||
}, {
|
}, {
|
||||||
path: '/empty',
|
path: '/empty',
|
||||||
component: Empty
|
component: Empty
|
||||||
@@ -37,10 +37,21 @@ const routes = [{
|
|||||||
|
|
||||||
const navLinks = routes.filter(route => route.label);
|
const navLinks = routes.filter(route => route.label);
|
||||||
|
|
||||||
|
const SourceDisplay = withRouter(({ location }) => {
|
||||||
|
const route = routes.find(route => route.path === location.pathname);
|
||||||
|
const sourceLink = `https://github.com/wbkd/react-flow/tree/master/example/src/${route.label}/index.js`;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<a className="sourcedisplay" href={sourceLink}>
|
||||||
|
{'<Source />'}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
ReactDOM.render((
|
ReactDOM.render((
|
||||||
<Router forceRefresh={true}>
|
<Router forceRefresh={true}>
|
||||||
<header>
|
<header>
|
||||||
<div>React Flow Examples</div>
|
<a href="https://github.com/wbkd/react-flow">React Flow</a>
|
||||||
<nav>
|
<nav>
|
||||||
{navLinks.map(route => (
|
{navLinks.map(route => (
|
||||||
<NavLink to={route.path} key={route.label} exact>
|
<NavLink to={route.path} key={route.label} exact>
|
||||||
@@ -49,6 +60,7 @@ ReactDOM.render((
|
|||||||
))}
|
))}
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
<SourceDisplay />
|
||||||
<Switch>
|
<Switch>
|
||||||
{routes.map(route => (
|
{routes.map(route => (
|
||||||
<Route exact path={route.path} render={() => <route.component />} key={route.path} />
|
<Route exact path={route.path} render={() => <route.component />} key={route.path} />
|
||||||
|
|||||||
Reference in New Issue
Block a user