Skip to content

Commit

Permalink
feat: make mobile look decent
Browse files Browse the repository at this point in the history
  • Loading branch information
lmammino committed Jan 5, 2024
1 parent 8137e57 commit 4fdc07e
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 100 deletions.
Binary file modified src/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion src/_includes/layout.njk
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ eleventyComputed:
{% endif %}
</head>
<body>
<nav class="navbar is-fixed-top has-shadow" role="navigation" aria-label="main navigation">
<nav id="navbar" class="navbar is-fixed-top has-shadow" role="navigation" aria-label="main navigation">
<div class="container">
<div class="navbar-brand">
<div class="navbar-item">
Expand Down
158 changes: 80 additions & 78 deletions src/index.html.njk
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ og_type:
<div class="columns is-vcentered is-gapless">
<div class="column pr-4">
<h1 class="title is-1">
<em>Node.js Design Patterns</em>: the ultimate guide to becoming a Node.js expert</h1>
Node.js Design Patterns: the ultimate guide to becoming a Node.js expert</h1>
<h2 class="subtitle is-4 mt-1">The <strong>top-tier book</strong> for Node.js that will guide you from A to Z through the design and implementation of production-grade <strong>Node.js applications</strong> with <strong>tested patterns</strong> and <strong>techniques</strong>.</h2>
<div class="buttons">
<a class="button is-primary" href="https://nodejsdp.link/buy" {{ track("click_buy_print") }}>Buy Print edition</a>
Expand Down Expand Up @@ -135,7 +135,7 @@ og_type:
<div class="bg-green">
<section id="complete-description" class="section bg-white is-medium">
<div class="container is-max-desktop">
<div class="container bg-green px-6 py-6 bd-all-small" style="max-width: 800px;">
<div id="complete-description-features" class="container bg-green bd-all-small" style="max-width: 800px;">
<h2 class="title underline-bright is-2 has-text-centered mb-6">
<span>More than just Design Patterns: a book with Everything you need to know about Node.js</span>
</h2>
Expand All @@ -153,83 +153,85 @@ og_type:
</div>
</div>

<h2 class="title is-2 underline has-text-centered mt-6">
<span>What you will find in the book:</span>
</h2>
<div id="chapters-container">
<h2 class="title is-2 underline has-text-centered mt-6">
<span>What you will find in the book:</span>
</h2>

<div id="chapters" class="columns is-centered">
<div class="column is-6">

<ol>
<li>
<h3 class="title is-4">The Node.js Platform</h3>
<p>Learn about the Node.js philosophy, the reactor patterns and the differences between JavaScript on the browser and Node.js on the server.</p>
</li>

<li>
<h3 class="title is-4">The Module System</h3>
<p>Learn how to leverage the powerful Node.js module system and discover the main differences between CommonJS and ESM.</p>
</li>

<li>
<h3 class="title is-4">Callbacks and Events</h3>
<p>Discover the callback pattern, how it works and the conventions used in Node.js. Learn how to avoid pitfalls and when to take advantage of the observer pattern using Node.js built-in event emitter.</p>
</li>

<li>
<h3 class="title is-4">Asynchronous Control Flow Patterns with Callbacks</h3>
<p>Lean how to avoid callback hell and explore common asynchronous patterns such as sequential execution, sequential iteration, parallel execution and limited parallel execution.</p>
</li>

<li>
<h3 class="title is-4">Asynchronous Control Flow Patterns with Promises and Async/Await</h3>
<p>Find out how promises work and how to use them effectively to implement various asynchronous control flow patterns. Explore the modern async/await syntax, the main tool today for dealing with asynchronous code in Node.js</p>
</li>

<li>
<h3 class="title is-4">Coding with Streams</h3>
<p>Understand why streams are so important in Node.js. Learn how to use standard streams and how to create custom ones. Explore various streaming patterns and learn how to build powerful streaming pipelines.</p>
</li>

<li>
<h3 class="title is-4">Creational Design Patterns</h3>
<p>Learn about the most famous creational design patterns in Node.js: the Factory pattern, the Revealing Constructor pattern, the Builder pattern. Finally, explore the Singleton pattern and the Dependency Injection pattern.</p>
</li>

<li>
<h3 class="title is-4">Structural Design Patterns</h3>
<p>Discover how to implement and use the Proxy, the Decorator and the Adapter pattern in Node.js.</p>
</li>

<li>
<h3 class="title is-4">Behavioural Design Patterns</h3>
<p>Learn how to implement and leverage some of the most well known behavioural design patterns in the context of Node.js: the Strategy pattern, the State pattern, the Template pattern, the Iterator pattern, the Middleware pattern, and the Command pattern.</p>
<p>
<a href="#sample-chapter">
<span class="tag is-primary">Free Chapter!</span></a>
</p>
</li>

