@csstools/postcss-text-decoration-shorthand 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changes to PostCSS Text Decoration Shorthand
2
+
3
+ ### 1.0.0 (August 15, 2022)
4
+
5
+ - Initial version
package/LICENSE.md ADDED
@@ -0,0 +1,108 @@
1
+ # CC0 1.0 Universal
2
+
3
+ ## Statement of Purpose
4
+
5
+ The laws of most jurisdictions throughout the world automatically confer
6
+ exclusive Copyright and Related Rights (defined below) upon the creator and
7
+ subsequent owner(s) (each and all, an “owner”) of an original work of
8
+ authorship and/or a database (each, a “Work”).
9
+
10
+ Certain owners wish to permanently relinquish those rights to a Work for the
11
+ purpose of contributing to a commons of creative, cultural and scientific works
12
+ (“Commons”) that the public can reliably and without fear of later claims of
13
+ infringement build upon, modify, incorporate in other works, reuse and
14
+ redistribute as freely as possible in any form whatsoever and for any purposes,
15
+ including without limitation commercial purposes. These owners may contribute
16
+ to the Commons to promote the ideal of a free culture and the further
17
+ production of creative, cultural and scientific works, or to gain reputation or
18
+ greater distribution for their Work in part through the use and efforts of
19
+ others.
20
+
21
+ For these and/or other purposes and motivations, and without any expectation of
22
+ additional consideration or compensation, the person associating CC0 with a
23
+ Work (the “Affirmer”), to the extent that he or she is an owner of Copyright
24
+ and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and
25
+ publicly distribute the Work under its terms, with knowledge of his or her
26
+ Copyright and Related Rights in the Work and the meaning and intended legal
27
+ effect of CC0 on those rights.
28
+
29
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
30
+ protected by copyright and related or neighboring rights (“Copyright and
31
+ Related Rights”). Copyright and Related Rights include, but are not limited
32
+ to, the following:
33
+ 1. the right to reproduce, adapt, distribute, perform, display, communicate,
34
+ and translate a Work;
35
+ 2. moral rights retained by the original author(s) and/or performer(s);
36
+ 3. publicity and privacy rights pertaining to a person’s image or likeness
37
+ depicted in a Work;
38
+ 4. rights protecting against unfair competition in regards to a Work,
39
+ subject to the limitations in paragraph 4(i), below;
40
+ 5. rights protecting the extraction, dissemination, use and reuse of data in
41
+ a Work;
42
+ 6. database rights (such as those arising under Directive 96/9/EC of the
43
+ European Parliament and of the Council of 11 March 1996 on the legal
44
+ protection of databases, and under any national implementation thereof,
45
+ including any amended or successor version of such directive); and
46
+ 7. other similar, equivalent or corresponding rights throughout the world
47
+ based on applicable law or treaty, and any national implementations
48
+ thereof.
49
+
50
+ 2. Waiver. To the greatest extent permitted by, but not in contravention of,
51
+ applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
52
+ unconditionally waives, abandons, and surrenders all of Affirmer’s Copyright
53
+ and Related Rights and associated claims and causes of action, whether now
54
+ known or unknown (including existing as well as future claims and causes of
55
+ action), in the Work (i) in all territories worldwide, (ii) for the maximum
56
+ duration provided by applicable law or treaty (including future time
57
+ extensions), (iii) in any current or future medium and for any number of
58
+ copies, and (iv) for any purpose whatsoever, including without limitation
59
+ commercial, advertising or promotional purposes (the “Waiver”). Affirmer
60
+ makes the Waiver for the benefit of each member of the public at large and
61
+ to the detriment of Affirmer’s heirs and successors, fully intending that
62
+ such Waiver shall not be subject to revocation, rescission, cancellation,
63
+ termination, or any other legal or equitable action to disrupt the quiet
64
+ enjoyment of the Work by the public as contemplated by Affirmer’s express
65
+ Statement of Purpose.
66
+
67
+ 3. Public License Fallback. Should any part of the Waiver for any reason be
68
+ judged legally invalid or ineffective under applicable law, then the Waiver
69
+ shall be preserved to the maximum extent permitted taking into account
70
+ Affirmer’s express Statement of Purpose. In addition, to the extent the
71
+ Waiver is so judged Affirmer hereby grants to each affected person a
72
+ royalty-free, non transferable, non sublicensable, non exclusive,
73
+ irrevocable and unconditional license to exercise Affirmer’s Copyright and
74
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
75
+ maximum duration provided by applicable law or treaty (including future time
76
+ extensions), (iii) in any current or future medium and for any number of
77
+ copies, and (iv) for any purpose whatsoever, including without limitation
78
+ commercial, advertising or promotional purposes (the “License”). The License
79
+ shall be deemed effective as of the date CC0 was applied by Affirmer to the
80
+ Work. Should any part of the License for any reason be judged legally
81
+ invalid or ineffective under applicable law, such partial invalidity or
82
+ ineffectiveness shall not invalidate the remainder of the License, and in
83
+ such case Affirmer hereby affirms that he or she will not (i) exercise any
84
+ of his or her remaining Copyright and Related Rights in the Work or (ii)
85
+ assert any associated claims and causes of action with respect to the Work,
86
+ in either case contrary to Affirmer’s express Statement of Purpose.
87
+
88
+ 4. Limitations and Disclaimers.
89
+ 1. No trademark or patent rights held by Affirmer are waived, abandoned,
90
+ surrendered, licensed or otherwise affected by this document.
91
+ 2. Affirmer offers the Work as-is and makes no representations or warranties
92
+ of any kind concerning the Work, express, implied, statutory or
93
+ otherwise, including without limitation warranties of title,
94
+ merchantability, fitness for a particular purpose, non infringement, or
95
+ the absence of latent or other defects, accuracy, or the present or
96
+ absence of errors, whether or not discoverable, all to the greatest
97
+ extent permissible under applicable law.
98
+ 3. Affirmer disclaims responsibility for clearing rights of other persons
99
+ that may apply to the Work or any use thereof, including without
100
+ limitation any person’s Copyright and Related Rights in the Work.
101
+ Further, Affirmer disclaims responsibility for obtaining any necessary
102
+ consents, permissions or other rights required for any use of the Work.
103
+ 4. Affirmer understands and acknowledges that Creative Commons is not a
104
+ party to this document and has no duty or obligation with respect to this
105
+ CC0 or use of the Work.
106
+
107
+ For more information, please see
108
+ http://creativecommons.org/publicdomain/zero/1.0/.
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # PostCSS Text Decoration Shorthand [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
2
+
3
+ [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-text-decoration-shorthand.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/text-decoration-shorthand.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
4
+
5
+ [PostCSS Text Decoration Shorthand] lets you use `text-decoration` as a shorthand following the [Text Decoration Specification].
6
+
7
+ ```pcss
8
+ .example {
9
+ text-decoration: wavy underline purple 25%;
10
+ }
11
+
12
+ /* becomes */
13
+
14
+ .example {
15
+ text-decoration: underline;
16
+ text-decoration: underline wavy purple;
17
+ text-decoration-thickness: calc(0.01em * 25);
18
+ }
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ Add [PostCSS Text Decoration Shorthand] to your project:
24
+
25
+ ```bash
26
+ npm install postcss @csstools/postcss-text-decoration-shorthand --save-dev
27
+ ```
28
+
29
+ Use it as a [PostCSS] plugin:
30
+
31
+ ```js
32
+ const postcss = require('postcss');
33
+ const postcssTextDecorationShorthand = require('@csstools/postcss-text-decoration-shorthand');
34
+
35
+ postcss([
36
+ postcssTextDecorationShorthand(/* pluginOptions */)
37
+ ]).process(YOUR_CSS /*, processOptions */);
38
+ ```
39
+
40
+ [PostCSS Text Decoration Shorthand] runs in all Node environments, with special
41
+ instructions for:
42
+
43
+ | [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
44
+ | --- | --- | --- | --- | --- | --- |
45
+
46
+ ## Options
47
+
48
+ ### preserve
49
+
50
+ The `preserve` option determines whether the original notation
51
+ is preserved. By default, it is not preserved.
52
+
53
+ ```js
54
+ postcssTextDecorationShorthand({ preserve: true })
55
+ ```
56
+
57
+ ```pcss
58
+ .example {
59
+ text-decoration: wavy underline purple 25%;
60
+ }
61
+
62
+ /* becomes */
63
+
64
+ .example {
65
+ text-decoration: underline;
66
+ text-decoration: underline wavy purple;
67
+ text-decoration-thickness: calc(0.01em * 25);
68
+ text-decoration: wavy underline purple 25%;
69
+ }
70
+ ```
71
+
72
+ [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
73
+ [css-url]: https://cssdb.org/#text-decoration-shorthand
74
+ [discord]: https://discord.gg/bUadyRwkJS
75
+ [npm-url]: https://www.npmjs.com/package/@csstools/postcss-text-decoration-shorthand
76
+
77
+ [Gulp PostCSS]: https://github.com/postcss/gulp-postcss
78
+ [Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
79
+ [PostCSS]: https://github.com/postcss/postcss
80
+ [PostCSS Loader]: https://github.com/postcss/postcss-loader
81
+ [PostCSS Text Decoration Shorthand]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-text-decoration-shorthand
82
+ [Text Decoration Specification]: https://drafts.csswg.org/css-text-decor-4/#text-decoration-property
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=e(require("postcss-value-parser"));const l=e=>{const l=Object.assign({preserve:!1},e);return{postcssPlugin:"postcss-text-decoration-shorthand",prepare(){const e=new Map;return{OnceExit:()=>{e.clear()},Declaration:i=>{if("text-decoration"!==i.prop.toLowerCase())return;const s=i.parent.index(i);if(i.parent.nodes.some((r=>"decl"===r.type&&"text-decoration"===r.prop.toLowerCase()&&e.get(i.value)===r.value&&i.parent.index(r)!==s)))return;const u=r.default(i.value).nodes.filter((e=>"space"!==e.type&&"comment"!==e.type));if(u.length>4)return;if(u.find((e=>"var"===e.value.toLowerCase()&&"function"===e.type)))return;if(u.find((e=>"word"===e.type&&o.includes(e.value))))return;const d={line:null,style:null,color:null,thickness:null};for(let e=0;e<u.length;e++){const r=u[e];"word"===r.type&&a.includes(r.value.toLowerCase())?d.line=r:"word"===r.type&&n.includes(r.value.toLowerCase())?d.style=r:t(r)?d.color=r:"word"!==r.type||"none"!==r.value.toLowerCase()?d.thickness=r:(d.color||(d.color=r),d.line||(d.line=r))}d.line||(d.line={type:"word",value:"none"}),d.style||(d.style={type:"word",value:"solid"}),d.color||(d.color={type:"word",value:"currentColor"});try{const e=r.default.unit(d.thickness.value);e&&"%"===e.unit&&(d.thickness={type:"function",value:"calc",nodes:[{type:"word",value:"0.01em"},{type:"space",value:" "},{type:"word",value:"*"},{type:"space",value:" "},{type:"word",value:e.number}]})}catch(e){}const c=r.default.stringify(d.line);if(i.value.toLowerCase()===c)return;const p=r.default.stringify([d.line,{type:"space",value:" "},d.style,{type:"space",value:" "},d.color]);i.cloneBefore({prop:"text-decoration",value:c}),(d.thickness||3!==u.length)&&i.cloneBefore({prop:"text-decoration",value:p}),d.thickness&&i.cloneBefore({prop:"text-decoration-thickness",value:r.default.stringify([d.thickness])}),e.set(i.value,c),e.set(p,c),l.preserve||i.remove()}}}}};function t(e){return!("word"!==e.type||!e.value.startsWith("#"))||(!("word"!==e.type||!s.includes(e.value.toLowerCase()))||!("function"!==e.type||!i.includes(e.value.toLowerCase())))}l.postcss=!0;const o=["unset","inherit","initial","revert","revert-layer"],a=["underline","overline","line-through","blink","spelling-error","grammar-error"],n=["solid","double","dotted","dashed","wavy"],i=["rgb","rgba","hsl","hsla","hwb","lch","lab","color","oklch","oklab"],s=["currentcolor","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","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","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","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"];module.exports=l;
@@ -0,0 +1,7 @@
1
+ import type { PluginCreator } from 'postcss';
2
+ declare type pluginOptions = {
3
+ color?: string;
4
+ preserve?: boolean;
5
+ };
6
+ declare const creator: PluginCreator<pluginOptions>;
7
+ export default creator;
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import e from"postcss-value-parser";const r=r=>{const n=Object.assign({preserve:!1},r);return{postcssPlugin:"postcss-text-decoration-shorthand",prepare(){const r=new Map;return{OnceExit:()=>{r.clear()},Declaration:i=>{if("text-decoration"!==i.prop.toLowerCase())return;const s=i.parent.index(i);if(i.parent.nodes.some((e=>"decl"===e.type&&"text-decoration"===e.prop.toLowerCase()&&r.get(i.value)===e.value&&i.parent.index(e)!==s)))return;const u=e(i.value).nodes.filter((e=>"space"!==e.type&&"comment"!==e.type));if(u.length>4)return;if(u.find((e=>"var"===e.value.toLowerCase()&&"function"===e.type)))return;if(u.find((e=>"word"===e.type&&o.includes(e.value))))return;const d={line:null,style:null,color:null,thickness:null};for(let e=0;e<u.length;e++){const r=u[e];"word"===r.type&&t.includes(r.value.toLowerCase())?d.line=r:"word"===r.type&&a.includes(r.value.toLowerCase())?d.style=r:l(r)?d.color=r:"word"!==r.type||"none"!==r.value.toLowerCase()?d.thickness=r:(d.color||(d.color=r),d.line||(d.line=r))}d.line||(d.line={type:"word",value:"none"}),d.style||(d.style={type:"word",value:"solid"}),d.color||(d.color={type:"word",value:"currentColor"});try{const r=e.unit(d.thickness.value);r&&"%"===r.unit&&(d.thickness={type:"function",value:"calc",nodes:[{type:"word",value:"0.01em"},{type:"space",value:" "},{type:"word",value:"*"},{type:"space",value:" "},{type:"word",value:r.number}]})}catch(e){}const c=e.stringify(d.line);if(i.value.toLowerCase()===c)return;const p=e.stringify([d.line,{type:"space",value:" "},d.style,{type:"space",value:" "},d.color]);i.cloneBefore({prop:"text-decoration",value:c}),(d.thickness||3!==u.length)&&i.cloneBefore({prop:"text-decoration",value:p}),d.thickness&&i.cloneBefore({prop:"text-decoration-thickness",value:e.stringify([d.thickness])}),r.set(i.value,c),r.set(p,c),n.preserve||i.remove()}}}}};function l(e){return!("word"!==e.type||!e.value.startsWith("#"))||(!("word"!==e.type||!i.includes(e.value.toLowerCase()))||!("function"!==e.type||!n.includes(e.value.toLowerCase())))}r.postcss=!0;const o=["unset","inherit","initial","revert","revert-layer"],t=["underline","overline","line-through","blink","spelling-error","grammar-error"],a=["solid","double","dotted","dashed","wavy"],n=["rgb","rgba","hsl","hsla","hwb","lch","lab","color","oklch","oklab"],i=["currentcolor","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","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","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","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"];export{r as default};
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@csstools/postcss-text-decoration-shorthand",
3
+ "description": "Use text-decoration in it's shorthand form in CSS",
4
+ "version": "1.0.0",
5
+ "contributors": [
6
+ {
7
+ "name": "Antonio Laguna",
8
+ "email": "antonio@laguna.es",
9
+ "url": "https://antonio.laguna.es"
10
+ },
11
+ {
12
+ "name": "Romain Menke",
13
+ "email": "romainmenke@gmail.com"
14
+ }
15
+ ],
16
+ "license": "CC0-1.0",
17
+ "funding": {
18
+ "type": "opencollective",
19
+ "url": "https://opencollective.com/csstools"
20
+ },
21
+ "engines": {
22
+ "node": "^12 || ^14 || >=16"
23
+ },
24
+ "main": "dist/index.cjs",
25
+ "module": "dist/index.mjs",
26
+ "types": "dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "import": "./dist/index.mjs",
30
+ "require": "./dist/index.cjs",
31
+ "default": "./dist/index.mjs"
32
+ }
33
+ },
34
+ "files": [
35
+ "CHANGELOG.md",
36
+ "LICENSE.md",
37
+ "README.md",
38
+ "dist"
39
+ ],
40
+ "dependencies": {
41
+ "postcss-value-parser": "^4.2.0"
42
+ },
43
+ "peerDependencies": {
44
+ "postcss": "^8.2"
45
+ },
46
+ "devDependencies": {
47
+ "autoprefixer": "^10.4.8"
48
+ },
49
+ "scripts": {
50
+ "build": "rollup -c ../../rollup/default.js",
51
+ "clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"",
52
+ "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs",
53
+ "lint": "npm run lint:eslint && npm run lint:package-json",
54
+ "lint:eslint": "eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern",
55
+ "lint:package-json": "node ../../.github/bin/format-package-json.mjs",
56
+ "prepublishOnly": "npm run clean && npm run build && npm run test",
57
+ "test": "node .tape.mjs && npm run test:exports",
58
+ "test:exports": "node ./test/_import.mjs && node ./test/_require.cjs",
59
+ "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
60
+ },
61
+ "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-text-decoration-shorthand#readme",
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "https://github.com/csstools/postcss-plugins.git",
65
+ "directory": "plugins/postcss-text-decoration-shorthand"
66
+ },
67
+ "bugs": "https://github.com/csstools/postcss-plugins/issues",
68
+ "keywords": [
69
+ "css",
70
+ "postcss-plugin",
71
+ "shorthand",
72
+ "text-decoration",
73
+ "text-decoration-thickness"
74
+ ],
75
+ "csstools": {
76
+ "cssdbId": "text-decoration-shorthand",
77
+ "exportName": "postcssTextDecorationShorthand",
78
+ "humanReadableName": "PostCSS Text Decoration Shorthand",
79
+ "specUrl": "https://drafts.csswg.org/css-text-decor-4/#text-decoration-property"
80
+ },
81
+ "volta": {
82
+ "extends": "../../package.json"
83
+ }
84
+ }