Compare commits

...

14 Commits

Author SHA1 Message Date
Anton Smirnov a4165465ae Kinda fix highlighting (scss highlighting crashes) 2022-12-19 18:58:36 +02:00
Anton Smirnov fea1f58102 Ignore build dir 2022-12-19 18:57:57 +02:00
Anton Smirnov e584d9c2b6 Useless param 2022-06-23 06:52:17 +03:00
Anton Smirnov c59eca22d7 Importer needs some adaptation 2022-06-23 06:45:34 +03:00
Anton Smirnov 8d7dc75796 Upgrade mocha 2022-06-23 06:12:47 +03:00
Anton Smirnov 7374479bfd RGB definition 2022-06-23 06:07:59 +03:00
Anton Smirnov a22810fbc8 loadPaths is required 2022-06-23 06:05:31 +03:00
Anton Smirnov beea262e6f Convert tests to TypeScript 2022-06-23 06:02:02 +03:00
Anton Smirnov 2d92d1ec16 Rename to ts 2022-06-23 06:00:05 +03:00
Anton Smirnov 3991142c0d Fix project name 2022-06-02 01:56:30 +03:00
Anton Smirnov 8bc1b2c1d4 Use furo for docs 2022-06-02 01:55:14 +03:00
Anton Smirnov 09e16c7d1d Use scss fields in package.json 2021-08-30 09:13:07 +03:00
Anton Smirnov 35f3120776 formatting 2021-08-29 18:36:04 +03:00
Anton Smirnov 7832f53709 typo 2021-08-29 18:31:20 +03:00
22 changed files with 258 additions and 276 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ package-lock.json
# project specific
/demo.*
/docs/index.html
/docs/build

View File

@ -2,6 +2,7 @@
module.exports = {
spec: [
"tests/spec/**/*.js"
"tests/spec/**/*.spec.ts"
],
"require": "ts-node/register",
}

View File

@ -9,3 +9,4 @@
/tests
/.mocharc.js
/.gitlab-ci.yml
/tsconfig.json

View File

@ -4,7 +4,7 @@
*Aug 29, 2021*
* Added a way to bypass libsass incompatibilty
* Added a way to bypass libsass incompatibility
* Added tests
## 1.0.1

22
docs/_templates/sidebar/brand.html vendored Normal file
View File

@ -0,0 +1,22 @@
<a class="sidebar-brand{% if logo %} centered{% endif %}" href="{{ pathto(master_doc) }}">
{% block brand_content %}
{%- if logo_url %}
<div class="sidebar-logo-container">
<img class="sidebar-logo" src="{{ logo_url }}" alt="Logo"/>
</div>
{%- endif %}
{%- if theme_light_logo and theme_dark_logo %}
<div class="sidebar-logo-container">
<img class="sidebar-logo only-light" src="{{ pathto('_static/' + theme_light_logo, 1) }}" alt="Light Logo"/>
<img class="sidebar-logo only-dark" src="{{ pathto('_static/' + theme_dark_logo, 1) }}" alt="Dark Logo"/>
</div>
{%- endif %}
{% if not theme_sidebar_hide_name %}
<span class="sidebar-brand-text">{{ docstitle if docstitle else project }}</span>
{%- endif %}
{% endblock brand_content %}
</a>
{%- if current_version -%}
<div class="sidebar-brand">{{ current_version }}</div>
{%- endif -%}

10
docs/conf.py Normal file
View File

@ -0,0 +1,10 @@
from datetime import datetime
project = 'sass-hsv'
author = 'Anton Smirnov'
copyright = '{} {}'.format(datetime.now().year, author)
language = 'en'
html_title = project
html_theme = 'furo'
templates_path = ["_templates"]

View File