<li>
<h3 class="title is-4">Universal JavaScript</h3>
<p>Explore the fundamentals of JavaScript cross-platform development and learn how to share code between the browser and Node.js. Learn how to leverage React.js to build a complete universal JavaScript application.</p>
</li>

<li>
<h3 class="title is-4">Advanced Recipes</h3>
<p>Discover well-known recipes to deal with some more advanced Node.js intricacies such as dealing with asynchronously initialized components, performing asynchronous request batching and caching, canceling asynchronous operations and running CPU-bound tasks.</p>
</li>

<li>
<h3 class="title is-4">Scalability and Architectural Patterns</h3>
<p>Master the art of Node.js scalability by learning about the "Scale Cube", discover how to run multiple instances of the same application and how to use load balancers and service registers. Learn how to use containers and containers orchestration platforms such as Kubernetes. Finally, find out how to design and build microservices architectures.</p>
</li>

<li>
<h3 class="title is-4">Messaging and Integration Patterns</h3>
<p>Learn how to integrate complex distributed Node.js applications using the most popular messaging systems. Learn how to implement the most common messaging patterns on top of ZeroMQ, RabbitMQ and Redis Streams.</p>
</li>
</ol>
<div id="chapters" class="columns is-centered">
<div class="column is-6">

<ol>
<li>
<h3 class="title is-4">The Node.js Platform</h3>
<p>Learn about the Node.js philosophy, the reactor patterns and the differences between JavaScript on the browser and Node.js on the server.</p>
</li>

<li>
<h3 class="title is-4">The Module System</h3>
<p>Learn how to leverage the powerful Node.js module system and discover the main differences between CommonJS and ESM.</p>
</li>

<li>
<h3 class="title is-4">Callbacks and Events</h3>
<p>Discover the callback pattern, how it works and the conventions used in Node.js. Learn how to avoid pitfalls and when to take advantage of the observer pattern using Node.js built-in event emitter.</p>
</li>

<li>
<h3 class="title is-4">Asynchronous Control Flow Patterns with Callbacks</h3>
<p>Lean how to avoid callback hell and explore common asynchronous patterns such as sequential execution, sequential iteration, parallel execution and limited parallel execution.</p>
</li>

<li>
<h3 class="title is-4">Asynchronous Control Flow Patterns with Promises and Async/Await</h3>
<p>Find out how promises work and how to use them effectively to implement various asynchronous control flow patterns. Explore the modern async/await syntax, the main tool today for dealing with asynchronous code in Node.js</p>
</li>

<li>
<h3 class="title is-4">Coding with Streams</h3>
<p>Understand why streams are so important in Node.js. Learn how to use standard streams and how to create custom ones. Explore various streaming patterns and learn how to build powerful streaming pipelines.</p>
</li>

<li>
<h3 class="title is-4">Creational Design Patterns</h3>
<p>Learn about the most famous creational design patterns in Node.js: the Factory pattern, the Revealing Constructor pattern, the Builder pattern. Finally, explore the Singleton pattern and the Dependency Injection pattern.</p>
</li>

<li>
<h3 class="title is-4">Structural Design Patterns</h3>
<p>Discover how to implement and use the Proxy, the Decorator and the Adapter pattern in Node.js.</p>
</li>

<li>
<h3 class="title is-4">Behavioural Design Patterns</h3>
<p>Learn how to implement and leverage some of the most well known behavioural design patterns in the context of Node.js: the Strategy pattern, the State pattern, the Template pattern, the Iterator pattern, the Middleware pattern, and the Command pattern.</p>
<p>
<a href="#sample-chapter">
<span class="tag is-primary">Free Chapter!</span></a>
</p>
</li>

<li>
<h3 class="title is-4">Universal JavaScript</h3>
<p>Explore the fundamentals of JavaScript cross-platform development and learn how to share code between the browser and Node.js. Learn how to leverage React.js to build a complete universal JavaScript application.</p>
</li>

<li>
<h3 class="title is-4">Advanced Recipes</h3>
<p>Discover well-known recipes to deal with some more advanced Node.js intricacies such as dealing with asynchronously initialized components, performing asynchronous request batching and caching, canceling asynchronous operations and running CPU-bound tasks.</p>
</li>

<li>
<h3 class="title is-4">Scalability and Architectural Patterns</h3>
<p>Master the art of Node.js scalability by learning about the "Scale Cube", discover how to run multiple instances of the same application and how to use load balancers and service registers. Learn how to use containers and containers orchestration platforms such as Kubernetes. Finally, find out how to design and build microservices architectures.</p>
</li>

