codein / ibexa-color-picker
Ibexa 平台颜色选择器字段类型
3.0.0
2023-06-16 10:43 UTC
Requires
- php: ^7.3
- ext-json: *
- ibexa/core: ~4.5
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-16 15:05:51 UTC
README
Symfony 扩展包,为 Ibexa 平台添加颜色管理功能。
(如果您需要与 eZ Platform 2.5 兼容的此扩展包版本,请查看此存储库: https://github.com/Codein-Labs/ezplatform-color-picker)
安装
composer require codein/ibexa-color-picker
在 bundles.php 中激活扩展包
Codein\eZColorPicker\eZColorPickerBundle::class => ['all' => true],
编译管理界面的资产
./bin/console ezplatform:encore:compile
使用
默认值
您可以为字段设置默认颜色。如果没有设置颜色,则将建议用户使用默认颜色。如果字段是必填项,则默认颜色将被分配。如果不是,则不分配颜色。
Twig
在 Twig 中渲染的默认颜色格式为 RGBa。您可以向 ez_render_field 传递额外的选项。
- 格式:RGBa, HEXa, HSVa, RGB, HEX
- 默认值:如果字段为空时返回的默认值。如果没有设置,ez_render_field 将返回空字符串
{{ ez_render_field(content, 'color2', {'parameters': {'format': 'HEX', 'default': 'none'}}) }}
迁移
方法 \Codein\eZColorPicker\FieldType\ColorPicker\Type::acceptValue 将接受单个字符串并将其转换为颜色。以下格式将被转换为有效的值对象
HSVa: hsva(0, 86%, 69%, 0.69)
RGBa: rgba(176, 25, 25, 0.69)
HEXa: #B01919B0
RGB: rgb(176, 25, 25)
HEX: #B01919
在编写迁移时可以使用此功能。
我们还为您提供了颜色转换服务 在此。
感谢
此扩展包在 MIT 许可证下使用 Pickr (https://github.com/Simonwep/pickr)。