Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
niksy committed Sep 2, 2021
0 parents commit bf8f5b5
Show file tree
Hide file tree
Showing 18 changed files with 996 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

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

[package.json]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
29 changes: 29 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"root": true,
"extends": [
"eslint-config-niksy",
"eslint-config-niksy/next",
"eslint-config-prettier"
],
"plugins": ["eslint-plugin-prettier"],
"rules": {
"prettier/prettier": 1
},
"overrides": [
{
"files": ["rollup.config.js"],
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"sourceType": "script"
},
"plugins": ["eslint-plugin-unicorn"],
"rules": {
"no-console": 0,
"unicorn/numeric-separators-style": 0
}
}
]
}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
node_modules/
package-lock.json
yarn.lock
npm-debug.log
cjs/
esm/
!test/fixtures/node_modules/
5 changes: 5 additions & 0 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"hooks": {
"pre-commit": "lint-staged"
}
}
5 changes: 5 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"*.js": ["eslint --fix"],
"*.(md|json)": ["prettier --ignore-path .gitignore --write"],
".!(npm)*rc": ["prettier --ignore-path .gitignore --parser json --write"]
}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
29 changes: 29 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"printWidth": 80,
"tabWidth": 4,
"useTabs": true,
"semi": true,
"singleQuote": true,
"quoteProps": "preserve",
"jsxSingleQuote": true,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "always",
"requirePragma": false,
"insertPragma": false,
"proseWrap": "always",
"htmlWhitespaceSensitivity": "css",
"vueIndentScriptAndStyle": false,
"endOfLine": "lf",
"embeddedLanguageFormatting": "auto",
"overrides": [
{
"files": "package.json",
"options": {
"useTabs": false,
"tabWidth": 2
}
}
]
}
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- '10'
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

## [Unreleased][]

### Added

- Initial implementation
18 changes: 18 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Copyright (c) Ivan Nikolić <http://ivannikolic.com>

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.
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# css-functions-list

[![Build Status][ci-img]][ci]

List of standard and
[browser specific](<(https://developer.mozilla.org/en-US/docs/Glossary/Vendor_Prefix)>)
CSS functions.

Source of data is MDN reference on
[CSS functions](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Functions)
and
[general CSS features](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference).

## Install

```sh
npm install css-functions-list --save
```

## Usage

```js
import { promises as fs } from 'fs';
import functionsListPath from 'css-functions-list';

(async () => {
const functionsList = JSON.parse(
await fs.readFile(functionsListPath, 'utf8')
);
console.log(functionsList);
/* [
'abs',
'acos',
'annotation',
'asin',
'atan',
'atan2',
'attr',
'blur',
'brightness',
'calc'
// …
]; */
})();
```

## API

### functionsListPath

Type: `string`

Path to CSS functions list JSON file.

## License

MIT © [Ivan Nikolić](http://ivannikolic.com)

<!-- prettier-ignore-start -->

[ci]: https://travis-ci.com/niksy/css-functions-list
[ci-img]: https://travis-ci.com/niksy/css-functions-list.svg?branch=master

<!-- prettier-ignore-end -->
62 changes: 62 additions & 0 deletions generate-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import path from 'path';
import fetch from 'isomorphic-unfetch';
import { JSDOM } from 'jsdom';
import writeJsonFile from 'write-json-file';

const references = [
{
url: 'https://developer.mozilla.org/en-US/docs/Glossary/Vendor_Prefix',
transform: (document) => {
let list = document.querySelectorAll('#css_prefixes + div li code');
list = [...list].map((node) => node.textContent);
return list;
}
},
{
url: 'https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Functions',
transform: (document) => {
let list = document.querySelectorAll('.main-page-content dt code');
list = [...list]
.map((node) => node.textContent)
.map((name) => name.replace('()', ''));
return list;
}
},
{
url: 'https://developer.mozilla.org/en-US/docs/Web/CSS/Reference',
transform: (document) => {
let list = document.querySelectorAll('#index + div .index li code');
list = [...list]
.map((node) => node.textContent)
.filter((name) => /^[^:]\S+\(\)$/.test(name))
.map((name) => name.replace('()', ''));
return list;
}
}
];

async function main() {
const responses = await Promise.all(
references.map(({ url }) => fetch(url))
);
const markups = await Promise.all(
responses.map((response) => response.text())
);
const [prefixes, ...functions] = markups.map((markup, index) => {
const {
window: { document }
} = new JSDOM(markup);
return references[index].transform(document);
});
let results = [...new Set([].concat(...functions))].sort();
results = [
...results,
...prefixes.map((prefix) => results.map((name) => `${prefix}${name}`))
];
results = [].concat(...results);
const filename = new URL('index.json', import.meta.url).pathname;
await writeJsonFile(filename, results);
console.log('Done!');
}

main();
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const location = new URL('index.json', import.meta.url).pathname;

export default location;
Loading

0 comments on commit bf8f5b5

Please sign in to comment.