npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

colorpicker-uex

v1.0.9

Published

a color picker like that in ms office 2013

Downloads

5

Readme

color-picker

More Version of README

English Version

项目主页

点击这里查看 demo

UI

color-picker-snap

特点

  1. 简单易用,UI 和 Microsoft Word 2013 的拾色器一样;
  2. 增加了「最近使用」的功能;
  3. 在支持 html5 input[type='color'] 的浏览器实现了「更多颜色」的功能
  4. 支持多语言, 目前支持: 简体中文(默认)[zh-cn], 英语美国[en-us]

获取

你可以直接下载 dist 目录里的 css 和 js 使用,比较快捷的方式是直接安装 bower 包:先安装 bower,然后运行 bower install color-picker

用法

color-picker 基于 angular,

用法示例:

<link rel="stylesheet" href="path/to/color-picker.min.css">

<script src="path/to/angular.js"></script>
<script src="path/to/color-picker.min.js"></script>

<!-- directive 的方式 -->
<font-color></font-color>

<!-- controller 的方式 -->
<div ng-controller="demoCtrl">
    <div color-picker set-color="dynamicSetColor()" class="font-color" ng-style="{'background-color': selectedForeColor}"></div>
</div>

<script>
    var myApp = angular.module('colorpickerDemo', ['ui.colorpicker']);

    // directive 的方式
    myApp.directive('fontColor', function() {
         return {
             restrict: 'E',
             scope:{},
             replace: false,
             template: '<div color-picker default-color="#ff0000" class="font-color" ng-style="{\'background-color\': selectedFontColor}"></div>',
             link: function(scope) {
                 scope.selectedFontColor = '#f00';

                 scope.$on('colorPicked', function(event, color) {
                     scope.selectedFontColor = color;
                 });
             }
         }
    })


    // controller 的方式
    myApp.controller('demoCtrl', function($scope) {
         $scope.selectedForeColor = dynamicSetColor();

         $scope.$on('colorPicked', function(event, color) {
             $scope.selectedForeColor = color;
         });

         // 动态设置默认颜色
         $scope.dynamicSetColor = dynamicSetColor;

         function dynamicSetColor() {
             return '#0f0';
         }

     });

</script>

配置

默认语言为简体中文(zh-cn), 目前还提供英语美国(en-us)的配置选项你可以通过如下方法配置默认语言:

angular.module('colorpickerDemo', ['ui.colorpicker'])
    .config(function (localizeProvider) {
        localizeProvider.setDefaultLang('en-us');
    })

语言文件源文件在 src/lang.service.js 里面, 欢迎提供更多语言的版本, 提 Pull Request 即可.

选项

你可以通过在所在的元素上设置以下属性来配置 color-picker

  • default-color: 默认的颜色,如 default-color="#ff0000"
  • disabled: 是否可用,如 disabled="disabled"
  • set-color: 动态设置默认颜色函数,以达到不同的上下文环境具有不同的默认颜色。 如 set-color="dynamicSet()",则 dynamicSet 函数是可以根据上下文而设置的颜色。

事件

colorPicked -- 在用户选择了颜色的时候触发,在 color-picker 的父 scope 里面都可以监听到,带有一个参数 color (用户选择的颜色值)