Code Monkey home page Code Monkey logo

regular-ui's Introduction

Regular UI

Regular UI is a set of front-end components built with RegularJS.

To get started, check out http://regular-ui.github.io!

NPM Version Bower Version

Dependency Status devDependency Status

Quick Start

Following options to get Regular UI:

  • Download the latest release
  • Install with bower: bower install regular-ui
  • Install with npm: npm install regular-ui

You can find the compiled Regular UI distribution in Bower Repo.

Docs

All documentations are generated in the directory of ./doc by Gulp. You can read them on GitHub Page conveniently or download them to local.

Browser Support

Chrome Firefox IE Safari Opera
Latest ✔ Latest ✔ IE8+ Latest ✔ Latest ✔

Develop

First of all, clone the code.

git clone [email protected]:regular-ui/regular-ui.git

Install project dependencies.

cd regular-ui
npm install

If you don't have used Gulp before, you need to install the gulp package as a global install.

npm install gulp -g

Now, you can start to develop.

Run gulp to watch and compile source files for developing anytime they are modified.

Run gulp all to prepare CSS and JS index files include all components based on ./structure.js.

Run gulp customize to prepare CSS and JS index files include partial components based on ./structure.customized.js.

Run gulp dist to compile a distribution to ./dist directory.

Run gulp bower to compile a distribution to ./dist directory and sync to Bower Repo.

Run gulp doc to rebuild docs without watching.

Run gulp page to rebuild docs and sync to GitHub Page Repo.

Run npm test to start karma for testing cases.

Structure

I'm lazy to translate...

regular-ui根目录

regular-ui-bower
|— css                    # css文件
|— fonts                  # 字体,Regular UI使用FontAwesome
|— js                     # js文件,整合的单入口文件
|— mcss                   # mcss文件
|— scss                   # scss文件
|— vendor                 # 第三方库
|-- bower.json             # bower配置文件
|-- README.md              # 说明文件

regular-ui/src目录

regular-ui
|— src                    # 组件的开发源代码
    |— js                 # 组件的js源代码
        |— base           # 基础组件和辅助类库
        |— module         # js模块类
        |— unit           # js元件类
        |— util           # js辅助类
        |-- index.js       # js引导文件
    |— mcss               # 组件的mcss源代码
        |— bootstrap      # Bootstrap主题
        |— core           # 主题内核
        |— default        # Default主题
        |— flat           # Flat主题
        |— simple         # Simple主题
        |-- bootstrap.mcss # Bootstrap主题引导文件
        |-- default.mcss   # Default主题引导文件
        |-- flat.mcss      # Flat主题引导文件
        |-- simple.mcss    # Simple主题引导文件

regular-ui/doc-src目录

regular-ui
|— doc-src                # 文档构建目录
    |— assets             # 静态资源,里面的内容会直接复制到doc目录下
    |— mcss               # doc的mcss源代码
    |— view               # 文档页面的模板和内容
        |— common         # 文档页面的头部、侧边栏、API等公共部分模板,ejs文件
        |— cssModule      # css模块的内容,markdown文件
        |— cssUnit        # css元件的内容,markdown文件
        |— jsModule       # js元件的内容,markdown文件
        |— jsUnit         # js元件的内容,markdown文件
        |— start          # 开始使用的内容,markdown文件
        |-- index.md       # 首页内容
    |— build.js           # 根据路径构建单个文档
    |— buildAll.js        # 构建全部文档
    |— cssdoc.js          # 暂无
    |— jsdoc.js           # 由组件js源代码的注释块生成文档API
    |— premark.js         # 将markdown中的代码段自动添加到页面中创建出活生生的例子
    |— sitemap.json       # 网站地图

Referenced Websites

Netease

Based on jQuery

Based on AngularJS

Based on React

Based on Web Component

Others

Versioning

Regular UI is maintained by using the Semantic Versioning Specification (SemVer).

Contributing

See the contributing guidelines for details.

