bolt / color
🎨 Bolt Color extension
Installs: 8 146
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 1
Open Issues: 0
Type:bolt-extension
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-11-25 20:12:08 UTC
README
This extension allows you to use fields of type: color
in your
ContentTypes, as defined in contenttypes.yaml
.
You can also manipulate colors in Twig, with all the might of the Iris PHP Color library.
Installation
composer require bolt/color
Usage
Definition
In your contenttypes.yaml
, you can define the following field:
background: type: color label: Background color
Which will show up as a colorpicker field like this (without red highlight):
In twig
To get the hex value (#ff0000
), simply use:
{{ record.background }}
The Iris library allows many ways in which you can manipulate the value of the field, for example:
{{ 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 #}