diff options
author | Jefferson Julio <[email protected]> | 2021-05-30 20:06:28 -0300 |
---|---|---|
committer | Jefferson Julio <[email protected]> | 2021-05-30 20:06:28 -0300 |
commit | e9c35a9eff9e0881df7d6a6e8d17b70ac37ad0fe (patch) | |
tree | 2a6a9d105b68daea1094e5a2faaca0fb9b138ab3 /static | |
parent | 1d628ce8cee397ca9c2a8a27d5820c91812a27ca (diff) | |
download | blog.sh-e9c35a9eff9e0881df7d6a6e8d17b70ac37ad0fe.tar.bz2 blog.sh-e9c35a9eff9e0881df7d6a6e8d17b70ac37ad0fe.zip |
Better modularization
Diffstat (limited to 'static')
-rw-r--r-- | static/header.js | 137 | ||||
-rw-r--r-- | static/styles.css | 359 |
2 files changed, 496 insertions, 0 deletions
diff --git a/static/header.js b/static/header.js new file mode 100644 index 0000000..06d868a --- /dev/null +++ b/static/header.js @@ -0,0 +1,137 @@ +let isMobile = window.innerWidth < 769; +let keyPressAudio = new Audio('/static/key-press.mp3'); +let headerAnimationTerminated = false; +let cursorHTML = '<span class="cursor"> </span>'; + +window.addEventListener('resize', () => { + isMobile = window.innerWidth < 769; +}); + +function hideTopNav() { + let topNav = document.querySelector('.top-nav'); + topNav.style.opacity = '0'; + topNav.style.display = 'none'; +} + +function hideContent() { + hideTopNav(); + let mainContainer = document.querySelector('main'); + let footer = document.querySelector('footer'); + mainContainer.style.opacity = '0'; + mainContainer.style.display = 'none'; + footer.style.opacity = '0'; + footer.style.display = 'none'; +} + +function showContent(cb) { + let mainContainer = document.querySelector('main'); + let footer = document.querySelector('footer'); + let topNav = document.querySelector('.top-nav'); + + topNav.style.transition = '100ms'; + topNav.style.opacity = '1'; + topNav.style.display = 'block'; + + setTimeout(() => { + mainContainer.style.transition = '500ms'; + mainContainer.style.opacity = '1'; + mainContainer.style.display = 'block'; + setTimeout(() => { + footer.style.transition = '500ms'; + footer.style.opacity = '1'; + footer.style.display = 'block'; + if (cb) cb(); + }, 500); + }, 100); +} + +function clearHideContentTransition() { + let mainContainer = document.querySelector('main'); + let footer = document.querySelector('footer'); + let topNav = document.querySelector('.top-nav'); + topNav.style.transition = '0s'; + mainContainer.style.transition = '0s'; + footer.style.transition = '0s'; +} + +function typingAnimation(el, text, index, cb) { + let delay = 30; + + let char = text[index]; + if (char == ';') { + el.innerHTML += '<br />$ '; + !isMobile && keyPressAudio.play(); + delay += 400; + } else if (char == ' ') { + el.innerHTML += ' '; + } else { + el.innerText += char; + } + + if (index < text.length - 1) { + setTimeout(() => typingAnimation(el, text, index + 1, cb), delay); + } else { + !isMobile && keyPressAudio.play(); + el.innerHTML += '<br />'; + setTimeout(() => { + if (cb) cb(); + setTimeout(clearHideContentTransition, 1000); + }, 600); + } +} + +function clearHeaderTerminal(cb) { + let titleMobile = document.querySelector("#header-title-mobile > .text"); + let titleDesktop = document.querySelector('#header-title > .text'); + let footerCommandPrompt = document.querySelector('#footer-command-prompt'); + + if (isMobile) { + titleMobile.innerHTML = ''; + } else { + titleDesktop.innerHTML = ''; + } + + footerCommandPrompt.style.height = 'calc(100vh)'; + hideTopNav(); + footerCommandPrompt.querySelector('.after-prompt').scrollIntoView({ + behavior: 'smooth', + }); + + setTimeout(() => { + if (cb) cb(); + footerCommandPrompt.style.height = 'auto'; + }, 1000); +} + +function headerTerminalExecute(desktopText, mobileText, cb) { + window.scrollTo(0, 0); + headerAnimationTerminated = false; + let titleMobile = document.querySelector("#header-title-mobile > .text"); + let titleDesktop = document.querySelector('#header-title > .text'); + + if (!mobileText) mobileText = desktopText; + + setTimeout(() => { + if (isMobile) { + titleMobile.insertAdjacentHTML('afterend', cursorHTML); + typingAnimation(titleMobile, mobileText, 0, () => { + if (cb) cb(); + headerAnimationTerminated = true; + document.querySelector('#header-title-mobile .cursor').remove(); + }); + } else { + titleDesktop.insertAdjacentHTML('afterend', cursorHTML); + typingAnimation(titleDesktop, desktopText, 0, () => { + if (cb) cb(); + headerAnimationTerminated = true; + document.querySelector('#header-title .cursor').remove(); + }); + } + }, 200); +} + +document.addEventListener('DOMContentLoaded', function() { + clearHeaderTerminal(); + hideContent(); + headerTerminalExecute(desktopText, mobileText, () => showContent(bindAllRelativeAnchors)); +}); diff --git a/static/styles.css b/static/styles.css new file mode 100644 index 0000000..e84dc56 --- /dev/null +++ b/static/styles.css @@ -0,0 +1,359 @@ +/* normalize.css */ +html { + line-height: 1.15; /* 1 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} +body { + margin: 0; +} +main { + display: block; + margin-top: 25px; +} +h1 { + font-size: 2em; + margin: 0.67em 0; +} +hr { + box-sizing: content-box; /* 1 */ + height: 0; /* 1 */ + overflow: visible; /* 2 */ +} +pre { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} +a { + background-color: transparent; +} +abbr[title] { + border-bottom: none; /* 1 */ + text-decoration: underline; /* 2 */ + text-decoration: underline dotted; /* 2 */ +} +b, +strong { + font-weight: bolder; +} +code, +kbd, +samp { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} +small { + font-size: 80%; +} +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} +sub { + bottom: -0.25em; +} +sup { + top: -0.5em; +} +img { + border-style: none; +} +button, +input, +optgroup, +select, +textarea { + font-family: inherit; /* 1 */ + font-size: 100%; /* 1 */ + line-height: 1.15; /* 1 */ + margin: 0; /* 2 */ +} +button, +input { /* 1 */ + overflow: visible; +} +button, +select { /* 1 */ + text-transform: none; +} +button, +[type="button"], +[type="reset"], +[type="submit"] { + -webkit-appearance: button; +} +button::-moz-focus-inner, +[type="button"]::-moz-focus-inner, +[type="reset"]::-moz-focus-inner, +[type="submit"]::-moz-focus-inner { + border-style: none; + padding: 0; +} +button:-moz-focusring, +[type="button"]:-moz-focusring, +[type="reset"]:-moz-focusring, +[type="submit"]:-moz-focusring { + outline: 1px dotted ButtonText; +} +fieldset { + padding: 0.35em 0.75em 0.625em; +} +legend { + box-sizing: border-box; /* 1 */ + color: inherit; /* 2 */ + display: table; /* 1 */ + max-width: 100%; /* 1 */ + padding: 0; /* 3 */ + white-space: normal; /* 1 */ +} +progress { + vertical-align: baseline; +} +textarea { + overflow: auto; +} +[type="checkbox"], +[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} +[type="number"]::-webkit-inner-spin-button, +[type="number"]::-webkit-outer-spin-button { + height: auto; +} +[type="search"] { + -webkit-appearance: textfield; /* 1 */ + outline-offset: -2px; /* 2 */ +} +[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} +::-webkit-file-upload-button { + -webkit-appearance: button; /* 1 */ + font: inherit; /* 2 */ +} +details { + display: block; +} +summary { + display: list-item; +} +template { + display: none; +} +[hidden] { + display: none; +} + +/* jefferson.sh */ + +@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap'); + +html { + --primary-bg: #2b2b2b; + /* --primary-fg: #65d84a; */ + --primary-fg: #0eff5d; + background-color: var(--primary-bg); + color: var(--primary-fg); + font-family: 'VT323', monospace; + font-size: 16px; + position: relative; + overflow: auto; + /* scroll-behavior: smooth; */ + min-height: 100vh; +} + +@media screen and (max-width: 600px) { + html { + font-size: 14px; + } +} + +html:before { + content: ' '; + display: block; + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + background: linear-gradient( + to bottom, + rgba(18, 16, 16, 0) 50%, + rgba(0, 0, 0, 0.25) 50% + ); + background-size: 100% 3px; + z-index: 99; + pointer-events: none; +} + +.separator-wrap { + width: 100%; + display: flex; + justify-content: center; +} + +.separator-wrap.left { + justify-content: flex-start; +} + +.separator { + border-top: 1px solid var(--primary-fg); + width: 25px; + margin-left: 25px; + margin-right: 25px; +} + +a { + color: var(--primary-fg); +} + +ul { + padding: 0; + margin: 0; + list-style: none; +} + +nav > * { + display: inline-block; +} + +ul > li { + display: inline-block; +} + +header, footer { + margin: 25px; +} + +header > h1, +header > h2 { + margin: 0; +} + +@media screen and (max-width: 600px) { + h1 { + font-size: 1.4rem; + } +} + +[class^=err-] { + text-align: left; + font-size: 2rem; + margin: 40px; +} + +.container { + padding-left: 25px; + padding-right: 25px; +} + +.hidden { + display: none !important; +} + +@keyframes blink-animation { + to { + opacity: 0; + } +} + +.cursor { + background-color: var(--primary-fg); + animation-name: blink-animation; + animation-duration: 500ms; + animation-iteration-count: infinite; + animation-timing-function: cubic-bezier(0.83,-0.22, 0.54, 0.55); +} + +@media screen and (min-width: 1000px) { + .container, [class^=err-] { + padding-left: 215px; + padding-right: 215px; + } + + .pad-left, .pad-right { + width: 215px; + } +} + +.post-header { + border-left: 1px solid; + padding-left: 15px; +} + +.post-title { + font-size: 1.4rem; + margin: 0; + margin-bottom: 10px; + line-break: anywhere; +} + +.post-preview { + border-left: 1px solid; + padding-left: 10px; + margin: 25px 0px; +} + +.post-header time, +.post-header small { + font-size: 0.9rem; +} + +.post-header-preview time, +.post-header-preview small { + font-size: 0.9rem; +} + +.post-header-preview .post-title { + margin: 0; + font-size: 1.1rem; +} +.post-header-preview time { + font-size: 0.8rem; +} + +.tags { + margin-top: 15px; + margin-bottom: 15px; +} + +.post-header-preview .tags { + margin-top: 5px; + margin-bottom: 5px; +} + +.tag { + background-color: var(--primary-fg); + color: var(--primary-bg); + padding-left: 4px; + padding-right: 4px; + padding-top: 1.5px; + padding-bottom: 1.5px; +} + +.post-header-preview .tag { + font-size: 0.75rem; +} + +::-webkit-scrollbar { + width: 10px; + height: 10px; +} +::-webkit-scrollbar-thumb { + background: var(--primary-fg); + border-radius: 8px; +} +::-webkit-scrollbar-thumb:hover{ + background: var(--primary-bg); +} +::-webkit-scrollbar-track{ + background: var(--primary-bg); + border-radius: 7px; +} + +::-webkit-scrollbar-track:hover { + background: var(--primary-fg); +} |