@ -17,7 +17,9 @@ Dart Sass
Just import the module:
.. code-block:: scss
.. don't ask why scilab, it just works
.. code-block:: scilab
// node-sass-package-importer path syntax, adjust for your favorite importer
@use "~sass-hsv" as *;
@ -39,10 +41,10 @@ Just import the module:
libsass
-------
The package is designed for `sass` / Dart Sass with modules but it has support of `node-sass` / `libsass`.
The package is designed for ``sass`` / Dart Sass with modules but it has support of ``node-sass`` / ``libsass``.
You need to import the legacy module explicitly:
.. code-block::
.. code-block:: scilab
// node-sass-package-importer path syntax, adjust for your favorite importer
@import "~sass-hsv/legacy"

1
docs/requirements.txt Normal file
View File

@ -0,0 +1 @@
furo

View File

@ -18,14 +18,19 @@
"email": "sandfox@sandfox.me",
"url": "https://sandfox.me/"
},
"sass": "_hsv.scss",
"scss": "_hsv.scss",
"main.scss": "_hsv.scss",
"scripts": {
"test": "mocha"
},
"devDependencies": {
"@types/chai": "^4.3.1",
"@types/mocha": "^9.1.1",
"@types/node-sass": "^4.11.2",
"chai": "^4.3.4",
"mocha": "^9.1.1",
"mocha": "^10.0.0",
"node-sass": "*",
"sass": "*"
"sass": "*",
"ts-node": "^10.8.1"
}
}

View File