Copyright and License

Code released under the MIT license.


regular-ui's People

Contributors

rainfore 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

regular-ui's Issues

如何在组件中引入regular-ui进行使用?

我所看到的大部分demo引入一个regular-ui组件后需要inject到一个dom上面去,如果在自己的组件中想使用regular-ui中的某个组件该如何实现呢?
我尝试过下面的方法,感觉这样写很怪

程序入口文件
var Regular = require('regular');
var restate = require('./vendor/restate');
var App = require('./module/app/app');
var Page = require('./module/page');
var stateman = restate({
  view: document.getElementById('app'),
  Component: Regular
});
stateman
  .state('app', App, '')
  .state('app.a', Page)
 
  .on('notfound', function () {
    this.go('app.a', {replace: true});
  });

stateman.start({root: '/', prefix: '!'});
Page.js

var Regular = require('regular');
var RGUI = require('regular-ui');
var Tpl = require('./page.rgl');
var Dom = Regular.dom;
module.exports = Regular.extend({
  template: Tpl,
  init: function () {
  //下面是我所尝试的方法,感觉不是很合理
		var self = this;
		 new RGUI.Calendar().$inject(Dom.element(self).find('#renderRGUI'));

  }
});
page.rgl

<div>
this is page
<div id="renderRGUI"></div>
<calendar />//此处想使用regular-ui中的calendar组件
</div>

App.js

var Regular = require('regular');
var Tpl = require('./app.rgl');
module.exports = Regular.extend({
  template: Tpl,
  init: function () {
  }
});
app.rgl

<div class="">
    <div ref=view class="main"></div>
</div>

如何扩展input2,给它加过滤器?

这是我的demo

模板:

<input2 value={a|number} />

数据:

{
    a: 1
}

加的过滤器是这样的:

Regular.filter({
        number: {
            get: function(){

                return 123;
            },
            set: function(value){

                //console.log(this.data);

                return +value;
            }
        }
    });

它是一开始有进get方法,但当值修改时,有进get方法,但return并没有什么卵用?像如果是input的话,get返回一个固定值,是修改不了的。

之所以是要基于它做扩展,是因为它有一个validate比较好用。

不用NumberInput的原因是它只纯粹地是数字,不支持小数点。

或者有什么更合适的方式吗?

IE8 拖拽代理元素位置飘的很远

dragdrop.proxy.style.left = dragdrop.proxy.offsetLeft + dragdrop.movementX + 'px';
dragdrop.proxy.style.top = dragdrop.proxy.offsetTop + dragdrop.movementY + 'px';

//offsetLeft、offsetTop是不是有兼容性问题

Select2无法支持外部传入disabled

api里面提及的

data.disabled 只能outer到inner

无法双向,导致在创建select2后,我想动态改变select的disable就比较麻烦。

我一开始的想法是让结构里面的ui,或者div,直接disabled。

但这样和之前的效果有差异。如果重新创建组件,个人感觉不是太合理。

有什么解决的方案吗?

自定义样式表

想在各个组件的scss基础上做修改样式,然后编译成类似flat之类的一套样式表,来适应自己的网页风格,
可是编译的时候会有这样一个问题
很多 include的mixin都没有定义过,全局搜索也搜不到,这个是什么原因呀

ie8下有兼容性问题

Object.keys 的使用在ie8下不兼容,导致产品页面挂掉,请于2015.11.19前修复,并检查其他的兼容性问题,谢谢~

Suggest数据量大时,有性能问题

