From 51e84f2b8c33ff9dcd3a16a8d8e72e9bd997063f Mon Sep 17 00:00:00 2001 From: Ben Larson <10101828+ben-larson@users.noreply.github.com> Date: Fri, 10 Apr 2020 14:02:32 -0500 Subject: [PATCH] Small updates (#6) --- src/Menu.jsx | 17 --------- src/{ => components}/Hero.jsx | 0 src/components/Menu.jsx | 34 +++++++++++++++++ src/components/hero.css | 45 ++++++++++++++++++++++ src/components/menu.css | 72 +++++++++++++++++++++++++++++++++++ src/index.jsx | 10 +++-- src/main.css | 65 +++++-------------------------- src/main.js | 26 ------------- 8 files changed, 168 insertions(+), 101 deletions(-) delete mode 100644 src/Menu.jsx rename src/{ => components}/Hero.jsx (100%) create mode 100644 src/components/Menu.jsx create mode 100644 src/components/hero.css create mode 100644 src/components/menu.css delete mode 100644 src/main.js diff --git a/src/Menu.jsx b/src/Menu.jsx deleted file mode 100644 index 35bf3a2..0000000 --- a/src/Menu.jsx +++ /dev/null @@ -1,17 +0,0 @@ -const React = require('react'); - -module.exports = ({ links }) => { - return ( - - ); -}; diff --git a/src/Hero.jsx b/src/components/Hero.jsx similarity index 100% rename from src/Hero.jsx rename to src/components/Hero.jsx diff --git a/src/components/Menu.jsx b/src/components/Menu.jsx new file mode 100644 index 0000000..e7a6d9b --- /dev/null +++ b/src/components/Menu.jsx @@ -0,0 +1,34 @@ +const React = require('react'); + +module.exports = ({ links }) => { + const navActions = { + open: () => document.body.classList.add('isNavOpen'), + close: () => document.body.classList.remove('isNavOpen'), + toggle: () => document.body.classList.toggle('isNavOpen'), + }; + + return ( + + ); +}; diff --git a/src/components/hero.css b/src/components/hero.css new file mode 100644 index 0000000..d8b3cd2 --- /dev/null +++ b/src/components/hero.css @@ -0,0 +1,45 @@ +:root { + --Hero-headerSize: 4em; +} + +header { + min-height: 100vh; + box-sizing: border-box; + background-attachment: fixed; + color: rgba(0, 0, 0, 0.6); + padding: var(--Hero-headerSize); +} + +header h1 { + font-size: var(--Hero-headerSize); + padding-bottom: 1em; +} + +header p { + line-height: 2em; +} + +@media (max-width: 55em) { + :root { + --Hero-headerSize: 3em; + } +} + +@media (max-width: 25em) { + header { + padding: 2em; + } + + h1 { + width: 0; + } +} + +@media (max-width: 20em) { + header p::first-letter { + margin-left: -1.3em; + text-align: right; + width: 0; + float: left; + } +} diff --git a/src/components/menu.css b/src/components/menu.css new file mode 100644 index 0000000..be1ec6a --- /dev/null +++ b/src/components/menu.css @@ -0,0 +1,72 @@ +.Menu { + width: 20em; + height: 100vh; + max-width: 100%; + right: -20em; + position: fixed; + transition: right 0.2s cubic-bezier(0.16, 0.7, 0.53, 1.18); +} + +.isNavOpen .Menu { + right: 0; +} + +.Menu-Closer { + z-index: 8; + position: fixed; + top: 0; + left: 0; + width: 0; + height: 100vh; +} + +.isNavOpen .Menu-Closer { + width: 100vw; +} + +.Menu-Button { + z-index: 10; + position: fixed; + top: 2em; + right: 2em; + padding: 0.75em; + box-shadow: 0 0 0 0.5em rgba(0, 0, 0, 0.5) inset; + border-radius: 100%; +} + +.Menu-Body { + z-index: 9; + position: fixed; + width: 100%; + height: 100%; + box-sizing: border-box; + border-radius: 1em 0 0 1em; + padding: 2em; + background-color: #fff; +} + +.Menu h3 { + font-size: 1.5em; + margin: 0; + padding-bottom: 1em; + line-height: 2.25rem; +} + +.Menu ul { + list-style-type: none; +} + +.Menu ul li { + margin: 1em 0; +} + +@media (max-width: 25em) { + .Menu { + width: 100%; + right: -100%; + transition: right 0.2s; + } + .Menu-Body { + border-radius: 0; + } +} diff --git a/src/index.jsx b/src/index.jsx index bd392e1..6bd5230 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -1,17 +1,21 @@ const React = require('react'); const ReactDom = require('react-dom'); -const Hero = require('./Hero'); -const Menu = require('./Menu'); +const Hero = require('./components/Hero'); +const Menu = require('./components/Menu'); ReactDom.render( <> { - const result = document.createElement(tagName); - Object.keys(attrs).forEach(key => result.setAttribute(key, attrs[key])); - children.forEach(child => { - if (typeof child === 'object') result.appendChild(child); - else result.innerHTML += child; - }); - return result; -}; - -repos.forEach(title => { - const name = title.toLowerCase().replace(' ', '-'); - const url = `https://benlarson.xyz/${name}/`; - - const iframe = element('iframe', { src: url }); - const githubLink = element( - 'a', - { href: `https://github.com/ben-larson/${name}/`, class: 'github' }, - 'View on GitHub ↗' - ); - const content = element('div', { class: 'sizer' }, githubLink, iframe); - const section = element('section', {}, content); - document.body.appendChild(section); -}); -- 2.45.2