diff --git a/.editorconfig b/.editorconfig index f71224a..5157391 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,4 @@ -# 本文件用于在不同的编辑器中统一代码风格 -# 请为你的编辑器安装 EditorConfig 插件 +# This file is for unifying the coding style for different editors and IDEs # editorconfig.org root = true @@ -10,17 +9,9 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true -[**.js] -indent_style = space -indent_size = 4 - -[**.styl] -indent_style = space +[*.{js,styl,html,json}] indent_size = 4 - -[**.html] indent_style = space -indent_size = 4 [*.md] trim_trailing_whitespace = false diff --git a/.fecsignore b/.fecsignore new file mode 100644 index 0000000..3235caf --- /dev/null +++ b/.fecsignore @@ -0,0 +1,2 @@ +test/** +demo/** diff --git a/.fecsrc b/.fecsrc new file mode 100644 index 0000000..78d9af3 --- /dev/null +++ b/.fecsrc @@ -0,0 +1,10 @@ +{ + "eslint": { + "env": { + "node": true + }, + "rules": { + "no-console": 0 + } + } +} diff --git a/.gitignore b/.gitignore index fba44de..eeda977 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -*.log +.idea/ node_modules/ .DS_Store demo/**/*.css +*.log diff --git a/.npmignore b/.npmignore index 5c05e59..4415c0a 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,3 @@ demo/ test/ +demo.js diff --git a/.travis.yml b/.travis.yml index 6e5919d..7ab627a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ language: node_js node_js: - "0.10" + - "0.12" diff --git a/History.md b/History.md index 333db60..954a3a2 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,28 @@ +2.0.0 / 2015-06-17 +================== + + * **Breaking Change** 改进 Function:`bg()`, `ir()` [#18](https://github.com/ecomfe/rider/issues/18) + * **Breaking Change** 改进 Root Mixin:`font-face()` [#16](https://github.com/ecomfe/rider/issues/16) [#24](https://github.com/ecomfe/rider/issues/24) + * **Breaking Change** 改进 Block Mixin:`+breakpoint()`,移除组合能力,迁出 retina 支持 [#19](https://github.com/ecomfe/rider/issues/19) + * **Breaking Change** 移除:retina 支持中的浏览器兼容代码 [#17](https://github.com/ecomfe/rider/issues/17) + * **Breaking Change** 移除 全局变量:`$-image-dppx`,retina 图片机制已更新 + * 增加 全局变量:`$-code-font-family` 作为代码段默认字体 + * 增加 全局变量:`$-image-dppx-range` 作为 retina 图片的探测范围 + * 增加 全局变量:`$-image-dppx-separator` 作为 retina 图片的分隔符 + * 增加 全局变量:`$-image-dppx-quality-first` 作为 retina 图片质量优先模式的开关 + * 增加 全局变量:`$-unit-precision` 作为单位转换的小数点精度控制 + * 增加 Function:`bg2x()`, `bg3x()`, `bg-dppx()` [#23](https://github.com/ecomfe/rider/issues/23) + * 增加 Function:`file-exists()`, `is-url()`, `get-retina-src()` [#15](https://github.com/ecomfe/rider/issues/15) + * 增加 Mixin:`normalize()` 作为布局初始化的补充 [#8](https://github.com/ecomfe/rider/issues/8) + * 增加 Mixin:`circle()` 生成圆形或椭圆 + * 增加 Block Mixin:`+retina()` [#20](https://github.com/ecomfe/rider/issues/20) + * 改进 Function:`rem()`, `em()`, `px()` 单位转换定义截取小数点位数 [#4](https://github.com/ecomfe/rider/issues/4) + * 改进 Mixin:`animate()` 升级至 animate.css 3.2.6 版 [#5](https://github.com/ecomfe/rider/issues/5) + * 改进:测试脚本启用 inline diff [#7](https://github.com/ecomfe/rider/issues/7) + * 改进:简化 demo 的支持部分 [#6](https://github.com/ecomfe/rider/issues/6) + * 改进:文档重新经过深入整理 [#21](https://github.com/ecomfe/rider/issues/21) + 0.4.4 / 2014-11-06 ================== diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9418541 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Baidu Inc. + +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/README.md b/README.md index 83ceeb0..7565028 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,35 @@ -rider [![NPM version](https://badge.fury.io/js/rider.png)](https://npmjs.org/package/rider) [![Build Status](https://travis-ci.org/ecomfe/rider.png)](https://travis-ci.org/ecomfe/rider) [![DevDependencies Status](https://david-dm.org/ecomfe/rider/dev-status.png)](https://david-dm.org/ecomfe/rider#info=devDependencies) +rider === -`rider` 是一个基于 [`stylus`](https://github.com/LearnBoost/stylus)、专注于 **移动 Web** 的 CSS 样式库。 +[![NPM version](https://img.shields.io/npm/v/rider.svg?style=flat-square)](https://npmjs.org/package/rider) [![Build Status](https://img.shields.io/travis/ecomfe/rider.svg?style=flat-square)](https://travis-ci.org/ecomfe/rider) [![License](https://img.shields.io/npm/l/rider.svg?style=flat-square)](./LICENSE) [![EFE Mobile Team](https://img.shields.io/badge/EFE-Mobile_Team-blue.svg?style=flat-square)](http://efe.baidu.com) -它提供了样式初始化、顺时针简写、缓动函数、图片、排版、单位转换、形状、动画、响应式工具等功能,可以让你的前端样式开发更轻松、更省心。 +`rider` 是基于 [Stylus](http://stylus-lang.com) 与后处理器、无侵入风格的 CSS 样式工具库。 -## 文档 +基于 `rider` 开发 **项目** 或 **UI 样式库**,能有效提高开发效率,延长代码生命周期。 -+ 安装与配置 - + [在 `edp` 环境使用](https://github.com/ecomfe/edp-provider-rider) - + [在 `connect`/`express` 环境使用](./doc/connect.md) -+ [API](./doc/api.md) -+ [代码风格](./doc/code-style.md) -+ [常见问题](./doc/faq.md) -+ [DEMO与单元测试](./doc/demo-and-ut.md) +## 功能 + + * [特性](./doc/feature.md) + * [样式初始化](./doc/initialize.md) + * [顺时针简写](./doc/clockhand.md) + * [缓动函数](./doc/easing.md) + * [图片](./doc/image.md) + * [排版](./doc/typography.md) + * [形状](./doc/shape.md) + * [动画](./doc/animate.md) + * [单位转换](./doc/unit.md) + * [响应式工具](./doc/breakpoint.md) + * [Retina 支持](./doc/retina.md) + * [辅助函数](./doc/helper.md) + +## 使用 + + * 安装与配置 + * [edp 环境](https://github.com/ecomfe/edp-provider-rider) + * [connect/express 环境](./doc/connect.md) + * [代码风格](./doc/code-style.md) + * [常见问题](./doc/faq.md) + +## License + +MIT © [Baidu Inc.](./LICENSE) diff --git a/demo.js b/demo.js new file mode 100644 index 0000000..d26813a --- /dev/null +++ b/demo.js @@ -0,0 +1,51 @@ +/** + * @file rider demo + * @author firede(firede@firede.us) + */ + +var path = require('path'); +var http = require('http'); + +var connect = require('connect'); +var serveStatic = require('serve-static'); + +var stylus = require('stylus'); +var rider = require('./lib/rider'); +var ap = require('autoprefixer-core'); + +var app = connect(); +var port = 8888; + +function compile(str, filePath) { + return stylus(str) + .set('filename', filePath) + .define('url', stylus.resolver()) + .use(rider()) + .on('end', prefixer); +} + +function prefixer(_, css) { + return ap( + { + browsers: [ + '> 5%', + 'iOS >= 6', + 'Android >= 2.3', + 'ExplorerMobile >= 10' + ] + } + ).process(css).css; +} + +app.use(stylus.middleware({ + src: path.join(__dirname, 'demo'), + compile: compile +})); + +app.use( + serveStatic(path.join(__dirname, 'demo')) +); + +http.createServer(app).listen(port, function () { + console.log('Rider demo started on port %d', port); +}); diff --git a/demo/animate.html b/demo/animate.html new file mode 100644 index 0000000..e69de29 diff --git a/demo/css/animate.styl b/demo/css/animate.styl new file mode 100644 index 0000000..62cceba --- /dev/null +++ b/demo/css/animate.styl @@ -0,0 +1,5 @@ +.test + animate('bounce') + +.abc + animate('bounce', 0.5s) diff --git a/demo/public/breakpoint.styl b/demo/css/breakpoint.styl similarity index 100% rename from demo/public/breakpoint.styl rename to demo/css/breakpoint.styl diff --git a/demo/public/easing.styl b/demo/css/easing.styl similarity index 100% rename from demo/public/easing.styl rename to demo/css/easing.styl diff --git a/demo/public/index.styl b/demo/css/index.styl similarity index 100% rename from demo/public/index.styl rename to demo/css/index.styl diff --git a/demo/public/initialize.styl b/demo/css/initialize.styl similarity index 100% rename from demo/public/initialize.styl rename to demo/css/initialize.styl diff --git a/demo/public/layout.styl b/demo/css/layout.styl similarity index 92% rename from demo/public/layout.styl rename to demo/css/layout.styl index 123d374..36dc202 100644 --- a/demo/public/layout.styl +++ b/demo/css/layout.styl @@ -2,7 +2,7 @@ initialize() // Fonts -font-face('rider-icon', 'font/rider-icon', '1') +font-face('rider-icon', '../font/rider-icon') [class^="icon-"], [class*=" icon-"] font-family: 'rider-icon' @@ -37,7 +37,7 @@ font-face('rider-icon', 'font/rider-icon', '1') font-size: rem(16) margin: 0 auto &.logo - ir: 'img/logo.png' + ir: '../img/logo.png' size: 75px 44px .next .prev diff --git a/demo/public/shape.styl b/demo/css/shape.styl similarity index 85% rename from demo/public/shape.styl rename to demo/css/shape.styl index 57c82fd..fd21b34 100644 --- a/demo/public/shape.styl +++ b/demo/css/shape.styl @@ -37,3 +37,10 @@ absolute: 15px -10px _ _ triangle: right 10px #939 +.circle-test-1 + circle: 60px 80px + background: #ccc + +.circle-test-2 + circle: 2rem + background: #ccc diff --git a/demo/views/easing.ejs b/demo/easing.html similarity index 98% rename from demo/views/easing.ejs rename to demo/easing.html index 24a2ccc..047c63e 100644 --- a/demo/views/easing.ejs +++ b/demo/easing.html @@ -4,7 +4,7 @@ - +