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

newspack-components library #72

Merged
merged 6 commits into from
May 31, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ Thumbs.db
/vendor/

# Built files
/assets/dist
/assets/dist
/assets/components/dist
/assets/components/node_modules
1 change: 1 addition & 0 deletions assets/components/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
3 changes: 3 additions & 0 deletions assets/components/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Newspack Components

This package contains UI components designed using the Muriel design system. Use these components for alternative, Muriel-styled versions of `@wordpress/components` components.
44 changes: 44 additions & 0 deletions assets/components/copy-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env node

/* eslint-disable import/no-nodejs-modules,no-console */

// find all the packages
const path = require( 'path' );
const rcopy = require( 'recursive-copy' );

const dir = process.cwd();

const inputDir = path.join( dir, 'src' );
const outputDirEsm = path.join( dir, 'dist', 'esm' );
const outputDirCommon = path.join( dir, 'dist', 'cjs' );

console.log( 'Copying styles %s', dir );

const copyOptions = {
overwrite: true,
filter: [ '**/*.scss', '**/*.svg' ],
concurrency: 127,
debug: true,
};

rcopy( inputDir, outputDirEsm, copyOptions )
.then( results => {
console.log( 'copied %d files', results.length );
} )
.catch( err => {
console.error( err );
} );
rcopy( inputDir, outputDirCommon, copyOptions )
.then( results => {
console.log( 'copied %d files', results.length );
} )
.catch( err => {
console.error( err );
} );
rcopy( path.join( dir, '..', 'shared' ), path.join( dir, 'dist', 'shared' ) )
.then( results => {
console.log( 'Copied shared lib' );
} )
.catch( err => {
console.error( err );
} );
45 changes: 45 additions & 0 deletions assets/components/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "newspack-components",
"version": "0.1.5",
"description": "Muriel design system components",
"author": "Automattic",
"license": "GPL-2.0-or-later",
"keywords": [
"wordpress",
"newspack",
"muriel",
"components"
],
"bugs": {
"url": "https://github.com/Automattic/newspack-plugin/issues"
},
"homepage": "https://github.com/Automattic/newspack-plugin",
"repository": {
"type": "git",
"url": "https://github.com/Automattic/newspack-plugin.git",
"directory": "assets/src/components"
},
"main": "dist/cjs/index.js",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@wordpress/components": "^7.3.1",
"@wordpress/element": "^2.3.0"
},
"devDependencies": {
"@automattic/calypso-build": "^2.0.0",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"recursive-copy": "2.0.10"
},
"babel": {
"ignore": [
"./node_modules"
]
},
"scripts": {
"prepublishOnly": "transpile && node copy-styles.js",
"postpublish": "rm -r dist"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Button as BaseComponent } from '@wordpress/components';
/**
* Internal dependencies
*/
import murielClassnames from '../../shared/js/muriel-classnames';
import murielClassnames from '../../../shared/js/muriel-classnames';

import './style.scss';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Button styles,
*/

@import '../../shared/scss/muriel-component';
@import '../../../shared/scss/muriel-component';

.muriel-button {
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Component } from '@wordpress/element';
/**
* Internal dependencies
*/
import murielClassnames from '../../shared/js/muriel-classnames';
import murielClassnames from '../../../shared/js/muriel-classnames';

/**
* Internal dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Card styles.
*/

@import '../../shared/scss/muriel-component';
@import '../../../shared/scss/muriel-component';

