diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2023-10-14 15:05:55 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2023-10-14 15:05:55 +0800 |
| commit | c06f7ee0a40255214c477e13d9b956a7e07c2900 (patch) | |
| tree | f5982a568ef8fab865d0142e71c7494fea3e4c1b /node_modules/postcss-font-variant | |
| parent | 3fd9400d4dccc25aa29b5702216732e0b7542073 (diff) | |
postcss,(plugins): nanocss, postcss-preset-env
Diffstat (limited to 'node_modules/postcss-font-variant')
| -rwxr-xr-x | node_modules/postcss-font-variant/CHANGELOG.md | 48 | ||||
| -rwxr-xr-x | node_modules/postcss-font-variant/LICENSE | 20 | ||||
| -rwxr-xr-x | node_modules/postcss-font-variant/README.md | 74 | ||||
| -rwxr-xr-x | node_modules/postcss-font-variant/index.js | 126 | ||||
| -rw-r--r-- | node_modules/postcss-font-variant/package.json | 36 |
5 files changed, 304 insertions, 0 deletions
diff --git a/node_modules/postcss-font-variant/CHANGELOG.md b/node_modules/postcss-font-variant/CHANGELOG.md new file mode 100755 index 00000000..51859470 --- /dev/null +++ b/node_modules/postcss-font-variant/CHANGELOG.md @@ -0,0 +1,48 @@ +# 5.0.0 - 2021-01-12 + +- Changed: use PostCSS 7 API +- Updated: Node support to 10.0.0 (major) + +# 4.0.1 - 2020-10-28 + +- Fixed: Incorrect conversion of small-caps ([#15](https://github.com/postcss/postcss-font-variant/pull/15)) + +# 4.0.0 - 2018-09-17 + +- Changed: use PostCSS 7 API + +# 3.0.0 - 2017-05-11 + +- Changed: use PostCSS 6 API + +# 2.0.1 - 2016-07-08 + +- Fixed: existing font-feature-settings being duplicated. + ([#8](https://github.com/postcss/postcss-font-variant/pull/8) - @ChaosExAnima) + +# 2.0.0 - 2015-09-08 + +- Added: compatibility with postcss v5.x +- Removed: compatiblity with postcss v4.x + +# 1.2.0 - 2015-08-13 + +- Added: compatibility with postcss v4.1.x + ([#5](https://github.com/postcss/postcss-font-variant/pull/5)) + +# 1.1.0 - 2015-01-29 + + - Fixed: Properly handle font-variant-position:normal ([#3](https://github.com/postcss/postcss-font-variant/pull/3)) + - Added: support font-kerning ([#2](https://github.com/postcss/postcss-font-variant/pull/2)) + +# 1.0.2 - 2015-01-27 + +- Fixed: Re–use existing font-feature-settings declarations to avoid creating multiples that override themselves ([#1](https://github.com/postcss/postcss-font-variant/pull/1)) + +# 1.0.1 - 2014-11-11 + +- Fixed: wrong space char that breaks on some environnements + +# 1.0.0 - 2014-10-09 + +✨ First release based on [rework-font-variant](https://github.com/ianstormtaylor/rework-font-variant) v1.0.1 diff --git a/node_modules/postcss-font-variant/LICENSE b/node_modules/postcss-font-variant/LICENSE new file mode 100755 index 00000000..efbafd76 --- /dev/null +++ b/node_modules/postcss-font-variant/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2014 Maxime Thirouin & Ian Storm Taylor + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/postcss-font-variant/README.md b/node_modules/postcss-font-variant/README.md new file mode 100755 index 00000000..bb2bcdfe --- /dev/null +++ b/node_modules/postcss-font-variant/README.md @@ -0,0 +1,74 @@ +# PostCSS Font-Variant [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">](https://github.com/postcss/postcss/) + +[](https://cssdb.org/#font-variant-property) +[](https://travis-ci.org/postcss/postcss-font-variant) + +PostCSS Font-Variant lets you use `font-variant` in CSS, following the +[CSS Fonts](https://www.w3.org/TR/css-fonts-3/#font-variant-prop) specification. + +## Installation + +```console +$ npm install postcss-font-variant +``` + +## Usage + +```js +// dependencies +var postcss = require("postcss") +var fontVariant = require("postcss-font-variant") + +// css to be processed +var css = fs.readFileSync("input.css", "utf8") + +// process css using postcss-font-variant +var out = postcss() + .use(fontVariant()) + .process(css) + .css +``` + +Using this `input.css`: + +```css +h2 { + font-variant-caps: small-caps; +} + +table { + font-variant-numeric: lining-nums; +} +``` + +you will get: + +```css +h2 { + font-feature-settings: "smcp"; + font-variant-caps: small-caps; +} + +table { + font-feature-settings: "lnum"; + font-variant-numeric: lining-nums; +} + +``` + +Checkout [tests](test) for more examples. + +--- + +## Contributing + +Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature. + + $ git clone https://github.com/postcss/postcss-font-variant.git + $ git checkout -b patch-1 + $ npm install + $ npm test + +## [Changelog](CHANGELOG.md) + +## [License](LICENSE) diff --git a/node_modules/postcss-font-variant/index.js b/node_modules/postcss-font-variant/index.js new file mode 100755 index 00000000..72ccf53a --- /dev/null +++ b/node_modules/postcss-font-variant/index.js @@ -0,0 +1,126 @@ +/** + * font variant convertion map + * + * @type {Object} + */ +const fontVariantProperties = { + "font-variant-ligatures": { + "common-ligatures": "\"liga\", \"clig\"", + "no-common-ligatures": "\"liga\", \"clig off\"", + "discretionary-ligatures": "\"dlig\"", + "no-discretionary-ligatures": "\"dlig\" off", + "historical-ligatures": "\"hlig\"", + "no-historical-ligatures": "\"hlig\" off", + contextual: "\"calt\"", + "no-contextual": "\"calt\" off" + }, + + "font-variant-position": { + sub: "\"subs\"", + "super": "\"sups\"", + normal: "\"subs\" off, \"sups\" off" + }, + + "font-variant-caps": { + "small-caps": "\"smcp\"", + "all-small-caps": "\"smcp\", \"c2sc\"", + "petite-caps": "\"pcap\"", + "all-petite-caps": "\"pcap\", \"c2pc\"", + unicase: "\"unic\"", + "titling-caps": "\"titl\"" + }, + + "font-variant-numeric": { + "lining-nums": "\"lnum\"", + "oldstyle-nums": "\"onum\"", + "proportional-nums": "\"pnum\"", + "tabular-nums": "\"tnum\"", + "diagonal-fractions": "\"frac\"", + "stacked-fractions": "\"afrc\"", + ordinal: "\"ordn\"", + "slashed-zero": "\"zero\"" + }, + + "font-kerning": { + normal: "\"kern\"", + none: "\"kern\" off" + }, + + "font-variant": { + normal: "normal", + inherit: "inherit" + } +} + +// The `font-variant` property is a shorthand for all the others. +for (const prop in fontVariantProperties) { + const keys = fontVariantProperties[prop] + for (const key in keys) { + if (!(key in fontVariantProperties["font-variant"])) { + fontVariantProperties["font-variant"][key] = keys[key] + } + } +} + +// Find font-feature-settings declaration before given declaration, +// create if does not exist +function getFontFeatureSettingsPrevTo(decl) { + let fontFeatureSettings = null; + decl.parent.walkDecls((decl) => { + if (decl.prop === "font-feature-settings") { + fontFeatureSettings = decl; + } + }) + + if (fontFeatureSettings === null) { + fontFeatureSettings = decl.clone() + fontFeatureSettings.prop = "font-feature-settings" + fontFeatureSettings.value = "" + decl.parent.insertBefore(decl, fontFeatureSettings) + } + return fontFeatureSettings +} + +function walkRule(rule) { + let fontFeatureSettings = null + // read custom media queries + rule.walkDecls((decl) => { + if (!fontVariantProperties[decl.prop]) { + return null + } + + let newValue = decl.value + if (decl.prop === "font-variant") { + newValue = decl.value.split(/\s+/g).map((val) => { + return fontVariantProperties["font-variant"][val] + }).join(", ") + } + else if (fontVariantProperties[decl.prop][decl.value]) { + newValue = fontVariantProperties[decl.prop][decl.value] + } + + if (fontFeatureSettings === null) { + fontFeatureSettings = getFontFeatureSettingsPrevTo(decl); + } + if (fontFeatureSettings.value && fontFeatureSettings.value !== newValue) { + fontFeatureSettings.value += ", " + newValue; + } + else { + fontFeatureSettings.value = newValue; + } + }) +} + +/** + * Expose the font-variant plugin. + */ +module.exports = () => { + return { + postcssPlugin: "postcss-font-variant", + Once(root) { + root.walkRules(walkRule) + } + } +} + +module.exports.postcss = true diff --git a/node_modules/postcss-font-variant/package.json b/node_modules/postcss-font-variant/package.json new file mode 100644 index 00000000..39b74cb8 --- /dev/null +++ b/node_modules/postcss-font-variant/package.json @@ -0,0 +1,36 @@ +{ + "name": "postcss-font-variant", + "version": "5.0.0", + "description": "PostCSS plugin to transform W3C font-variant properties to more compatible CSS (font-feature-settings)", + "keywords": [ + "css", + "postcss", + "postcss-plugin", + "font", + "variant", + "font-variant" + ], + "author": "Maxime Thirouin", + "license": "MIT", + "repository": "https://github.com/postcss/postcss-font-variant.git", + "files": [ + "index.js" + ], + "peerDependencies": { + "postcss": "^8.1.0" + }, + "devDependencies": { + "jscs": "^3.0.7", + "jshint": "^2.9.6", + "npmpub": "^4.1.0", + "postcss": "^8.1.0", + "tape": "^5.0.0" + }, + "scripts": { + "lint": "npm run jscs && npm run jshint", + "jscs": "jscs index.js test/index.js", + "jshint": "jshint . --exclude-path .gitignore", + "test": "npm run lint && tape test", + "release": "npmpub" + } +} |