{#list source as item}
    {#if this.filter(item)}
        <li z-dis={item.disabled} z-divider={item.divider} title={item.name} on-click={this.select(item)}>{#if @(itemTemplate)}{#inc @(itemTemplate)}{#else}{item.name}{/if}</li>
    {/if}
{/list}

suggest用这种过滤结果的方式,当source长度到4,5K的时候,整个页面都卡住了;希望优化下

依赖的 reqwest 报错

只是 require 了 regular-ui,并没有实例化组件,就报这个错(实例化了依然报错),报错信息如下:

regular-ui.js:1171 Uncaught TypeError: Cannot use 'in' operator to search for 'window' in undefined
    at regular-ui.js:1171
    at context (regular-ui.js:1164)
    at Object.<anonymous> (regular-ui.js:1167)
    at __webpack_require__ (regular-ui.js:30)
    at Object.<anonymous> (regular-ui.js:1079)
    at __webpack_require__ (regular-ui.js:30)
    at Object.module.exports (regular-ui.js:70)
    at __webpack_require__ (regular-ui.js:30)
    at regular-ui.js:50
    at regular-ui.js:51

报错代码如下:

	!function (name, context, definition) {
	  if (typeof module != 'undefined' && module.exports) module.exports = definition()
	  else if (true) !(__WEBPACK_AMD_DEFINE_FACTORY__ = (definition), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))
	  else context[name] = definition()
	}('reqwest', this, function () {

	  var context = this

	  if ('window' in context) {     // 报错
	    var doc = document
	      , byTag = 'getElementsByTagName'
	      , head = doc[byTag]('head')[0]
	  } else {
	    var XHR2
	    try {
	      XHR2 = __webpack_require__(11)
	    } catch (ex) {
	      throw new Error('Peer dependency `xhr2` required! Please npm install xhr2')
	    }
	  }
     // ....

}

regular 和 regular-ui 都是最新版,浏览器 chrome 最新版。

ajax依赖reqwest的问题

我个人觉得regular-ui是不应该把reqwest这一块给打包进去的。

理由:

1.项目中可能会自定义reqwest的一些方法,这样一来,导致regular-ui里面的请求和外部的请求就有区别了。
2.目前的Regular.ajax不支持then方法,且不支持同步请求(这个是因为reqwest本身的原因)。

可以考虑将require去掉,外部依赖reqwest.js文件。

多dropdown组件的时候,不能正常关闭非点击下拉菜单bug

regular ui 源码 dropdown.js 部分 code:

// 处理点击dropdown之外的地方后的收起事件。
Dropdown.opens = [];

_.dom.on(document, 'click', function(e) {
    Dropdown.opens.forEach(function(dropdown, index) {
        // 这个地方不能用stopPropagation来处理,因为展开一个dropdown的同时要收起其他dropdown
        var element = dropdown.$refs.element;
        var element2 = e.target;
        while(element2) {
            if(element == element2)
                return;
            element2 = element2.parentElement;
        }
        dropdown.toggle(false);
        dropdown.$update();
    });
});

在document上绑定监听事件,forEach循环遍历Dropdown.opens数组,如果不是点击节点的父组件,就toggle(false)

regular ui 源码 dropdown.js 部分 toggle code:

    //  ......
   
  // 根据状态在Dropdown.opens列表中添加/删除管理项
        var index = Dropdown.opens.indexOf(this);
        if(open && index < 0)
            Dropdown.opens.push(this);
        else if(!open && index >= 0)
            Dropdown.opens.splice(index, 1);

在toggle函数里,动态splice一个节点,在Dropdown.opens.forEach遍历事件的时候,就会因为Dropdown.opens数组的改变,少遍历很多节点。少遍历的节点无法关闭下拉框。

仓库命名规范?

比如我提供的并不是一个组件,而是一套指令或事件(独立的)。 该如何命名?

Suggest组件中value作用域的疑问

我想在Suggests组件onchange的时候,对value作处理再显示,组件定义如下:

<suggest source={options.channels} on-select={this.selectChannel($event)} value={valuevalue}/>

事件函数如下:

selectChannel($event) {
       ...

        this.data.valuevalue = '';
        ...
    }

但结果this.data.valuevalue = '';只会在第一次调用的时候reset成功是为什么?
这个问题有点类似与Anuglar1.x的一个坑,就是子$scope会隐性创建上级$scope的同名model导致赋值失效,但这个坑可以通过传递引用类型model来绕过,但这种方法在regular下不管用。
求解决方案

模态框modal

一、模态框弹出后,确认按钮默认是:focus状态,也就是在取人按钮上自动获取焦点了
二、模态框没有提供遮罩这方面的API

regular-ui 配合 webpack 打包时无法使用

测试项目地址:[email protected]:lleobox/demo.git

测试环境:

win7 64位
node 版本 6.3.0
npm 版本 3.10.3
webpack 版本 1.31.1

regularjs、regular-ui 均为最新版

表现问题

通过 RGUI.Component.extend 创建的组件无法识别

index.js

var RGUI = require('regular-ui');

var DragabledItem = RGUI.Component.extend({
    name: 'dragabledItem',
    template: '<draggable data="{item}"><li class="u-color-{item.color}">{item.title}</li></draggable>',
});
<!-- 运行结果  #-->
<!-- 渲染后组件不识别 -->
<dragableditem item="[object Object]" class="anLocaApply"></dragableditem>

modal 组件写法,不支持r-animation=" on:enter;......."

    init: function () {
            this.supr();
            //必须异步,动画enter 必须等组件编译周期结束
            setTimeout(function(){
                if (this.$root === this)
                    this.$inject(document.body);
            }._$bind(this),0)

        },

============= 下面是Regular Animation动画源码,注意env.isRunning参数的判断=============

animate.startClassAnimate = function ( node, className,  callback, mode ){  
  var activeClassName, timeout, tid, onceAnim;
  if( (!animationEnd && !transitionEnd) || env.isRunning ){
    return callback();
  }
。。。。。。
}

支持2个月的calendar

目前的组件只支持一个月,对于跨月的范围选择很不方便,希望后面推出支持跨月范围的组件支持。比如1月15号到2月10号

关于浏览器兼容性

测试了一下,IE8模式下,有问题,Object.defineProperty会报错。。

然后想了解一下,能否支持到IE6 7?

想知道listView的动态模板中的this指向的是?

我尝试在itemTemple 这样中添加事件

template

<listView source={source} itemTemplate={@(this.itemTemplate)} />
itemTemplate

<div>
    <span class="number">{item_index + 1}.</span>
    <span class="title">{item.name}</span>
    <span class="hits f-fr" on-click="{this.doClick()}">{item.hits}</span>
</div>
page.js

var component = new RGUI.Component({
    template: template,
    itemTemplate: itemTemplate,
    data: {
        source: [
            {name: '精通Javascript开发', org: '前端Funs', hits: 42371},
            {name: 'Android深入浅出', org: 'Android学院', hits: 30645},
            {name: 'cocos2dx游戏开发教程', org: '鱼C课程', hits: 25112},
            {name: 'MySQL数据库', org: 'LAMP兄弟连', hits: 18089},
            {name: 'Arduino初级教程', org: '硬件社', hits: 16361}
        ]
    },
    doClick: function() {
    
    }

});

这里的doClick好像调用不到的

datePicker的date不能为空吗?

手动更新datePicker组件的date属性为空字符串,就会报错。

我个人觉得这不应该报错的。当它为空的时候,input的value就应该为空。

当date为非法日期的时候,这个时候报错才是正常的。

selectgroup初始化的时候为什么不会触发事件

我不设置placeholder 默认选中第一个,但是事件没有触发,有问题。
在 select1 this.$watch('selected') 触发change 事件,这个正常调用selectGroup 的_onchage 在onchange 里面触发了 select。 但是在组件的init 里面定义的时间回调没反应。
是不是组件在未完全完成的状态下,组件事件是不是不能触发.

而且我发现不设置 placeholder 的时候,会先触发子组件 select1 的 $watch('value') 再触发 $watch('source'). 设置了placeholder就不会先触发 $watch(‘value’);

不设置placeholder select 事件里面打印出来的值很有问题

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.