fromholdio/silverstripe-colorpalette

SilverStripe CMS 的颜色调色板选择器

安装: 550

依赖项: 2

建议者: 0

安全: 0

星星: 1

关注者: 1

分支: 16

开放问题: 1

类型:silverstripe-vendormodule

3.1.0 2023-05-24 06:07 UTC

This package is auto-updated.

Last update: 2024-09-24 08:52:40 UTC


README

为 SilverStripe 提供一个颜色选择字段,允许用户从定义的颜色选择(调色板)中选择

从 heyday/silverstripe-colorpalette 分支进行分支,应用 PR 和新的样式。2.x 分支与原始存储库的 2.x 分支兼容,可作为直接替换。

活跃的 3.x 分支在原始版本的基础上增加了更多功能和重大更改

  • 为每个颜色提供文本标签,并将它们显示给用户
  • 为每个颜色设置完整的 CSS 背景声明,而不是仅设置十六进制值(允许渐变/图片等)
  • 可以设置一些文本字符串,如 "Aa",它将被放置在颜色框的顶部(可选)
  • 设置一个与背景值不同的 CSS 颜色值,顶部框中的文本将使用此颜色值着色(可能有两个具有相同背景样式但文本颜色不同的主题,例如)
  • 改进了 'selected' 视觉处理
  • 分组字段现在继承自单个版本的字段,并减少了重复代码

安装(使用 composer)

$ composer require fromholdio/silverstripe-colorpalette

示例

Color Palette Example

用法

常规调色板

$fields->addFieldToTab(
    'Root.Main',
    Fromholdio\ColorPalette\Fields\ColorPaletteField::create(
        'BackgroundColor',
        'Background Color',
        [
            // still works
            'white' => '#fff',      // will be applied as 'background_css' value
            // new config options
            'black' => [
                'label' => 'Jet Black',     // displayed in field under color box
                'background_css' => '#111', // without ';', used to fill in color box
                'color_css' => '#FFFFFE',   // used to style the sample_text displayed on top of color box
                'sample_text' => 'Aa'       // if color_css is provided, this text displayed on top of color box
            ]
        ]
    )
);```

### Grouped Palette

```php
$fields->addFieldToTab(
    'Root.Main',
    Fromholdio\ColorPalette\Fields\GroupedColorPaletteField::create(
        'BackgroundColor',
        'Background Color',
        [
            'Group title' => [
                'black' => '#000',
                'white' => [
                    'label' => 'White',
                    'background_css' => '#FFF',
                    'color_css' => '#000',
                    'sample_text' => 'Aa'
                ]
            ],
            'Another group title' => [
                'red' => '#ff0'
            ]
        ]
    )
);

许可证

SilverStripe 颜色调色板字段许可协议为 MIT 许可协议