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

Packages: Move Custom CSS Properties to new calypso-css-custom-properties package #30933

Merged
merged 36 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
460ecb0
Move assets/stylesheets/shared/ to packages/calypso-shared-style/src/
ockham Feb 21, 2019
8f719da
Move moar stuff
ockham Feb 21, 2019
f8bd083
Fix paths
ockham Feb 21, 2019
dbdd0ed
Add package.json
ockham Feb 21, 2019
008cf02
Fix a path
ockham Feb 21, 2019
c992ba1
Remove now-obsolete prebuild-css script
ockham Feb 21, 2019
50f7f4e
Drop now-obsolete BuildCustomPropertiesCssPlugin
ockham Feb 21, 2019
f8bce81
Add new @automattic/calypso-shared-style dependency
ockham Feb 21, 2019
927ff12
Move stuff back
ockham Feb 21, 2019
98a3a72
Fix paths
ockham Feb 21, 2019
2d81db5
Moar path fixes
ockham Feb 21, 2019
04e78db
Rename to calypso-css-custom-properties
ockham Feb 21, 2019
79d1bc3
shrinkwrap
ockham Feb 21, 2019
ff8b964
Add README
ockham Feb 21, 2019
5017a6d
Small README follow-up
ockham Feb 21, 2019
8d6b823
Remove color-studio dependency
ockham Feb 21, 2019
f236805
Simplify postcss.config.js
ockham Feb 22, 2019
1945341
Nicer external SASS import paths
ockham Feb 25, 2019
2cac29a
Make sure output dir exists
ockham Feb 28, 2019
0b6cf2f
Shut up eslint
ockham Feb 28, 2019
4141963
Add package-lock.json
ockham Feb 28, 2019
ba2d25a
Update README
ockham Feb 28, 2019
1e753c9
Add package eslint
sirreal Mar 1, 2019
6ddaffd
Use standard sass imports by copying required file
sirreal Mar 1, 2019
d501480
Remove package-lock.json
ockham Mar 1, 2019
d1479de
Update deps
sirreal Mar 1, 2019
5e8baa2
Make scripts more consistent and robust
sirreal Mar 1, 2019
afdb29f
Build packages before css
sirreal Mar 1, 2019
04c0c79
Add clean scripts
sirreal Mar 1, 2019
43e0adc
Drop build steps from package readme
sirreal Mar 1, 2019
502b56c
Use npx lerna
sirreal Mar 1, 2019
0ef1c22
Update new package name
sirreal Mar 5, 2019
6df1215
Update README
sirreal Mar 5, 2019
9eb4956
Rename files to calypso-color-schemes
sirreal Mar 5, 2019
79b88b8
update name of the css file in package
blowery Mar 5, 2019
82ec0a7
Update deps
sirreal Mar 6, 2019
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 assets/stylesheets/directly.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// QUIT AND RESTART YOUR BROWSER NORMALLY WHEN YOU'RE DONE MAKING LOCAL CSS CHANGES.

@import 'shared/mixins/mixins';
@import 'shared/colors';
@import '~@automattic/calypso-css-custom-properties/src/shared/colors';
@import 'shared/extends-forms';
@import 'shared/forms';
@import 'shared/typography';
Expand Down
5 changes: 2 additions & 3 deletions assets/stylesheets/editor.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

@import 'shared/colors';
@import 'shared/color-schemes';
@import '~@automattic/calypso-css-custom-properties/src/shared/colors';
@import '~@automattic/calypso-css-custom-properties/src/shared/color-schemes';
@import 'shared/typography';
@import 'shared/mixins/breakpoints';

Expand Down
3 changes: 1 addition & 2 deletions assets/stylesheets/shared/_utils.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

@import '../shared/functions'; // functions that we've used from Compass, ported over
@import '../shared/functions/functions'; // sass functions for z-index, etc.
@import '../shared/colors'; // import all of our wpcom colors
@import '~@automattic/calypso-css-custom-properties/src/shared/colors'; // import all of our wpcom colors
@import '../shared/typography'; // all the typographic rules, variables, etc.
@import '../shared/variables'; // other variables
@import '../shared/mixins/mixins'; // sass mixins for gradients, bordius radii, etc.
Expand Down
3 changes: 1 addition & 2 deletions assets/stylesheets/shared/functions/_functions.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