<li>
<h3 class="title is-4">Messaging and Integration Patterns</h3>
<p>Learn how to integrate complex distributed Node.js applications using the most popular messaging systems. Learn how to implement the most common messaging patterns on top of ZeroMQ, RabbitMQ and Redis Streams.</p>
</li>
</ol>
</div>
</div>
</div>

Expand Down
59 changes: 44 additions & 15 deletions src/js/navbar.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,49 @@
export default function navbar () {
// Get all "navbar-burger" elements
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0)
const html = document.getElementsByTagName('html')[0]
const navbar = document.getElementById('navbar')
const htmlStickyClasses = ['has-navbar-fixed-top']
const navbarStickyClasses = ['is-fixed-top', 'has-shadow']

// Check if there are any navbar burgers
if ($navbarBurgers.length > 0) {
// Add a click event on each of them
$navbarBurgers.forEach(el => {
el.addEventListener('click', () => {
// Get the target from the "data-target" attribute
const target = el.dataset.target
const $target = document.getElementById(target)
let lastScrollY = 0
let state = {
stickyBarEnabled: true,
stickyBarVisible: true
}

function updateState (stateChanges) {
const newState = { ...state, ...stateChanges }
if (JSON.stringify(newState) !== JSON.stringify(state)) {
state = newState
update()
}
}

// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
el.classList.toggle('is-active')
$target.classList.toggle('is-active')
})
})
function update () {
if (state.stickyBarEnabled && state.stickyBarVisible) {
for (const className of htmlStickyClasses) {
html.classList.add(className)
}
for (const className of navbarStickyClasses) {
navbar.classList.add(className)
}
} else {
for (const className of htmlStickyClasses) {
html.classList.remove(className)
}
for (const className of navbarStickyClasses) {
navbar.classList.remove(className)
}
}
}

const mobileMq = window.matchMedia('screen and (max-width: 768px)')
mobileMq.addEventListener('change', (e) => {
updateState({ stickyBarEnabled: e.matches })
})

window.addEventListener('scroll', (e) => {
const isScrollingUp = window.scrollY < lastScrollY
updateState({ stickyBarVisible: isScrollingUp })
lastScrollY = window.scrollY
})
}
97 changes: 91 additions & 6 deletions src/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,53 @@ nav.navbar {
}

#key-characteristics {
padding: 4.5rem;
padding: 4.5rem 1rem;

h2 {
font-size: 2rem;
}

h4 {
margin-bottom: 0.5rem;
}

p {
margin: 0 0 1.5rem 0;
}

@media screen and (min-width: 769px) {
padding: 4.5rem;

h2 {
font-size: 2.5rem;
}

h4 {
margin-bottom: 1.25rem;
}

p {
margin: 0;
}
}
}

#the-problem {
padding: 4.5rem;
padding: 4.5rem 1rem;

h2 {
font-size: 2rem;
text-align: center;
}

@media screen and (min-width: 769px) {
padding: 4.5rem;

h2 {
font-size: 2.5rem;
text-align: left;
}
}

p {
margin: 1.5rem 0 0 0;
Expand All @@ -198,13 +240,26 @@ nav.navbar {

#alternative-solution {
section {
padding: 4.5rem;
padding: 4.5rem 1rem;
}

h2 {
font-size: 2rem;
text-align: center;
margin: 0 0 2rem 0;
}

@media screen and (min-width: 769px) {
section {
padding: 4.5rem;
}

h2 {
font-size: 2.5rem;
text-align: left;
}
}

picture {
display: block;
margin: 1.5rem 0 0 0;
Expand All @@ -228,13 +283,43 @@ nav.navbar {
}

#complete-description {
padding: 0 4.5rem 4.5rem 4.5rem;
padding: 0;

h2 {
font-size: 2rem;
margin: 0 0 3rem 0;
font-size: 1.5rem;
}

#complete-description-features {
padding: 2rem 1rem;
}

#chapters-container {
margin: 0 1rem;

ol {
padding-left: 2rem;
}

li p {
max-width: 600px;
}
}

@media screen and (min-width: 769px) {
padding: 0 4.5rem 4.5rem 4.5rem;

#complete-description-features {
padding: 3rem;
}

h2 {
font-size: 2rem;
margin: 0 0 3rem 0;
}
}



h3 {
font-size: 1.5rem;
margin: 0 0 3rem 0;
Expand Down

0 comments on commit 4fdc07e

Please sign in to comment.