mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #2824 from SomaticIT/add-stylus
Add stylus definitions
This commit is contained in:
@@ -357,6 +357,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [status-bar](https://github.com/atom/status-bar) (by [vvakame](https://github.com/vvakame))
|
||||
* [stripe](https://stripe.com/) (by [Eric J. Smith](https://github.com/ejsmith/))
|
||||
* [Store.js](https://github.com/marcuswestin/store.js/) (by [Vincent Bortone](https://github.com/vbortone))
|
||||
* [stylus](https://github.com/LearnBoost/stylus) (by [Maxime LUCE](https://github.com/SomaticIT))
|
||||
* [Sugar](http://sugarjs.com/) (by [Josh Baldwin](https://github.com/jbaldwin/))
|
||||
* [Swiper](http://www.idangero.us/sliders/swiper) (by [Sebastián Galiano](https://github.com/sgaliano))
|
||||
* [SwipeView](http://cubiq.org/swipeview) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* Test suite created by Maxime LUCE <https://github.com/SomaticIT>
|
||||
*
|
||||
* Created by using code samples from https://github.com/LearnBoost/stylus/blob/master/docs/js.md.
|
||||
*/
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
/// <reference path="stylus.d.ts" />
|
||||
|
||||
import stylus = require("stylus");
|
||||
|
||||
var str = "This is a stylus test";
|
||||
|
||||
/**
|
||||
* Basic Usage
|
||||
*/
|
||||
stylus.render(str, { filename: 'nesting.css' }, function(err, css){
|
||||
if (err) throw err;
|
||||
console.log(css);
|
||||
});
|
||||
|
||||
stylus(str)
|
||||
.set('filename', 'nesting.css')
|
||||
.render(function (err, css) {
|
||||
// logic
|
||||
});
|
||||
|
||||
/**
|
||||
* .set(setting, value)
|
||||
* https://github.com/LearnBoost/stylus/blob/master/docs/js.md#setsetting-value
|
||||
*/
|
||||
stylus(str)
|
||||
.set('filename', __dirname + '/test.styl')
|
||||
.set('paths', [__dirname, __dirname + '/mixins'])
|
||||
.render(function (err, css) {
|
||||
// logic
|
||||
});
|
||||
|
||||
/**
|
||||
* .include(path)
|
||||
* https://github.com/LearnBoost/stylus/blob/master/docs/js.md#includepath
|
||||
*/
|
||||
stylus(str)
|
||||
.include(require('nib').path)
|
||||
.include(process.env.HOME + '/mixins')
|
||||
.render(function (err, css) {
|
||||
// logic
|
||||
});
|
||||
|
||||
/**
|
||||
* .import(path)
|
||||
* https://github.com/LearnBoost/stylus/blob/master/docs/js.md#importpath
|
||||
*/
|
||||
stylus(str)
|
||||
.set('filename', __dirname + '/test.styl')
|
||||
.import('mixins/vendor')
|
||||
.render(function (err, css) {
|
||||
if (err) throw err;
|
||||
console.log(css);
|
||||
});
|
||||
|
||||
/**
|
||||
* .define(name, node|fn)
|
||||
* https://github.com/LearnBoost/stylus/blob/master/docs/js.md#definename-node
|
||||
*/
|
||||
stylus(str)
|
||||
.define('has-canvas', stylus.nodes.false)
|
||||
.define('some-setting', new stylus.nodes.String('some value'))
|
||||
|
||||
.define('string', 'some string')
|
||||
.define('number', 15.5)
|
||||
.define('some-bool', true)
|
||||
.define('list', [1, 2, 3])
|
||||
.define('list', [1, 2, [3, 4, [5, 6]]])
|
||||
.define('list', { foo: 'bar', bar: 'baz' })
|
||||
.define('families', ['Helvetica Neue', 'Helvetica', 'sans-serif'])
|
||||
|
||||
.define('get-list', function () {
|
||||
return ['foo', 'bar', 'baz'];
|
||||
})
|
||||
|
||||
.render(function (err, css) {
|
||||
if (err) throw err;
|
||||
console.log(css);
|
||||
});
|
||||
|
||||
/**
|
||||
* .use(fn)
|
||||
* https://github.com/LearnBoost/stylus/blob/master/docs/js.md#usefn
|
||||
*/
|
||||
var mylib = function (style: Stylus.Renderer) {
|
||||
style.define('number', 15.5);
|
||||
style.define('get-list', function () {
|
||||
return ['foo', 'bar', 'baz'];
|
||||
});
|
||||
};
|
||||
|
||||
stylus(str)
|
||||
.use(mylib)
|
||||
.render(function (err, css) {
|
||||
if (err) throw err;
|
||||
console.log(css);
|
||||
});
|
||||
Vendored
+1439
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user