Book Image

Isomorphic JavaScript Web Development

By : Tomas Alabes, Konstantin Tarkus
Book Image

Isomorphic JavaScript Web Development

By: Tomas Alabes, Konstantin Tarkus

Overview of this book

<p>The latest trend in web development, Isomorphic JavaScript, allows developers to overcome some of the shortcomings of single-page applications by running the same code on the server as well as on the client. Leading this trend is React, which, when coupled with Node, allows developers to build JavaScript apps that are much faster and more SEO-friendly than single-page applications.</p> <p>This book begins by showing you how to develop frontend components in React. It will then show you how to bind these components to back-end web services that leverage the power of Node. You'll see how web services can be used with React code to offload and maintain the application logic. By the end of this book, you will be able to save a significant amount of development time by learning to combine React and Node to code fast, scalable apps in pure JavaScript.</p>
Table of Contents (16 chapters)
Title Page
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Sharing common settings across multiple CSS files


The precss plugin mentioned previously allows you to use Sass variables and mixins in your CSS code. While this may sound like a great feature, in practice, you may want to keep the usage of variables and (especially) mixins to the very minimum, in favor of a better composition of React components. This will keep your code more maintainable. There are some legit cases though where you need to have shared variables. For example, you may want to have the $primary-color variable containing the primary base color used by many UI elements in your app.

Let's create the components/variables.scss file for such variables. It may look similar to this:

/* Colors */ 
$color-primary: #0275d8; 
$color-success: #5cb85c; 
$color-info:    #5bc0de; 
$color-warning: #f0ad4e; 
$color-danger:  #d9534f; 
 
/* Shadows */ 
$shadow-2dp: 0 2px 2px 0 rgba(0, 0, 0, .14), 
             0 3px 1px -2px rgba(0, 0, 0, .2), 
             0 1px 5px 0 rgba(0, 0, 0, .12); 
 
...