Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets Integration Branch: React Support with Mayflower Assets Package #1047

Merged
merged 10 commits into from
May 11, 2020
Merged
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
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';
Copy link
Contributor

@clairesunstudio clairesunstudio May 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import '../src/index.css';
import '../src/index.css';

why is this import here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That pulls in the global styling for storybook for things that should be imported only once. So things like font files, or box sizing, etc.


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