@import 'hex-to-rgb';
@import '~@automattic/calypso-css-custom-properties/src/shared/functions/_hex-to-rgb';
@import 'overflow-gradient';
@import 'z-index';
3 changes: 1 addition & 2 deletions assets/stylesheets/style.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

// External Dependencies
@import 'vendor';

// Shared
@import 'shared/reset'; // css reset before the rest of the styles are defined
@import 'shared/utils'; // utilities that are used by all CSS but don't produce any code
@import 'shared/color-schemes'; // import color schemes
@import '~@automattic/calypso-css-custom-properties/src/shared/color-schemes'; // import color schemes
@import 'shared/animation'; // all UI animation
@import 'shared/forms'; // form styling
@import 'shared/welcome'; // welcome messages
Expand Down
9 changes: 0 additions & 9 deletions bin/build-custom-properties-css.js

This file was deleted.

20 changes: 16 additions & 4 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
"classnames": "2.2.6",
"click-outside": "2.0.2",
"clipboard": "2.0.4",
"color-studio": "github:automattic/color-studio#1.0.1",
"component-closest": "1.0.1",
"component-file-picker": "0.2.1",
"cookie": "0.3.1",
Expand Down Expand Up @@ -228,7 +227,6 @@
"postcss": "postcss -r",
"prebuild": "npm run -s install-if-deps-outdated",
"build": "npm run build-css && npm run build-packages && run-p -s build-devdocs:* build-server build-client-if-prod build-client-if-desktop",
"prebuild-css": "node bin/build-custom-properties-css.js",
"build-css": "run-p -s build-css:*",
"build-css:debug": "node-sass --importer node_modules/node-sass-package-importer/dist/cli.js --include-path client --source-map \"public/style-debug.css.map\" assets/stylesheets/style.scss public/style-debug.css && npm run -s postcss -- public/style-debug.css && rtlcss public/style-debug.css public/style-debug-rtl.css",
"build-css:directly": "node-sass --importer node_modules/node-sass-package-importer/dist/cli.js --include-path client assets/stylesheets/directly.scss public/directly.css --output-style compressed && npm run -s postcss -- public/directly.css",
Expand Down Expand Up @@ -288,6 +286,7 @@
},
"devDependencies": {
"@automattic/babel-plugin-i18n-calypso": "file:./packages/babel-plugin-i18n-calypso",
"@automattic/calypso-css-custom-properties": "file:./packages/calypso-css-custom-properties",
"@babel/plugin-transform-react-jsx": "7.3.0",
"@wordpress/babel-plugin-makepot": "2.1.3",
"babel-eslint": "10.0.1",
Expand Down
5 changes: 5 additions & 0 deletions packages/calypso-css-custom-properties/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
rules: {
'import/no-extraneous-dependencies': [ 'error', { packageDir: __dirname } ],
},
};
1 change: 1 addition & 0 deletions packages/calypso-css-custom-properties/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/__color-studio
11 changes: 11 additions & 0 deletions packages/calypso-css-custom-properties/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Calypso CSS Custom Properties

