Skip to content
This repository has been archived by the owner on Dec 28, 2024. It is now read-only.

feat: Support PostCSS 8 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{json,md,yml}]
indent_size = 2
indent_style = space
122 changes: 0 additions & 122 deletions .eslintrc

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Node.js CI

on:
push:
branches: master
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x, 17.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
node_modules/
npm-debug.log
node_modules
package-lock.json
yarn.lock
.*
!.editorconfig
!.gitignore
!.tape.js
!.github
*.log*
*.result.css
8 changes: 0 additions & 8 deletions .npmignore

This file was deleted.

20 changes: 20 additions & 0 deletions .tape.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
'basic': {
message: 'supports basic usage'
},
'basic:w-prefix': {
message: 'ignores basic usage when { prefix: "x" }',
options: {
prefix: 'x'
}
},
'prefix': {
message: 'ignores prefix usage'
},
'prefix:w-prefix': {
message: 'supports prefix usage when { prefix: "x" }',
options: {
prefix: 'x'
}
}
};
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Short Text [![Build Status][ci-img]][ci]
# Short Text [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]

<img align="right" width="135" height="95" src="http://postcss.github.io/postcss/logo-leftp.png" title="Philosopher’s stone, logo of PostCSS">
[![NPM Version][npm-img]][npm-url]
[![Build Status][cli-img]][cli-url]
[![Licensing][lic-img]][lic-url]
[![Gitter Chat][git-img]][git-url]

[Short Text] is a [PostCSS] plugin that lets you use a shorthand `text` property in CSS.

Expand Down Expand Up @@ -133,8 +136,15 @@ Default: `null`

Specifies a prefix to be surrounded by dashes before the declaration (e.g. `-x-text`).

[ci]: https://travis-ci.org/jonathantneal/postcss-short-text
[ci-img]: https://travis-ci.org/jonathantneal/postcss-short-text.svg
[cli-url]: https://github.com/csstools/postcss-short-text/actions/workflows/ci.yaml
[cli-img]: https://github.com/csstools/postcss-short-text/actions/workflows/ci.yaml/badge.svg
[git-url]: https://gitter.im/postcss/postcss
[git-img]: https://img.shields.io/badge/chat-gitter-blue.svg
[lic-url]: LICENSE.md
[lic-img]: https://img.shields.io/npm/l/postcss-short-text.svg
[npm-url]: https://www.npmjs.com/package/postcss-short-text
[npm-img]: https://img.shields.io/npm/v/postcss-short-text.svg

[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
[PostCSS]: https://github.com/postcss/postcss
Expand Down
25 changes: 0 additions & 25 deletions gulpfile.js

This file was deleted.

39 changes: 22 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var assign = require('object-assign');
var postcss = require('postcss');
var matches = [{
const postcss = require('postcss');

const matches = [{
'color': /^(\*|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|currentColor|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|inherit|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|#[0-9a-f]+|(hsl|rgb)a?\(.+\))$/i
}, {
'font-style': /^(\*|var\(.+\)|inherit|italic|normal|oblique)$/i,
Expand All @@ -21,24 +21,27 @@ var matches = [{
'word-spacing': /^(\*|(calc|var)\(.+\)|inherit|initial|normal|unset|0|[-+]?[0-9]*\.?[0-9]+(%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw))$/i
}];

module.exports = postcss.plugin('postcss-short-text', function (opts) {
var name = opts && opts.prefix ? '-' + opts.prefix + '-text' : 'text';
module.exports = (opts = {}) => {
const name = opts && opts.prefix ? '-' + opts.prefix + '-text' : 'text';

return function (css) {
css.walkDecls(name, function (decl) {
var values = postcss.list.space(decl.value);
var sources = matches.slice(0).map(function (source) {
return assign({}, source);
});
return {
postcssPlugin: 'postcss-short-text',
Declaration (decl) {
if (decl.prop !== name) {
return
}

values.forEach(function (value) {
const values = postcss.list.space(decl.value);
const sources = matches.slice(0).map((source) => Object.assign({}, source));

values.forEach((value) => {
all: {
var source;
let source

while (source = sources[0]) {
source.state = source.state || 'skipped';

for (var prop in source) {
for (const prop in source) {
if (prop !== 'state' && source[prop].test(value)) {
source.state = 'done';

Expand All @@ -61,6 +64,8 @@ module.exports = postcss.plugin('postcss-short-text', function (opts) {
});

decl.remove();
});
};
});
}
}
}

module.exports.postcss = true;
Loading