@ -1,19 +1,22 @@
'use strict';
const sass = require('sass');
const packageImporter = require('node-sass-package-importer');
const packageImporter = require('node-sass-package-importer')();
const fs = require('fs');
const process = require('process');
const css = sass.renderSync({
file: 'test.scss',
outputStyle: 'compressed',
importer: packageImporter(),
const css = sass.compile('test.scss', {
style: 'compressed',
importers: [{
findFileUrl(url) {
return new URL('file://' + packageImporter(url).file)
}
}],
})
const data = fs.readFileSync('../test_result.css');
const data = fs.readFileSync('../test_result.css').toString();
if (Buffer.compare(css.css, data) !== 0) {
if (css.css !== data) {
console.log('css content is different');
console.log(`expected: "${data}"`);
console.log(`actual: "${css.css}"`);

View File

@ -1,7 +1,7 @@
{
"dependencies": {
"node-sass-package-importer": "^5.3.2",
"sass": "^1.38.2",
"sass": "^1.45.0",
"sass-hsv": "file:../../.."
}
}

View File

@ -1,72 +0,0 @@
'use strict';
const chai = require('chai');
const assert = chai.assert;
const sass = require('sass');
const fs = require('fs');
const expected = fs.readFileSync(__dirname + '/sass/aliases/expected.css').toString().trim();
const expectedAlpha = fs.readFileSync(__dirname + '/sass/aliases/expected-alpha.css').toString().trim();
describe('hsv()', function () {
it('works', function () {
const actual = sass.renderSync({
file: __dirname + '/sass/aliases/hsv-test.scss',
outputStyle: 'compressed',
}).css.toString().trim();
assert.equal(actual, expected);
});
});
describe('hsb()', function () {
it('works', function () {
const actual = sass.renderSync({
file: __dirname + '/sass/aliases/hsb.scss',
outputStyle: 'compressed',
}).css.toString().trim();
assert.equal(actual, expected);
});
});
describe('hsva()', function () {
it('works', function () {
const actual = sass.renderSync({
file: __dirname + '/sass/aliases/hsva.scss',
outputStyle: 'compressed',
}).css.toString().trim();
assert.equal(actual, expectedAlpha);
});
it('requires alpha param', function () {
assert.throws(function () {
sass.renderSync({
file: __dirname + '/sass/aliases/hsva-error.scss',
outputStyle: 'compressed',
});
});
});
});
describe('hsba()', function () {
it('works', function () {
const actual = sass.renderSync({
file: __dirname + '/sass/aliases/hsba.scss',
outputStyle: 'compressed',
}).css.toString().trim();
assert.equal(actual, expectedAlpha);
});
it('requires alpha param', function () {
assert.throws(function () {
sass.renderSync({
file: __dirname + '/sass/aliases/hsba-error.scss',
outputStyle: 'compressed',
});
});
});
});

View File

@ -0,0 +1,52 @@
import { assert } from 'chai';
import { compile } from 'sass';
import { readFileSync } from 'fs';
import { Options } from 'sass/types/options';
const expected = readFileSync(__dirname + '/sass/aliases/expected.css').toString().trim();
const expectedAlpha = readFileSync(__dirname + '/sass/aliases/expected-alpha.css').toString().trim();
const options: Options<'sync'> = {
style: 'compressed',
loadPaths: [__dirname + '/../..']
}
describe('hsv()', function () {
it('works', function () {
const actual = compile(__dirname + '/sass/aliases/hsv-test.scss', options).css.toString().trim();
assert.equal(actual, expected);
});
});
describe('hsb()', function () {
it('works', function () {
const actual = compile(__dirname + '/sass/aliases/hsb.scss', options).css.toString().trim();
assert.equal(actual, expected);
});
});
describe('hsva()', function () {
it('works', function () {
const actual = compile(__dirname + '/sass/aliases/hsva.scss', options).css.toString().trim();
assert.equal(actual, expectedAlpha);
});
it('requires alpha param', function () {
assert.throws(function () {
compile(__dirname + '/sass/aliases/hsva-error.scss', options);
});
});
});
describe('hsba()', function () {
it('works', function () {
const actual = compile(__dirname + '/sass/aliases/hsba.scss', options).css.toString().trim();
assert.equal(actual, expectedAlpha);
});
it('requires alpha param', function () {
assert.throws(function () {
compile(__dirname + '/sass/aliases/hsba-error.scss', options);
});
});
});

View File

@ -1,74 +0,0 @@
'use strict';
const chai = require('chai');
const assert = chai.assert;
const sass = require('sass');
const fs = require('fs');
const expected = fs.readFileSync(__dirname + '/sass/angles/expected.css').toString().trim();
describe('angle units', function () {
it('accepts unitless as degrees', function () {
const actual = sass.renderSync({
file: __dirname + '/sass/angles/unitless.scss',
outputStyle: 'compressed',
}).css.toString().trim();
assert.equal(actual, expected);
});
it('accepts degrees', function () {
const actual = sass.renderSync({
file: __dirname + '/sass/angles/deg.scss',
outputStyle: 'compressed',
}).css.toString().trim();
assert.equal(actual, expected);
});
it('accepts radians', function () {
const actual = sass.renderSync({
file: __dirname + '/sass/angles/rad.scss',
outputStyle: 'compressed',
}).css.toString().trim();
assert.equal(actual, expected);
});
it('accepts turns', function () {
const actual = sass.renderSync({
file: __dirname + '/sass/angles/turn.scss',
outputStyle: 'compressed',
}).css.toString().trim();
assert.equal(actual, expected);
});
it('accepts grads', function () {
const actual = sass.renderSync({
file: __dirname + '/sass/angles/grad.scss',
outputStyle: 'compressed',
}).css.toString().trim();
assert.equal(actual, expected);
});
it('does not allow incompatible units: %', function () {
assert.throws(function () {
sass.renderSync({
file: __dirname + '/sass/angles/percent.scss',
outputStyle: 'compressed',
});
});
});
it('does not allow incompatible units: pt', function () {
assert.throws(function () {
sass.renderSync({
file: __dirname + '/sass/angles/pt.scss',
outputStyle: 'compressed',
});
});
});
});

50
tests/spec/angles.spec.ts Normal file
View File

@ -0,0 +1,50 @@
import { assert } from 'chai';
import { compile } from 'sass';
import { readFileSync } from 'fs';
import { Options } from 'sass/types/options';
const expected = readFileSync(__dirname + '/sass/angles/expected.css').toString().trim();
const options: Options<'sync'> = {
style: 'compressed',
loadPaths: [__dirname + '/../..']
}
describe('angle units', function () {
it('accepts unitless as degrees', function () {
const actual = compile(__dirname + '/sass/angles/unitless.scss', options).css.toString().trim();
assert.equal(actual, expected);
});
it('accepts degrees', function () {
const actual = compile(__dirname + '/sass/angles/deg.scss', options).css.toString().trim();
assert.equal(actual, expected);
});
it('accepts radians', function () {
const actual = compile(__dirname + '/sass/angles/rad.scss', options).css.toString().trim();
assert.equal(actual, expected);
});
it('accepts turns', function () {
const actual = compile(__dirname + '/sass/angles/turn.scss', options).css.toString().trim();
assert.equal(actual, expected);
});
it('accepts grads', function () {
const actual = compile(__dirname + '/sass/angles/grad.scss', options).css.toString().trim();
assert.equal(actual, expected);
});
it('does not allow incompatible units: %', function () {
assert.throws(function () {
compile(__dirname + '/sass/angles/percent.scss', options);
});
});
it('does not allow incompatible units: pt', function () {
assert.throws(function () {
compile(__dirname + '/sass/angles/pt.scss', options);
});
});
});

View File

@ -1,47 +0,0 @@
'use strict';
const chai = require('chai');
const assert = chai.assert;
const sass = require('sass');
const fs = require('fs');
const expected = fs.readFileSync(__dirname + '/sass/frac/expected.css').toString().trim();
describe('fraction units', function () {
it('accepts unitless as fractions', function () {
const actual = sass.renderSync({
file: __dirname + '/sass/frac/fraction.scss',
outputStyle: 'compressed',
}).css.toString().trim();
assert.equal(actual, expected);
});
it('accepts percent', function () {
const actual = sass.renderSync({
file: __dirname + '/sass/frac/percent.scss',
outputStyle: 'compressed',
}).css.toString().trim();
assert.equal(actual, expected);
});
it('does not allow incompatible units: deg', function () {
assert.throws(function () {
sass.renderSync({
file: __dirname + '/sass/frac/deg.scss',
outputStyle: 'compressed',
});
});
});
it('does not allow incompatible units: pt', function () {
assert.throws(function () {
sass.renderSync({
file: __dirname + '/sass/frac/pt.scss',
outputStyle: 'compressed',
});
});
});
});

35
tests/spec/frac.spec.ts Normal file
View File

@ -0,0 +1,35 @@
import { assert } from 'chai';
import { compile } from 'sass';
import { readFileSync } from 'fs';
import { Options } from 'sass/types/options';
const expected = readFileSync(__dirname + '/sass/frac/expected.css').toString().trim();
const options: Options<'sync'> = {
style: 'compressed',
loadPaths: [__dirname + '/../..']
}
describe('fraction units', function () {
it('accepts unitless as fractions', function () {
const actual = compile(__dirname + '/sass/frac/fraction.scss', options).css.toString().trim();
assert.equal(actual, expected);
});
it('accepts percent', function () {
const actual = compile(__dirname + '/sass/frac/percent.scss', options).css.toString().trim();
assert.equal(actual, expected);
});
it('does not allow incompatible units: deg', function () {
assert.throws(function () {
compile(__dirname + '/sass/frac/deg.scss', options);
});
});
it('does not allow incompatible units: pt', function () {
assert.throws(function () {
compile(__dirname + '/sass/frac/pt.scss', options);
});
});
});

View File

@ -1,20 +0,0 @@
'use strict';
const chai = require('chai');
const assert = chai.assert;
const sass = require('sass');
const fs = require('fs');
describe('check all hue values with 10 degree step to verify all h1 branches', function () {
it('is valid', function () {
const actual = sass.renderSync({
file: __dirname + '/sass/hue/all-degrees.scss',
outputStyle: 'expanded',
}).css.toString().trim();
const expected = fs.readFileSync(__dirname + '/sass/hue/expected.css').toString().trim();
assert.equal(actual, expected);
});
});

15
tests/spec/hue.spec.ts Normal file
View File

@ -0,0 +1,15 @@
import { assert } from 'chai';
import { compile } from 'sass';
import { readFileSync } from 'fs';
describe('check all hue values with 10 degree step to verify all h1 branches', function () {
it('is valid', function () {
const actual = compile(__dirname + '/sass/hue/all-degrees.scss', {
style: 'expanded',
loadPaths: [__dirname + '/../..']
}).css.toString().trim();
const expected = readFileSync(__dirname + '/sass/hue/expected.css').toString().trim();
assert.equal(actual, expected);
});
});

View File

@ -1,19 +1,14 @@
'use strict';
const chai = require('chai');
const assert = chai.assert;
import { assert } from 'chai';
import { renderSync } from 'node-sass';
import { readFileSync } from 'fs';
describe('legacy libsass support' , function () {
it('works with node-sass', function () {
const sass = require('node-sass');
const fs = require('fs');
const actual = sass.renderSync({
const actual = renderSync({
file: __dirname + '/sass/node-sass/node-sass.scss',
outputStyle: 'compressed',
}).css;
const expected = fs.readFileSync(__dirname + '/sass/node-sass/expected.css');
const expected = readFileSync(__dirname + '/sass/node-sass/expected.css');
assert.equal(actual.toString(), expected.toString());
});

View File

@ -1,147 +1,147 @@
.h0 {
color: red;
color: rgb(255, 0, 0);
}
.h1 {
color: #ff2a00;
color: rgb(255, 42, 0);
}
.h2 {
color: #ff5400;
color: rgb(255, 84, 0);
}
.h3 {
color: #ff7f00;
color: rgb(255, 127, 0);
}
.h4 {
color: #ffaa00;
color: rgb(255, 170, 0);
}
.h5 {
color: #ffd400;
color: rgb(255, 212, 0);
}
.h6 {
color: yellow;
color: rgb(255, 255, 0);
}
.h7 {
color: #d4ff00;
color: rgb(212, 255, 0);
}
.h8 {
color: #aaff00;
color: rgb(170, 255, 0);
}
.h9 {
color: chartreuse;
color: rgb(127, 255, 0);
}
.h10 {
color: #54ff00;
color: rgb(84, 255, 0);
}
.h11 {
color: #2aff00;
color: rgb(42, 255, 0);
}
.h12 {
color: lime;
color: rgb(0, 255, 0);
}
.h13 {
color: #00ff2a;
color: rgb(0, 255, 42);
}
.h14 {
color: #00ff55;
color: rgb(0, 255, 85);
}
.h15 {
color: springgreen;
color: rgb(0, 255, 127);
}
.h16 {
color: #00ffa9;
color: rgb(0, 255, 169);
}
.h17 {
color: #00ffd4;
color: rgb(0, 255, 212);
}
.h18 {
color: aqua;
color: rgb(0, 255, 255);
}
.h19 {
color: #00d4ff;
color: rgb(0, 212, 255);
}
.h20 {
color: #00a9ff;
color: rgb(0, 169, 255);
}
.h21 {
color: #007fff;
color: rgb(0, 127, 255);
}
.h22 {
color: #0055ff;
color: rgb(0, 85, 255);
}
.h23 {
color: #002aff;
color: rgb(0, 42, 255);
}
.h24 {
color: blue;
color: rgb(0, 0, 255);
}
.h25 {
color: #2a00ff;
color: rgb(42, 0, 255);
}
.h26 {
color: #5400ff;
color: rgb(84, 0, 255);
}
.h27 {
color: #7f00ff;
color: rgb(127, 0, 255);
}
.h28 {
color: #aa00ff;
color: rgb(170, 0, 255);
}
.h29 {
color: #d400ff;
color: rgb(212, 0, 255);
}
.h30 {
color: fuchsia;
color: rgb(255, 0, 255);
}
.h31 {
color: #ff00d4;
color: rgb(255, 0, 212);
}
.h32 {
color: #ff00aa;
color: rgb(255, 0, 170);
}
.h33 {
color: #ff007f;
color: rgb(255, 0, 127);
}
.h34 {
color: #ff0054;
color: rgb(255, 0, 84);
}
.h35 {
color: #ff002a;
color: rgb(255, 0, 42);
}
.h36 {
color: red;
color: rgb(255, 0, 0);
}

2
tsconfig.json Normal file
View File

@ -0,0 +1,2 @@
{
}