toastnz / theme-colours
Silverstripe theme colours module
Installs: 4 185
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:silverstripe-vendormodule
pkg:composer/toastnz/theme-colours
Requires
- php: >=8.3
- heyday/silverstripe-colorpalette: dev-main
- silverstripe/cms: ^6
- tractorcow/silverstripe-colorpicker: dev-master
README
Installation
The easiest way is to use composer:
composer require toastnz/theme-colours
Run dev/build afterwards.
Configuration
Add the following to your config.yml (optional) to generate default colours on dev/build
Colours with a hex value will be locked and not editable in the CMS
Colours with null value will be editable in the CMS
Toast\ThemeColours\Models: default_colours: - primary: null - secondary: null - black: '000000' - white: 'ffffff'
Usage
Colour functions
getColourCustomID() returns either the ID set in the config.yml, or for additional colours, returns the ID
getColourPaletteID() returns a combination of the getColourCustomID() and the Title, so the data object can be found from the selected colour palette field value.
getColourClassName() returns c- + getColourCustomID() so the css class is unique. c- is there to represent colour and to ensure the class does not start with a number.
getColourBrightness() returns either dark or light based on their luminocity of the colour value.
getColourHexCode() returns the hex value of the colour
getColourClasses() will return a combination of the getColourClassName() and getColourBrightness()
Helper functions
Helper::getThemeColourPalette() to loop through the $themeColours and add the Title and Value to the $array for ColorPaletteField to use.
Helper::getThemeColourFromColourPaletteID to loop through the $themeColours and return the object that matches the $colourPaletteID