bolt / 颜色
🎨 Bolt 颜色扩展
1.0.1
2020-10-27 17:35 UTC
Requires
- php: >=7.2.9
- ozdemirburak/iris: ^2.1
Requires (Dev)
- bolt/core: ^4.0.0
- symplify/easy-coding-standard: ^7.0
This package is auto-updated.
Last update: 2024-08-25 19:35:52 UTC
README
此扩展允许您在 ContentTypes 中使用 type: color
字段,如 contenttypes.yaml
中定义。
您还可以使用 Iris PHP 颜色库 的全部功能在 Twig 中操作颜色。
安装
composer require bolt/color
用法
定义
在您的 contenttypes.yaml
中,您可以定义以下字段
background: type: color label: Background color
这将显示为类似这样的颜色选择器字段(没有红色高亮)
在 twig 中
要获取十六进制值(#ff0000
),只需使用
{{ record.background }}
Iris 库 允许您以多种方式操作字段的值,例如
{{ record.background.red }} {# get the amount of red #} {{ record.background.values }} {# array with ['ff', '00', 'ff'] rgb values #} {{ record.background.lighten(20) }} {{ record.background.darken(10) }} {{ record.background.dark }} {# true if color is dark #} {{ record.background.hsl }} {# converts to HSL #} {{ record.background.rgba }} {# converts to RGBA #}