From 5f2e67ad4467a8652755a685257e162cbc811c78 Mon Sep 17 00:00:00 2001 From: moklick Date: Tue, 12 May 2020 11:14:00 +0200 Subject: [PATCH] refactor(examples): mobile friendly --- example/src/Rich/index.js | 1 + example/src/index.css | 69 +++++++++++++++++++++++++++++++++++---- example/src/index.js | 19 ++++++++--- 3 files changed, 77 insertions(+), 12 deletions(-) diff --git a/example/src/Rich/index.js b/example/src/Rich/index.js index 0cd4cc89..37b69e6e 100644 --- a/example/src/Rich/index.js +++ b/example/src/Rich/index.js @@ -70,6 +70,7 @@ const RichGraph = () => { type="button" onClick={addRandomNode} style={{ position: 'absolute', right: 10, top: 30, zIndex: 4 }} + className="richexample__add" > add node diff --git a/example/src/index.css b/example/src/index.css index 3db13f73..530e0418 100644 --- a/example/src/index.css +++ b/example/src/index.css @@ -23,10 +23,13 @@ header { border-bottom: 1px solid #eee; display: flex; font-weight: 700; + align-items: center; } -header a { +.logo { text-decoration: none; + display: block; + line-height: 1; } header a, header a:focus, header a:active, header a:visited { @@ -37,20 +40,41 @@ header a:hover { color: #333; } -header nav { - font-weight: 400; +.menu { 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 { - margin-left: 10px; text-decoration: none; - font-size: 12px; + font-size: 14px; background: rgb(255, 96, 96); color: white; padding: 5px 12px; border-radius: 5px; position: relative; + display: block; + margin-bottom: 5px; } nav a, nav a:focus, nav a:active, nav a:visited { @@ -76,7 +100,7 @@ nav a.active:before { .sourcedisplay { position: absolute; - top: 45px; + top: 50px; right: 15px; z-index: 4; text-decoration: none; @@ -89,4 +113,35 @@ nav a.active:before { .sourcedisplay:hover { color: #111; -} \ No newline at end of file +} + +.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; + } +} diff --git a/example/src/index.js b/example/src/index.js index 0ca8f17a..63268472 100644 --- a/example/src/index.js +++ b/example/src/index.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import ReactDOM from 'react-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 = () => { + const [menuOpen, setMenuOpen] = useState(); + + return (
- React Flow -
+ ); +} + +ReactDOM.render(( + +
{routes.map(route => (