.muriel-card {
background: $muriel-white;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import { CheckboxControl as BaseComponent } from '@wordpress/components';
/**
* Internal dependencies
*/
import murielClassnames from '../../shared/js/muriel-classnames';
import InfoButton from '../../components/info-button';
import murielClassnames from '../../../shared/js/muriel-classnames';
import { InfoButton } from '../';

import './style.scss';

class CheckboxControl extends Component {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Checkbox styles.
*/

@import '../../shared/scss/muriel-component';
@import '../../../shared/scss/muriel-component';

.muriel-checkbox {
display: block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Dashicon } from '@wordpress/components';
/**
* Internal dependencies.
*/
import murielClassnames from '../../shared/js/muriel-classnames';
import murielClassnames from '../../../shared/js/muriel-classnames';
import { Button, ProgressBar } from '../';
import './style.scss';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Component } from '@wordpress/element';
/**
* Internal dependencies
*/
import murielClassnames from '../../shared/js/muriel-classnames';
import murielClassnames from '../../../shared/js/muriel-classnames';

/**
* Internal dependencies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Formatted Header styles.
*/

@import '../../shared/scss/muriel-component';
@import '../../../shared/scss/muriel-component';

.muriel-formatted-header {
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import murielClassnames from '../../shared/js/muriel-classnames';
import murielClassnames from '../../../shared/js/muriel-classnames';
import './style.scss';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Image uploader styles.
*/

@import '../../shared/scss/muriel-component';
@import '../../../shared/scss/muriel-component';

.muriel-image-upload {
button {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export { default as Card } from './card';
export { default as CheckboxControl } from './checkbox-control';
export { default as Checklist } from './checklist';
export { default as FormattedHeader } from './formatted-header';
export { default as InfoButton } from './info-button';
export { default as ImageUpload } from './image-upload';
export { default as ProgressBar } from './progress-bar';
export { default as SelectControl } from './select-control';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Info Button styles
*/

@import '../../shared/scss/muriel-component';
@import '../../../shared/scss/muriel-component';

.muriel-info-button {
background-image: url( 'info_24px.svg' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Component } from '@wordpress/element';
/**
* Internal dependencies
*/
import murielClassnames from '../../shared/js/muriel-classnames';
import murielClassnames from '../../../shared/js/muriel-classnames';
import './style.scss';

const SelectControl = withFocusOutside(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Dashicon } from '@wordpress/components';
/**
* Internal dependencies.
*/
import Button from '../button';
import { Button } from '../';
import './style.scss';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Component } from '@wordpress/element';
/**
* Internal dependencies
*/
import murielClassnames from '../../shared/js/muriel-classnames';
import murielClassnames from '../../../shared/js/muriel-classnames';
import './style.scss';

const TextControl = withFocusOutside(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Text/Number Input styles.
*/

@import '../../shared/scss/muriel-component';
@import '../../../shared/scss/muriel-component';

.muriel-input-text {
position: relative;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
Checklist,
Task,
SelectControl,
} from '../../components';
} from '../../components/src';
import './style.scss';

/**
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"@wordpress/browserslist-config": "^2.2.2",
"@wordpress/components": "^7.3.1",
"@wordpress/element": "^2.3.0",
"@wordpress/components": "^7.3.1",
"autoprefixer": "^9.1.5",
"chokidar-cli": "^1.2.1",
"classnames": "^2.2.6",
Expand Down Expand Up @@ -53,10 +52,10 @@
],
"jest": {
"setupFilesAfterEnv": [
"<rootDir>/assets/src/setupTests.js"
"<rootDir>/assets/setupTests.js"
],
"testMatch": [
"<rootDir>/**/src/**/*test.js?(x)",
"<rootDir>/**/*test.js?(x)",
"!**/.eslintrc.*"
],
"transform": {
Expand Down
6 changes: 3 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const getBaseWebpackConfig = require( '@automattic/calypso-build/webpack.config.
const path = require( 'path' );
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );

const wizardsDir = path.join( __dirname, 'assets', 'src', 'wizards' );
const wizardsDir = path.join( __dirname, 'assets', 'wizards' );

// Get files for wizards scripts.
const wizardsScripts = fs
.readdirSync( wizardsDir )
.filter( wizard => fs.existsSync( path.join( __dirname, 'assets', 'src', 'wizards', wizard, 'index.js' ) ) );
.filter( wizard => fs.existsSync( path.join( __dirname, 'assets', 'wizards', wizard, 'index.js' ) ) );
const wizardsScriptFiles = {}
wizardsScripts.forEach( function( wizard ) {
wizardsScriptFiles[ wizard ] = path.join( __dirname, 'assets', 'src', 'wizards', wizard, 'index.js' );
wizardsScriptFiles[ wizard ] = path.join( __dirname, 'assets', 'wizards', wizard, 'index.js' );
} );

const webpackConfig = getBaseWebpackConfig(
Expand Down