定制 shel/neos-colorpicker 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

shel/neos-colorpicker

Composer 安装命令:

composer require shel/neos-colorpicker

包简介

A plugin for Neos CMS which provides a colorpicker editor

README 文档

README

Latest Stable Version Total Downloads License

Introduction

This package provides a Color Picker Editor which can be used in Neos CMS with the Neos.Ui 2+.

This editor is based on the example in https://github.com/neos/neos-ui-extensibility-examples but has some modifications in regards to styling, supports the alpha channel and has a reset button to unset a value.

Example

See it in action.

Colorpicker in Neos CMS sidebar

Installation

Run this in your site package

composer require --no-update shel/neos-colorpicker

Then run composer update in your project directory.

How to use

Add a property of type string and configure the editor as seen in this example:

Your NodeType:

"My.Site:Content.Text":
  superTypes:
    "Neos.Neos:Content": true
  ui:
    label: 'My text content'
  properties:
    textColor:
      type: string
      ui:
        label: 'Text color'
        reloadIfChanged: true
        inspector:
          group: 'text'
          editor: 'Shel.Neos.ColorPicker/ColorPickerEditor'
          editorOptions:
            # `mode` can be one of "rgba", "hsla", "hex", "preset", default: rgba
            mode: 'rgba'
            # Show saturation/hue/alpha (optional), boolean, default: false
            picker: true
            # Show hex/rgba fields (optional), boolean, default: false
            fields: true
            # Show preset colors (optional), array of colors or boolean (to disable)
            presetColors: ['#ff0000', '#0000ff', '#ffff00', ...]
            # OR you can show presetColors with alternative titles, that will be shown on hover
            # presetColors: [{color: '#ff0000', title: 'red'}, {color: '#0000ff', title: 'blue'}, {color: '#ffff00', title: 'yellow'}]
            # Hides the reset button if set to false
            allowEmpty: true

Your Fusion:

prototype(My.Site:Content.Text) < prototype(Neos.Neos:ContentComponent) {

  textColor = ${q(node).property('textColor')}

  renderer = afx`
    <div class="container" style={'color:' + props.textColor + ';'} style.@if.hasColor={props.textColor}>
        <h1>Hello World</h1>
        <p>Euismod massa quam arcu et mi arcu tincidunt maximus tortor lacus interdum vivamus cursus aliquam eget amet amet eget gravida et vivamus eget diam tortor.</p>
    </div>
  `
}

Customization

The editor allows some global default options via your Settings.yaml file:

Neos:
 Neos:
  Ui:
   frontendConfiguration:
    "Shel.Neos:ColorPickerEditor":
     # `mode` can be one of "rgba", "hsla", "hex", "preset"
     mode: "rgba"
     # Colors which are available for quick selection
     presetColors: ["#D0021B", "#F5A623", ...]

mode allows you to store the selected color values in a different format if needed. This can be helpful, when the hsl format is needed to get the individual components.

presetColors lets you customize the list of color squares that are available for quick selection.

Advanced preset usage

The presetColors option can have two shapes. One is just a simple list of color strings, the other one is a list of objects with a color (hex) and optional title and value properties.

  • color - the color (hex) that will be displayed in the preset color squares
  • title - (optional) the text that will be displayed on hover
  • value - (optional) the value that will be stored in the node property instead of the color value

The value can be used to store a value different from the presets color value. This value is only used when the mode is set to preset which in turn will also disable the color picker and the color fields. The benefit of this option is that you can show a color value to the user but store a different value in the node property. F.e. a CSS classname.

Contributions

Contributions are very welcome!

Please create detailed issues and PRs.

shel/neos-colorpicker 适用场景与选型建议

shel/neos-colorpicker 是一款 基于 TypeScript 开发的 Composer 扩展包,目前已累计 102.72k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2019 年 03 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 102.72k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 13
  • 依赖项目数: 5
  • 推荐数: 1

GitHub 信息

  • Stars: 14
  • Watchers: 2
  • Forks: 7
  • 开发语言: TypeScript

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2019-03-29