This package contains a number of CSS custom properties (i.e. variables) for use in Calypso.
Most of them are synonyms for colors defined by the [Color Studio](https://automattic.github.io/color-studio/).
Copy link
Member

Choose a reason for hiding this comment

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

Let me propose a better name: calypso-color-schemes. Because that's what the package contains: definitions of the Calypso color scheme CSS variables. It's not just a random bag of CSS variables, but they all have a common purpose.

Most of them are synonyms for colors defined by the Color Studio

That's not true 🙂 Color Studio provides the Muriel color palette, something much more generic than Calypso and its color schemes.

This package provides definitions for Calypso color schemes specifically. The default "Classic Bright" and the custom "Classic Blue" and "Laser Black" ones. There are variables like --color-primary, --color-accent and --masterbar-color that map to the muriel-* colors provided by Color Studio.

Copy link
Member

Choose a reason for hiding this comment

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

I'm happy to go with @automattic/calypso-color-schemes unless there are any other objections.

Copy link
Member

Choose a reason for hiding this comment

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

i'm ok with that :)

Copy link
Contributor

Choose a reason for hiding this comment

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

+1


## Build Steps

```
npm ci
sirreal marked this conversation as resolved.
Show resolved Hide resolved
npm run build
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-disable import/no-nodejs-modules */
const { dirname, join } = require( 'path' );
const { existsSync, mkdirSync, writeFileSync } = require( 'fs' );
const { renderSync } = require( 'node-sass' );

const INPUT_FILE = join( __dirname, '..', 'src', 'custom-properties.scss' );
const OUTPUT_FILE = join( __dirname, '..', 'dist', 'custom-properties.css' );

if ( ! existsSync( dirname( OUTPUT_FILE ) ) ) {
mkdirSync( dirname( OUTPUT_FILE ), { recursive: true } );
}
Copy link
Contributor Author

@ockham ockham Mar 7, 2019

Choose a reason for hiding this comment

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

I didn't add an exitsSync check since my reading (and testing) of the recursive: true arg was that it worked even if the path existed already 😬 (But I should've commented to that effect.)


const output = renderSync( { file: INPUT_FILE } );
writeFileSync( OUTPUT_FILE, output.css );
12 changes: 12 additions & 0 deletions packages/calypso-css-custom-properties/bin/postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-disable import/no-nodejs-modules */
const { dirname, join } = require( 'path' );
const { copyFileSync, existsSync, mkdirSync } = require( 'fs' );

const srcFile = 'color-variables.scss';
const target = join( __dirname, '..', 'src', '__color-studio', srcFile );

if ( ! existsSync( dirname( target ) ) ) {
mkdirSync( dirname( target ), { recursive: true } );
}

copyFileSync( require.resolve( 'color-studio/dist/' + srcFile ), join( target ) );
39 changes: 39 additions & 0 deletions packages/calypso-css-custom-properties/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
sirreal marked this conversation as resolved.
Show resolved Hide resolved
"name": "@automattic/calypso-css-custom-properties",
"version": "1.0.0-alpha.0",
"description": "Calypso Shared Style Bits",
"author": "Automattic",
"license": "GPL-2.0-or-later",
"keywords": [
"calypso",
"wordpress",
"sass",
"css"
],
"homepage": "https://github.com/Automattic/wp-calypso/tree/master/packages/calypso-css-custom-properties/README.md",
"repository": {
"type": "git",
"url": "https://github.com/Automattic/wp-calypso.git"
},
"bugs": {
"url": "https://github.com/Automattic/wp-calypso/issues"
},
"engines": {
"node": "^10.13.0",
"npm": "^6.1.0"
},
"main": "dist/custom-properties.css",
"dependencies": {
"color-studio": "github:automattic/color-studio#1.0.1"
},
"devDependencies": {
"node-sass": "^4.11.0"
sirreal marked this conversation as resolved.
Show resolved Hide resolved
sirreal marked this conversation as resolved.
Show resolved Hide resolved
},
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "node bin/build-custom-properties-css.js",
"postinstall": "node bin/postinstall.js"
sirreal marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// The Muriel Color Palette
@import '~color-studio/dist/color-variables';
@import '../__color-studio/color-variables';

// TODO: where possible we should replace the colors below with the Muriel Color Palette.
// The goals is to eventually have a single source of truth for colors across all our products.
Expand Down
4 changes: 1 addition & 3 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const path = require( 'path' );

module.exports = ( { options: { preserveCssCustomProperties = true } } ) => ( {
plugins: {
'postcss-custom-properties': {
importFrom: [ path.join( __dirname, 'public', 'custom-properties.css' ) ],
importFrom: [ require.resolve( '@automattic/calypso-css-custom-properties' ) ],
preserve: preserveCssCustomProperties,
},
autoprefixer: {},
Expand Down
14 changes: 0 additions & 14 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,6 @@ const shouldCheckForCycles = process.env.CHECK_CYCLES === 'true';
const codeSplit = config.isEnabled( 'code-splitting' );
const isCalypsoClient = process.env.CALYPSO_CLIENT === 'true';

/**
* Plugin that generates the `public/custom-properties.css` file before compilation
*/
class BuildCustomPropertiesCssPlugin {
apply( compiler ) {
compiler.hooks.compile.tap( 'BuildCustomPropertiesCssPlugin', () =>
execSync( 'node ' + path.join( __dirname, 'bin', 'build-custom-properties-css.js' ), {
cwd: __dirname,
} )
);
}
}

/*
* Create reporter for ProgressPlugin (used with EMIT_STATS)
*/
Expand Down Expand Up @@ -370,7 +357,6 @@ function getWebpackConfig( {
},
} ),
shouldEmitStats && new webpack.ProgressPlugin( createProgressHandler() ),
new BuildCustomPropertiesCssPlugin(),
new MomentTimezoneDataPlugin( {
startYear: 2000,
} ),
Expand Down