Code Monkey home page Code Monkey logo

cmui's Introduction

CMUI

CMUI is a UI framework for mobile web. It provides rich widgets and simple interfaces out-of-the-box, which helps developers get rid of details of styling and troubles of compatibility, and focus on building their own applications.

CMUI 是一个专攻移动网页的 UI 框架,它提供了丰富的组件和简洁的接口,开箱即用。CMUI 帮助开发者摆脱样式细节和兼容性困扰,从而腾出更多精力投入到业务开发中。

兼容性

浏览器支持

  • 支持以下移动平台的主流浏览器:

    • iOS 10+
    • Android 4.4+
  • 同样支持以下桌面浏览器:

    • Firefox (Latest)
    • Chrome (Latest)
    • Safari (Latest)

(更多细节参见 CMUI 的浏览器分级支持策略。)

外部依赖

  • Underscore 1.8+
  • Zepto 1.1+
  • Gearbox 0.7+

安装与使用

传统方式

  1. 通过 npm 3 安装:

    $ npm install cmui
  2. 在页面中加载 CMUI 的样式文件、脚本文件及必要的依赖:

    <!DOCTYPE html>
    <html>
    <head>
    	...
    	<link rel="stylesheet" href="node_modules/cmui/dist/cmui.css">
    </head>
    <body>
    	...
    	<script src="node_modules/underscore/underscore-min.js"></script>
    	<script src="node_modules/zepto.js/dist/zepto.min.js"></script>
    	<script src="node_modules/cmui-gearbox/dist/gearbox.min.js"></script>
    	<script src="node_modules/cmui/dist/cmui.js"></script>
    </body>
    </html>

通过 Stylus 加载

如果你的项目以 Stylus 作为 CSS 预处理器语言,则可以在你的源码中直接引入 CMUI 的样式入口文件:

@import './node_modules/cmui/src/css/theme/baixing/index'

在这种方式下,你可以在源码中使用 CMUI 提供的高级 API

  • 变量
  • Mixin

演示与文档

建议使用 iOS/Android 设备访问:CMUI Demo

cmui-demo

谁在用?

以下网站基于 CMUI 构建(请使用 iOS/Android 设备访问):


参与开发

功能模块

CMUI 的部分模块已经分离出去,成为独立项目。这些模块以开发依赖的方式引入,并打包到发布文件中。因此,参与这些独立项目的开发即可修改这些模块。

构建

  1. 把本项目的代码 fork 并 clone 到本地。
  2. 在项目根目录执行 npm install,安装必要的依赖。
  3. 在项目根目录执行 npm run dist,运行构建脚本。
  4. 构建生成的发布文件将存放在 /dist 目录下。

单元测试

  1. 把本项目的代码 fork 并 clone 到本地。
  2. 在项目根目录执行 npm install,安装必要的依赖。
  3. 在浏览器中打开以下文件即可运行单元测试:
    • test/test-dev.html - 测试源码(用于开发阶段的测试)

Thanks

CMUI is based on these open source projects:

CMUI team is using JetBrains IDE (WebStorm) with Open Source License:

  • WebStorm Logo

License

MIT License

cmui's People

Contributors

cssmagic avatar lyt9304 avatar myst729 avatar xuemengfei avatar zpbx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cmui's Issues

[BX Theme] `article > main` 布局似乎考虑过多了,反而限制了实际开发的便利性

article > main 默认设置了左右内边距,而如果其内容区块需要显示为全宽时,则需要调用 full-width-block() 这个 mixin——它的原理是通过水平方向上负外边距来突破 main 的内容区的。而这些内容区块自己可能也需要设置水平内边距,于是整个过程就变得相当折腾了。

article > main 指定默认的左右内边距是为了快速实现简单页面——直接写内容即可,内容不会贴到边。但实际开发中这种场景其实非常有限,几乎所有的页面都是经过充分美化的。

使用 clean-css 压缩 CSS 会导致 Firefox 下样式异常

问题

目前在使用 CSS 代码压缩工具是 clean-css,使用方便,压缩率高。

但存在一个问题,它默认会把所有 rgba(*,*,*,0) 转换成 transparent。而(我估计)在 Firefox 内核中 transparent 是直接绑定了 rgba(0,0,0,0) 的,那么在发生颜色插值运算的场景下(transition、gradient、不同边框色的斜边交界等),Firefox 在计算中间色调时会出现问题,观感上表现为半透明的黑色乱入。

对 CMUI 的样式来说,这个问题会影响到按钮和列表等元素的渐变背景等。

解决方案

在使用 clean-css 压缩 CSS 代码时,增加 -c * 参数,强制关闭这种透明色转换行为。

$ cleancss -o cmui.min.css --s1 -d -c * cmui.css

Implement building tasks based on Gulp/Grunt

建立基于 Gulp/Grunt 的构建过程

我在开发时是用我本地的一个 Shell 脚本(批处理)来做 dist 文件的合并、压缩的。由于这只是个临时方案,我并没有把这个脚本提交到代码库。其它开发者在参与开发时,需要各自处理构建问题,一来不方便,二来构建结果不统一。

未来需要把这个构建过程规范化,把它建立在通用的工具链之上。方案可能是 Gulp 或 Grunt,至少需要完成以下基本的构建任务:

  • 源码合并
  • 源码压缩

路径问题

路径都是下面这样的,如果整个项目不是托管在根目录下就会404,在local预览也404

C:\Users\IBM_ADMIN\Desktop\CMUI-master\dist\cmui.css (8 hits)
    Line 328:   background: url(/src/img/ui-loading-32x32-white-black.gif) no-repeat center center;
    Line 332:   background: url(/src/img/ui-loading-32x32-black-white.gif) no-repeat center center;
    Line 513:   background: url(/src/img/ui-loading-48x48-white-black.gif) no-repeat center center;
    Line 517:   background: url(/src/img/ui-loading-48x48-black-white.gif) no-repeat center center;
    Line 695:   background: url(/src/img/ui-loading-32x32-white-black.gif) no-repeat center center;
    Line 698:   background: url(/src/img/ui-loading-32x32-black-white.gif) no-repeat center center;

Underscore 升级到 1.7 之后,Loading 组件不能正常工作

主要原因是 _.union() API 的行为有变化。以下代码在 1.6- 和 1.7 中的结果不同:

_.union([1], 2)

必须写成以下方式才能得到预期结果:

_.union([1], [2])

除此以外,Underscore 1.7 的很多 API 行为都有变化。

API 变得更严格我很理解并赞同,但 API 行为变化之后大版本号并没有变,感觉很不爽,险些中招啊。Lo-dash 嘲讽 Underscore 不支持 semver 果然是有道理的。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.