bolt/颜色

🎨 Bolt 颜色扩展

维护者

详细信息

github.com/bolt/color

源代码

问题

安装次数: 7,644

依赖者: 0

建议者: 0

安全: 0

星标: 1

关注者: 4

分支: 1

开放问题: 0

类型:bolt-extension

1.0.1 2020-10-27 17:35 UTC

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

这将显示为类似这样的颜色选择器字段(没有红色高亮)

Color field

在 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 #}