Merge pull request #216 from wbkd/develop
refactor(examples): mobile friendly
This commit is contained in:
@@ -70,6 +70,7 @@ const RichGraph = () => {
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={addRandomNode}
|
onClick={addRandomNode}
|
||||||
style={{ position: 'absolute', right: 10, top: 30, zIndex: 4 }}
|
style={{ position: 'absolute', right: 10, top: 30, zIndex: 4 }}
|
||||||
|
className="richexample__add"
|
||||||
>
|
>
|
||||||
add node
|
add node
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
+61
-6
@@ -23,10 +23,13 @@ header {
|
|||||||
border-bottom: 1px solid #eee;
|
border-bottom: 1px solid #eee;
|
||||||
display: flex;
|
display: flex;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
header a {
|
.logo {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
display: block;
|
||||||
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
header a, header a:focus, header a:active, header a:visited {
|
header a, header a:focus, header a:active, header a:visited {
|
||||||
@@ -37,20 +40,41 @@ header a:hover {
|
|||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
header nav {
|
.menu {
|
||||||
font-weight: 400;
|
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
|
background: rgb(255, 96, 96);
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
padding: 5px 12px;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav {
|
||||||
|
font-weight: 400;
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
width: 94%;
|
||||||
|
top: 46px;
|
||||||
|
z-index: 10;
|
||||||
|
left: 0;
|
||||||
|
padding: 3%;
|
||||||
|
background: rgba(255,255,255,0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
nav.is-open {
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
nav a {
|
nav a {
|
||||||
margin-left: 10px;
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-size: 12px;
|
font-size: 14px;
|
||||||
background: rgb(255, 96, 96);
|
background: rgb(255, 96, 96);
|
||||||
color: white;
|
color: white;
|
||||||
padding: 5px 12px;
|
padding: 5px 12px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nav a, nav a:focus, nav a:active, nav a:visited {
|
nav a, nav a:focus, nav a:active, nav a:visited {
|
||||||
@@ -76,7 +100,7 @@ nav a.active:before {
|
|||||||
|
|
||||||
.sourcedisplay {
|
.sourcedisplay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 45px;
|
top: 50px;
|
||||||
right: 15px;
|
right: 15px;
|
||||||
z-index: 4;
|
z-index: 4;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
@@ -90,3 +114,34 @@ nav a.active:before {
|
|||||||
.sourcedisplay:hover {
|
.sourcedisplay:hover {
|
||||||
color: #111;
|
color: #111;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.richexample__add {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 768px) {
|
||||||
|
nav {
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
margin-left: auto;
|
||||||
|
width: auto;
|
||||||
|
padding: 0;
|
||||||
|
top: auto;
|
||||||
|
left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav a {
|
||||||
|
margin-left: 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
display: inline-block;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.richexample__add {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+14
-5
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { BrowserRouter as Router, Route, Switch, NavLink, withRouter } from 'react-router-dom';
|
import { BrowserRouter as Router, Route, Switch, NavLink, withRouter } from 'react-router-dom';
|
||||||
|
|
||||||
@@ -58,18 +58,27 @@ const SourceDisplay = withRouter(({ location }) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
ReactDOM.render((
|
const Header = () => {
|
||||||
<Router forceRefresh={true}>
|
const [menuOpen, setMenuOpen] = useState();
|
||||||
|
|
||||||
|
return (
|
||||||
<header>
|
<header>
|
||||||
<a href="https://github.com/wbkd/react-flow">React Flow</a>
|
<a className="logo" href="https://github.com/wbkd/react-flow">React Flow</a>
|
||||||
<nav>
|
<nav className={menuOpen ? 'is-open' : ''}>
|
||||||
{navLinks.map(route => (
|
{navLinks.map(route => (
|
||||||
<NavLink to={route.path} key={route.label} exact>
|
<NavLink to={route.path} key={route.label} exact>
|
||||||
{route.label}
|
{route.label}
|
||||||
</NavLink>
|
</NavLink>
|
||||||
))}
|
))}
|
||||||
</nav>
|
</nav>
|
||||||
|
<button className="menu" onClick={() => setMenuOpen(!menuOpen)}>Menu</button>
|
||||||
</header>
|
</header>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReactDOM.render((
|
||||||
|
<Router forceRefresh={true}>
|
||||||
|
<Header />
|
||||||
<SourceDisplay />
|
<SourceDisplay />
|
||||||
<Switch>
|
<Switch>
|
||||||
{routes.map(route => (
|
{routes.map(route => (
|
||||||
|
|||||||
Reference in New Issue
Block a user