Skip to content

Commit 7a04ca7

Browse files
committed
css next replacement begins
1 parent 240464c commit 7a04ca7

File tree

4 files changed

+256
-216
lines changed

4 files changed

+256
-216
lines changed

README.md

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,12 @@
55
[![dependencies](https://img.shields.io/david/static-dev/spike-css-standards.svg?style=flat-square)](https://david-dm.org/static-dev/spike-css-standards)
66
[![coverage](https://img.shields.io/coveralls/static-dev/spike-css-standards.svg?style=flat-square)](https://coveralls.io/r/static-dev/spike-css-standards?branch=master)
77

8-
standard plugin pack for postcss
9-
10-
> **Note:** This project is in early development, and versioning is a little different. [Read this](http://markup.im/#q4_cRZ1Q) for more details.
11-
8+
A standard plugin pack for postcss
129

1310
### Installation
1411

1512
`npm install spike-css-standards -S`
1613

17-
> **Note:** This project is compatible with node v6+ only
18-
1914
### Usage
2015

2116
This is nothing more than a light wrapper around a postcss configuration object. Options are filtered into their appropriate plugins internally. All are optional.
@@ -28,18 +23,38 @@ const standards = cssStandards(/* options */)
2823
// returns { parser: 'xxx', plugins: ['xxx'] }
2924

3025
postcss(standards.plugins)
31-
.process(someCss, { parser: standards.parser })
26+
.process(/* css string */, { parser: standards.parser })
3227
.then((res) => { console.log(res.content) })
3328

3429
```
3530

3631
By default, the css standard plugin pack includes:
3732

38-
- [sugarss](https://github.com/postcss/sugarss), provided as default parser
39-
- [postcss-import](https://github.com/postcss/postcss-import), default settings
40-
- [postcss-cssnext](http://cssnext.io/), default settings
41-
- [rucksack](https://simplaio.github.io/rucksack/), default settings
42-
- [cssnano](http://cssnano.co/), toggled with the `minify` option which is false by default
33+
- [sugarss](https://github.com/postcss/sugarss), whitespace-based html, similar to jade/pug
34+
- [postcss-import](https://github.com/postcss/postcss-import), like `require` for css
35+
- [rucksack](https://simplaio.github.io/rucksack/), collection of syntax sugar for css
36+
- [autoprefixer](https://github.com/postcss/autoprefixer), automatic vendor prefixing
37+
- [postcss-attribute-case-insensitive](https://github.com/Semigradsky/postcss-attribute-case-insensitive), allows [case insensitive attr selectors](https://www.w3.org/TR/selectors4/#attribute-case)
38+
- [postcss-calc](https://github.com/postcss/postcss-calc), reduces calc expression where possible
39+
- [postcss-color-function](https://github.com/postcss/postcss-color-function), polyfill for [color-mod function](https://drafts.csswg.org/css-color/#modifying-colors)
40+
- [postcss-color-gray](https://github.com/postcss/postcss-color-gray), polyfill for [gray function](https://drafts.csswg.org/css-color/#grays)
41+
- [postcss-color-hex-alpha](https://github.com/postcss/postcss-color-hex-alpha), polyfill for [rgba hex notations](https://github.com/postcss/postcss-color-hex-alpha)
42+
- [postcss-color-hsl](https://github.com/dmarchena/postcss-color-hsl), polyfill for [new hsl syntax](https://drafts.csswg.org/css-color/#the-hsl-notation)
43+
- [postcss-color-hwb](https://github.com/postcss/postcss-color-hwb), polyfill for [hue whiteness blackness function](https://drafts.csswg.org/css-color/#the-hwb-notation)
44+
- [postcss-color-rebeccapurple](https://github.com/postcss/postcss-color-rebeccapurple), polyfill for [rebeccapurple color](https://drafts.csswg.org/css-color/#valdef-color-rebeccapurple)
45+
- [postcss-color-rgb](https://github.com/dmarchena/postcss-color-rgb), polyfill for [css module level 4 rgb function](https://drafts.csswg.org/css-color/#funcdef-rgb)
46+
- [postcss-custom-media](https://github.com/postcss/postcss-custom-media), polyfill for [custom media queries](https://drafts.csswg.org/mediaqueries-5/#custom-mq)
47+
- [postcss-custom-properties](https://github.com/postcss/postcss-custom-properties), polyfill for [css variables](https://www.w3.org/TR/css-variables/)
48+
- [postcss-custom-selectors](https://github.com/postcss/postcss-custom-selectors), polyfill for [custom selectors](https://drafts.csswg.org/css-extensions/#custom-selectors)
49+
- [postcss-font-family-system-ui](https://github.com/JLHwung/postcss-font-family-system-ui),
50+
- [postcss-font-variant](https://drafts.csswg.org/css-fonts-4/#system-ui-def), polyfill for generic [system-ui](https://github.com/JLHwung/postcss-font-family-system-ui) font definition
51+
- [postcss-image-set-polyfill](https://github.com/SuperOl3g/postcss-image-set-polyfill), polyfills [image-set](https://drafts.csswg.org/css-images-3/#image-set-notation) for resolution detection
52+
- [postcss-media-minmax](https://github.com/postcss/postcss-media-minmax), nice syntax sugar for media queries from [media queries level 4 spec](https://drafts.csswg.org/mediaqueries/#mq-range-context)
53+
- [postcss-nesting](https://github.com/jonathantneal/postcss-nesting), polyfill for [css nesting module level 3](http://tabatkins.github.io/specs/css-nesting/)
54+
- [postcss-pseudo-class-any-link](https://github.com/jonathantneal/postcss-pseudo-class-any-link), polyfills [:any-link pseudo-class](https://drafts.csswg.org/selectors/#any-link-pseudo)
55+
- [postcss-selector-matches](https://github.com/postcss/postcss-selector-matches), polyfills [:matches pseudo-class](https://drafts.csswg.org/selectors-4/#matches)
56+
- [postcss-selector-not](https://github.com/postcss/postcss-selector-not), polyfills [:not pseudo-class](https://drafts.csswg.org/selectors-4/#negation)
57+
- [cssnano](http://cssnano.co/), minifies css, toggled with the `minify` option which is false by default
4358

4459
Any of these plugins can be customized by passing the [options](#options) described below. You can also add additional postCSS plugins (like the popular [`lost`](https://github.com/peterramsing/lost) grid, for example) on top of this package:
4560

@@ -58,7 +73,7 @@ css.plugins.push(lost())
5873
| **root** | Root used to resolve `path`(s) from | |
5974
| **path** | A path to a folder or an array of paths, telling postcss-import where to look for sss or css files to `@import`. | |
6075
| **browsers** | Browser support provided to [autoprefixer](http://cssnext.io/usage/#browsers) | `> 1%, last 2 versions, Firefox ESR` |
61-
| **features** | Enable or disable [cssnext features](http://cssnext.io/usage/#features) | |
76+
| **features** | Enable, disable, or pass options to a most included plugins | |
6277
| **warnForDuplicates** | Enable or disable [cssnext duplicate warnings](http://cssnext.io/usage/#warnforduplicates) | `true` |
6378
| **rucksack** | Options passed directly to [rucksack](http://simplaio.github.io/rucksack/docs/#options) | |
6479
| **parser** | custom css parser if desired. pass `false` to use the default css parser | `sugarss` |

lib/index.js

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
1-
const sugarss = require('sugarss')
1+
let sugarss = require('sugarss')
22
let postcssImport = require('postcss-import')
3-
let cssnext = require('postcss-cssnext')
3+
let customProperties = require('postcss-custom-properties')
4+
let calc = require('postcss-calc')
5+
let imageSet = require('postcss-image-set')
6+
let nesting = require('postcss-nesting')
7+
let customMedia = require('postcss-custom-media')
8+
let mediaQueriesRange = require('postcss-media-minmax')
9+
let customSelectors = require('postcss-custom-selectors')
10+
let attributeCaseInsensitive = require('postcss-attribute-case-insensitive')
11+
let colorRebeccapurple = require('postcss-color-rebeccapurple')
12+
let colorHwb = require('postcss-color-hwb')
13+
let colorHsl = require('postcss-color-hsl')
14+
let colorRgb = require('postcss-color-rgb')
15+
let colorGray = require('postcss-color-gray')
16+
let colorHexAlpha = require('postcss-color-hex-alpha')
17+
let colorFunction = require('postcss-color-function')
18+
let fontFamilySystemUi = require('postcss-font-family-system-ui')
19+
let fontVariant = require('postcss-font-variant')
20+
let pseudoClassMatches = require('postcss-selector-matches')
21+
let pseudoClassNot = require('postcss-selector-not')
22+
let pseudoClassAnyLink = require('postcss-pseudo-class-any-link')
423
let rucksack = require('rucksack-css')
24+
let autoprefixer = require('autoprefixer')
525

626
/**
727
* Primary export, formats options and returns an object with intelligent
@@ -25,12 +45,31 @@ module.exports = (options = {}) => {
2545

2646
// standard options merge
2747
const importOpt = selectKeys(options, ['root', 'path'])
28-
const cssnextOpt = selectKeys(options, ['browsers', 'features', 'warnForDuplicates'])
2948

3049
// define default plugin list
3150
const plugins = [
3251
postcssImport(importOpt),
33-
cssnext(cssnextOpt),
52+
customProperties(options.customProperties),
53+
calc(options.calc),
54+
imageSet(options.imageSet),
55+
nesting(options.nesting),
56+
customMedia(options.customMedia),
57+
mediaQueriesRange(options.mediaQueriesRange),
58+
customSelectors(options.customSelectors),
59+
attributeCaseInsensitive(options.attributeCaseInsensitive),
60+
colorRebeccapurple(options.colorRebeccapurple),
61+
colorHwb(options.colorHwb),
62+
colorHsl(options.colorHsl),
63+
colorRgb(options.colorRgb),
64+
colorGray(options.colorGray),
65+
colorHexAlpha(options.colorHexAlpha),
66+
colorFunction(options.colorFunction),
67+
fontFamilySystemUi(options.fontFamilySystemUi),
68+
fontVariant(options.fontVariant),
69+
pseudoClassMatches(options.pseudoClassMatches),
70+
pseudoClassNot(options.pseudoClassNot),
71+
pseudoClassAnyLink(options.pseudoClassAnyLink),
72+
autoprefixer(options.autoprefixer),
3473
rucksack(options.rucksack)
3574
]
3675

@@ -44,7 +83,7 @@ module.exports = (options = {}) => {
4483
}
4584

4685
// add cssnano if minify config present
47-
if (options.minify) plugins.push(require('cssnano')())
86+
if (options.minify) plugins.push(require('cssnano')(options.cssnano))
4887

4988
return {parser, plugins}
5089
}

package.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,29 @@
88
},
99
"bugs": "https://github.com/static-dev/spike-css-standards/issues",
1010
"dependencies": {
11+
"autoprefixer": "^7.1.1",
1112
"cssnano": "^3.7.4",
12-
"postcss-cssnext": "^2.11.0",
13+
"postcss-attribute-case-insensitive": "^2.0.0",
14+
"postcss-calc": "^6.0.0",
15+
"postcss-color-function": "^4.0.0",
16+
"postcss-color-gray": "^4.0.0",
17+
"postcss-color-hex-alpha": "^3.0.0",
18+
"postcss-color-hsl": "^2.0.0",
19+
"postcss-color-hwb": "^3.0.0",
20+
"postcss-color-rebeccapurple": "^3.0.0",
21+
"postcss-color-rgb": "^2.0.0",
22+
"postcss-custom-media": "^6.0.0",
23+
"postcss-custom-properties": "^6.0.1",
24+
"postcss-custom-selectors": "^4.0.1",
25+
"postcss-font-family-system-ui": "^2.0.1",
26+
"postcss-font-variant": "^3.0.0",
27+
"postcss-image-set-polyfill": "^0.3.5",
1328
"postcss-import": "^10.0.0",
29+
"postcss-media-minmax": "^3.0.0",
30+
"postcss-nesting": "^4.0.1",
31+
"postcss-pseudo-class-any-link": "^4.0.0",
32+
"postcss-selector-matches": "^3.0.1",
33+
"postcss-selector-not": "^3.0.1",
1434
"rucksack-css": "^0.9.1",
1535
"sugarss": "^1.0.0"
1636
},

0 commit comments

Comments
 (0)