承接 tractorcow/silverstripe-colorpicker 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tractorcow/silverstripe-colorpicker

Composer 安装命令:

composer require tractorcow/silverstripe-colorpicker

包简介

Color picker field for Silverstripe CMS using the ColorPicker jQuery plugin

README 文档

README

The ColorPicker Module adds a color-picker input field to the SilverStripe CMS. It makes use of the ColorPicker jQuery Plugin.

Requirements

SilverStripe Framework v4+, v5+, & v6+

For a Version that is compatible to SilverStripe 3+, consider using the 3.0 release For a Version that is compatible to SilverStripe 5+, consider using the 4.0 release

Installation

Install using composer

composer require tractorcow/silverstripe-colorpicker

Usage

Here's how you define a DB field to be a color:

private static $db = [
    'BgColor' => 'Color'
];

Alternatively, you can also use the fully qualified classname. The best way to do this is to import the class at the top of your PHP file, like so:

use TractorCow\Colorpicker\Color;
use TractorCow\Colorpicker\Forms\ColorField;

In your class, you can then use:

private static $db = [
    'BgColor' => Color::class
];

That's all... scaffolding will take care of creating the appropriate form-field.

If you use getCMSFields to create your fields yourself, you might want to do something like this:

public function getCMSFields()
{
    $fields = parent::getCMSFields();

    $fields->addFieldToTab(
    	'Root.Main',
    	ColorField::create('BgColor', 'Background color')
    );

    return $fields;
}

Tips for using the Color fieldtype in templates

The TractorCow\Colorpicker\Color fieldtype provides some helper methods that can be useful in templating. Let's consider the above scenario where you have a Field named 'BgColor'. The most common use-case is something like this:

<body style="background-color: #$BgColor;">
...

But there's more. You could also use CSS3 rgba color definitions with alpha. Example:

<body style="background-color: #$BgColor; background-color: $BgColor.CSSColor(0.5);">
...

This will color your background with an alpha value of 0.5 (browsers that don't support rgba, such as IE-8 will fall back to the first background-color definition, that's why it's still in there).

Here's a complete list of the Color methods available in templates:

  • Red returns the red color component
  • Green returns the green color component
  • Blue returns the blue color component
  • CSSColor returns the color as rgba. The alpha value can be specified with the (optional) argument.
  • Luminance the luminance of the color as a floating-point value ranging from 0-1
  • Blend blends the color with a second background color (defaults to #FFFFFF) with the given opacity. $BGColor.Blend(0.5, '#000000') will give the color 50% opacity and put it on top of a black background.
  • AlteredColorHSV modifies the current color by the given HSV values. These values are offsets, so you could do something like this: $BgColor.AlteredColorHSV(0.5, 0, 0) which will return the color with the opposite hue. All parameters are percentage based and range from 0 - 1. So doing: $BgColor.AlteredColorHSV(0, 0, -0.2) will result in a color with 20% less brightness (absolute, not relative).
  • ColorCMS returns HTML code with a visual representation and the HEX code of the color for usage in CMS. Can be used in $summary_fields of a DataObject: $summary_fields = [ 'Color.ColorCMS' => 'Color' ]; so that GridFields will always render the visible color instead of only the HEX code.

tractorcow/silverstripe-colorpicker 适用场景与选型建议

tractorcow/silverstripe-colorpicker 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 266.29k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2013 年 05 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「color」 「silverstripe」 「colorpicker」 「colour」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 tractorcow/silverstripe-colorpicker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tractorcow/silverstripe-colorpicker 我们能提供哪些服务?
定制开发 / 二次开发

基于 tractorcow/silverstripe-colorpicker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 266.29k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 32
  • 依赖项目数: 19
  • 推荐数: 2

GitHub 信息

  • Stars: 18
  • Watchers: 3
  • Forks: 26
  • 开发语言: JavaScript

其他信息

  • 授权协议: Unknown
  • 更新时间: 2013-05-10