Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"presets": ["react", "es2015", "stage-0"]
"presets": [
"react",
"es2015",
"stage-0"
]
}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ Atomic React enables rapid development of web applications by using readily avai
## Reference Guides.
The components being built follow the [Component Design Guidelines](https://github.com/areai51/react-component-design)

## Setup
## Molecules
Building Blocks of the repo built on the guide above.

## Setup the example
Clone the Repo

`$npm i`
Expand Down
10 changes: 5 additions & 5 deletions config/env.js → example/config/env.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
// injected into the application via DefinePlugin in Webpack configuration.

var REACT_APP = /^REACT_APP_/i;
const REACT_APP = /^REACT_APP_/i;

function getClientEnvironment(publicUrl) {
var raw = Object
const raw = Object
.keys(process.env)
.filter(key => REACT_APP.test(key))
.reduce((env, key) => {
Expand All @@ -13,15 +13,15 @@ function getClientEnvironment(publicUrl) {
}, {
// Useful for determining whether we’re running in production mode.
// Most importantly, it switches React into the correct mode.
'NODE_ENV': process.env.NODE_ENV || 'development',
NODE_ENV: process.env.NODE_ENV || 'development',
// Useful for resolving the correct path to static assets in `public`.
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
// This should only be used as an escape hatch. Normally you would put
// images into the `src` and `import` them in code to get their paths.
'PUBLIC_URL': publicUrl
PUBLIC_URL: publicUrl
});
// Stringify all values so we can feed into Webpack DefinePlugin
var stringified = {
const stringified = {
'process.env': Object
.keys(raw)
.reduce((env, key) => {
Expand Down
File renamed without changes.
File renamed without changes.
50 changes: 25 additions & 25 deletions config/paths.js → example/config/paths.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
var path = require('path');
var fs = require('fs');
var url = require('url');
import path from 'path';
import fs from 'fs';
import url from 'url';

const envPublicUrl = process.env.PUBLIC_URL;
const nodePaths = (process.env.NODE_PATH || '')
.split(process.platform === 'win32' ? ';' : ':')
.filter(Boolean)
.filter(folder => !path.isAbsolute(folder))
.map(resolveApp);
// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebookincubator/create-react-app/issues/637
var appDirectory = fs.realpathSync(process.cwd());
const appDirectory = fs.realpathSync(process.cwd());

function resolveApp(relativePath) {
return path.resolve(appDirectory, relativePath);
}
Expand All @@ -24,20 +31,12 @@ function resolveApp(relativePath) {
// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421

var nodePaths = (process.env.NODE_PATH || '')
.split(process.platform === 'win32' ? ';' : ':')
.filter(Boolean)
.filter(folder => !path.isAbsolute(folder))
.map(resolveApp);

var envPublicUrl = process.env.PUBLIC_URL;

function ensureSlash(path, needsSlash) {
var hasSlash = path.endsWith('/');
const hasSlash = path.endsWith('/');
if (hasSlash && !needsSlash) {
return path.substr(path, path.length - 1);
} else if (!hasSlash && needsSlash) {
return path + '/';
return `${path}/`;
} else {
return path;
}
Expand All @@ -54,26 +53,27 @@ function getPublicUrl(appPackageJson) {
// We can't use a relative path in HTML because we don't want to load something
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
function getServedPath(appPackageJson) {
var publicUrl = getPublicUrl(appPackageJson);
var servedUrl = envPublicUrl || (
publicUrl ? url.parse(publicUrl).pathname : '/'
);
const publicUrl = getPublicUrl(appPackageJson);
const servedUrl = envPublicUrl || (
publicUrl ? url.parse(publicUrl).pathname : '/'
);
return ensureSlash(servedUrl, true);
}

// config after eject: we're in ./config/
module.exports = {
export default {
appBuild: resolveApp('build'),
appPublic: resolveApp('public'),
appHtml: resolveApp('public/index.html'),
appIndexJs: resolveApp('src/index.js'),
appPublic: resolveApp('example/public'),
appHtml: resolveApp('example/public/index.html'),
appIndexJs: resolveApp('example/src/index.js'),
appPackageJson: resolveApp('package.json'),
appSrc: resolveApp('src'),
appSrc: resolveApp('example/src'),
moleculeSrc: resolveApp('molecules'),
yarnLockFile: resolveApp('yarn.lock'),
testsSetup: resolveApp('src/setupTests.js'),
testsSetup: resolveApp('example/src/setupTests.js'),
appNodeModules: resolveApp('node_modules'),
ownNodeModules: resolveApp('node_modules'),
nodePaths: nodePaths,
nodePaths,
publicUrl: getPublicUrl(resolveApp('package.json')),
servedPath: getServedPath(resolveApp('package.json'))
};
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
var autoprefixer = require('autoprefixer');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
var WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
var getClientEnvironment = require('./env');
var paths = require('./paths');


import autoprefixer from 'autoprefixer';
import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
import InterpolateHtmlPlugin from 'react-dev-utils/InterpolateHtmlPlugin';
import WatchMissingNodeModulesPlugin from 'react-dev-utils/WatchMissingNodeModulesPlugin';
import getClientEnvironment from './env';
import paths from './paths';

// Webpack uses `publicPath` to determine where the app is being served from.
// In development, we always serve from the root. This makes config easier.
var publicPath = '/';
const publicPath = '/';
// `publicUrl` is just like `publicPath`, but we will provide it to our app
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
// Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz.
var publicUrl = '';
const publicUrl = '';
// Get environment variables to inject into our app.
var env = getClientEnvironment(publicUrl);
const env = getClientEnvironment(publicUrl);

// This is the development configuration.
// It is focused on developer experience and fast rebuilds.
// The production configuration is different and lives in a separate file.
module.exports = {
export default {
// You may want 'eval' instead if you prefer to see the compiled output in DevTools.
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.
devtool: 'cheap-module-source-map',
Expand Down Expand Up @@ -79,17 +77,17 @@ module.exports = {
'react-native': 'react-native-web'
}
},

module: {
// First, run the linter.
// It's important to do this before Babel processes the JS.
/*preLoaders: [
{
test: /\.(js|jsx)$/,
loader: 'eslint',
include: paths.appSrc,
}
],*/
/* preLoaders: [
{
test: /\.(js|jsx)$/,
loader: 'eslint',
include: paths.appSrc,
}
],*/
loaders: [
// ** ADDING/UPDATING LOADERS **
// The "url" loader handles all assets unless explicitly excluded.
Expand All @@ -116,10 +114,10 @@ module.exports = {
// Process JS with Babel.
{
test: /\.(js|jsx)$/,
include: paths.appSrc,
include: [paths.appSrc, paths.moleculeSrc],
loader: 'babel',
query: {

// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
Expand All @@ -135,8 +133,8 @@ module.exports = {
test: /\.css$/,
loader: 'style!css?importLoaders=1!postcss'

//------ Using CSS Modules-----//
// loader: 'style!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss'
// ------ Using CSS Modules-----//
// loader: 'style!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss'
},
// JSON is not enabled by default in Webpack but both Node and Browserify
// allow it implicitly so we also enable it.
Expand All @@ -156,20 +154,18 @@ module.exports = {
// Remember to add the new extension(s) to the "url" loader exclusion list.
]
},

// We use PostCSS for autoprefixing only.
postcss: function() {
return [
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
]
}),
];
},
postcss: () => [
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
]
}),
],
plugins: [
// Makes some environment variables available in index.html.
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
var autoprefixer = require('autoprefixer');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var ManifestPlugin = require('webpack-manifest-plugin');
var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
var url = require('url');
var paths = require('./paths');
var getClientEnvironment = require('./env');


import autoprefixer from 'autoprefixer';
import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import ManifestPlugin from 'webpack-manifest-plugin';
import InterpolateHtmlPlugin from 'react-dev-utils/InterpolateHtmlPlugin';
import paths from './paths';
import getClientEnvironment from './env';

// Webpack uses `publicPath` to determine where the app is being served from.
// It requires a trailing slash, or the file assets will get an incorrect path.
var publicPath = paths.servedPath;
const publicPath = paths.servedPath;
// Some apps do not use client-side routing with pushState.
// For these, "homepage" can be set to "." to enable relative asset paths.
var shouldUseRelativeAssetPaths = publicPath === './';
const shouldUseRelativeAssetPaths = publicPath === './';
// `publicUrl` is just like `publicPath`, but we will provide it to our app
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
var publicUrl = publicPath.slice(0, -1);
const publicUrl = publicPath.slice(0, -1);
// Get environment variables to inject into our app.
var env = getClientEnvironment(publicUrl);
const env = getClientEnvironment(publicUrl);

// Assert this just to be safe.
// Development builds of React are slow and not intended for production.
Expand All @@ -44,7 +41,7 @@ const extractTextPluginOptions = shouldUseRelativeAssetPaths
// This is the production configuration.
// It compiles slowly and is focused on producing a fast and minimal bundle.
// The development configuration is different and lives in a separate file.
module.exports = {
export default {
// Don't attempt to continue if there are any errors.
bail: true,
// We generate sourcemaps in production. This is slow but gives good results.
Expand All @@ -64,7 +61,7 @@ module.exports = {
filename: 'static/js/[name].[chunkhash:8].js',
chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js',
// We inferred the "public path" (such as / or /my-project) from homepage.
publicPath: publicPath
publicPath
},
resolve: {
// This allows you to set a fallback for where Webpack should look for modules.
Expand All @@ -84,7 +81,7 @@ module.exports = {
'react-native': 'react-native-web'
}
},

module: {
// First, run the linter.
// It's important to do this before Babel processes the JS.
Expand Down Expand Up @@ -121,9 +118,9 @@ module.exports = {
// Process JS with Babel.
{
test: /\.(js|jsx)$/,
include: paths.appSrc,
include: [paths.appSrc, paths.moleculeSrc],
loader: 'babel',

},
// The notation here is somewhat confusing.
// "postcss" loader applies autoprefixer to our CSS.
Expand Down Expand Up @@ -164,9 +161,9 @@ module.exports = {
// Remember to add the new extension(s) to the "url" loader exclusion list.
]
},

// We use PostCSS for autoprefixing only.
postcss: function() {
postcss() {
return [
autoprefixer({
browsers: [
Expand Down
19 changes: 19 additions & 0 deletions example/public/data/catalog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"data": [
{
"image": "http://placehold.it/256x192/",
"heading": "Men's Jeans",
"text": "An index card consists of card stock cut to a standard size, used for recording and storing small amounts of discrete data. It was invented by Carl Linnaeus, around 1760."
},
{
"image": "http://placehold.it/256x192/",
"heading": "Men's Formal Pants",
"text": "An index card consists of card stock cut to a standard size, used for recording and storing small amounts of discrete data. It was invented by Carl Linnaeus, around 1760."
},
{
"image": "http://placehold.it/256x192/",
"heading": "Men's Formal Pants",
"text": "An index card consists of card stock cut to a standard size, used for recording and storing small amounts of discrete data. It was invented by Carl Linnaeus, around 1760."
}
]
}
22 changes: 22 additions & 0 deletions example/public/data/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"brandName": "Atomic React",
"theme": "light",
"defaultLogo": "https://image.ibb.co/fNJGbF/atomic_react_logo_invert.png",
"nav": [
{
"title": "Home",
"url": "https://github.com/pagesource/atomic-react",
"index": "1"
},
{
"title": "Guidelines",
"url": "https://github.com/areai51/react-component-design",
"index": "2"
},
{
"title": "Random Bash",
"url": "http://bash.org/?random",
"index": "3"
}
]
}
Loading