Skip to content

Commit

Permalink
Assets Integration Branch: React Support with Mayflower Assets Package (
Browse files Browse the repository at this point in the history
#1047)

* DP-18263: Adds support for assets package with react.

* DP-18263: Updates react package to use latest mayflower-assets package, removes debugging in storybook config.

* Update react/.storybook/main.js

* DP-18263: Adds .env file for react.

* DP-18263: Fixes bugs related to fonts, layouts. Removes bourbon and bourbon neat dependencies.

* DP-18263: Fixes stylelint errors for mayflower-assets.

* DP-18263: Updates mayflower-assets package.

* DP-18263: Fixes visual regression on HeaderSearch component.
  • Loading branch information
smurrayatwork authored May 11, 2020
1 parent a0b1868 commit 2286711
Show file tree
Hide file tree
Showing 128 changed files with 2,667 additions and 2,456 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
node_modules

.env

!react/.env
# Distribution folder
dist
1 change: 1 addition & 0 deletions react/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SASS_PATH=./src/components:./node_modules:./node_modules/@massds/mayflower-assets/scss:./node_modules/@massds/mayflower-assets/scss/00-base:./node_modules/@massds/mayflower-assets/scss/00-base/mixins:./node_modules/@massds/mayflower-assets/scss/01-atoms:./node_modules/@massds/mayflower-assets/scss/02-molecules:./node_modules/@massds/mayflower-assets/scss/03-organisms:./node_modules/@massds/mayflower-assets/scss/04-templates/./node_modules/@massds/mayflower-assets/scss/05-dataviz:./node_modules/@massds/mayflower-assets/scss/08-print
1 change: 1 addition & 0 deletions react/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
npm-debug.log*

src/**/*.css
src/**/*.css.map
storybook-static

backstop/data/bitmaps_test/
Expand Down
34 changes: 19 additions & 15 deletions react/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
const path = require("path");
const path = require('path');
module.exports = {
stories: ['../**/*.stories.js'],
stories: ['../src/**/*.stories.js'],
addons: [
'@storybook/addon-knobs',
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-knobs',
'@storybook/addon-viewport',
'@storybook/addon-storysource',
'@storybook/addon-a11y'
'@storybook/addon-a11y',
],
webpackFinal: async (config, { configType }) => {
// Add special plugins to the babel loader.
const babelRule = config.module.rules.find(rule => rule.loader && rule.loader.match('babel-loader'));
babelRule.options.plugins = babelRule.options.plugins.concat([
'babel-plugin-dynamic-import-node',
"@babel/proposal-export-default-from",
'@babel/proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread'
]);

// Alter the mini-css-extract-plugin to look for asset files relative to
// the storybook-static directory. Note that we guard this logic because
// the storybook development server doesn't actually use the
// mini-css-extract-plugin.
const cssRule = config.module.rules.find(rule => rule.test && 'some.css'.match(rule.test));
if(cssRule) {
const cssFileLoader = cssRule.use.find(loader => loader.loader && loader.loader.match('mini-css-extract-plugin'));
if(cssFileLoader) {
cssFileLoader.options.publicPath = '../../';
// the storybook-static directory.
if ( configType === 'PRODUCTION') {
const cssRule = config.module.rules.find(rule => rule.test && 'some.css'.match(rule.test));
if(cssRule) {
const cssFileLoader = cssRule.use.find(loader => loader.loader && loader.loader.match('mini-css-extract-plugin'));
if(cssFileLoader) {
cssFileLoader.options.publicPath = (resourcePath, context) => {
// publicPath is the relative path of the resource to the context
// e.g. for ./css/admin/main.css the publicPath will be ../../
// while for ./css/main.css the publicPath will be ../
return path.relative(path.dirname(resourcePath), context) + '/';
};
}
}
}

Expand All @@ -42,10 +46,10 @@ module.exports = {
...config.resolve,
alias: {
...config.resolve.alias,
SharedAssets: path.resolve(__dirname, '../../assets/')
SharedAssets: '@massds/mayflower-assets/static'
}};

// Return the altered config
return config;
},
};
};
5 changes: 2 additions & 3 deletions react/.storybook/mayflowerTheme.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { create } from '@storybook/theming/create';
import logo from './mayflower-react-logo.png';

export default create({
base: 'light',

Expand All @@ -14,8 +13,8 @@ export default create({
appBorderRadius: 6,

// Typography
// fontBase: '"Open Sans", sans-serif',
// fontCode: 'monospace',
fontBase: '"Texta", "Helvetica", "Arial", sans-serif',
fontCode: '"Source Code Pro", "Monaco", monospace',

// Text colors
textColor: 'black',
Expand Down
1 change: 1 addition & 0 deletions react/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { addDecorator, addParameters } from '@storybook/react';
import { withA11y } from '@storybook/addon-a11y';
import { withInfo } from '@storybook/addon-info';
import '../src/index.css';

const storyKindOrder = [
'about', // storyKindOrder.indexOf -1 follow alphabetical order
Expand Down
2 changes: 1 addition & 1 deletion react/nwb.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
['module-resolver', {
root: ['./src'],
alias: {
SharedAssets: './src/assets'
SharedAssets: '@massds/mayflower-assets/static'
}
}],
'babel-plugin-dynamic-import-node'
Expand Down
Loading

0 comments on commit 2286711

Please sign in to comment.