sunnysideup / selected-colour-picker
Silverstrpe Module that sets a list of colours that the CMS Editor can choose from.
Package info
github.com/sunnysideup/silverstripe-selected-colour-picker
Type:silverstripe-vendormodule
pkg:composer/sunnysideup/selected-colour-picker
Requires
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
TL;DR
add colour to DataObject
Here is how to add a colour to a DataObject:
private static $db = [ 'MyColour' => 'Colour', 'MyColour2' => 'BackgroundColour', 'MyColour3' => 'FontColour', 'MyColour4' => 'DifferentDBColourSchema', ]
Settings in yml
Sunnysideup\SelectedColourPicker\Model\Fields\DBColour: # REQUIRED colours: '#ff2233': 'Brand Colour 1' '#88aadd': 'Brand Colour 2' # OPTIONAL! linked_colours: '#ff2233': 'font': '#123312' 'background': '#775544' 'somethingelse': '#000000' # OPTIONAL! colour_picker_field_class_name: MyColourSelectionField
Usage in SilverStripe template
<div style="background-color: $MyColour; color: $MyColour.ReadableColour" style="$MyColour.CssClass"> <br /><% if $MyColour.IsDarkColour %>Is Dark Colour <% end_if %> <br /><% if $MyColour.IsLightColour %>Is Light Colour <% end_if %> <br />Related font colour: $MyColour.RelatedColourByName(font) - as set in private static <br />Related background colour: $MyColour.RelatedColourByName(background) - as set in private static <br />Related something else colour: $MyColour.RelatedColourByName(somethingelse) - as set in private static <br />Inverted colour: $MyColour.Inverted <style> MyColour.CssVariableDefinition </style>
customisation
SilverStripe\Core\Injector\Injector: MyColour: class: MyName\MyApp\Model\Fields\DifferentDBColourSchema
In PHP you can then add different approaches.
class DifferentDBColourSchema extends DBColour { private static $colour_picker_field_class_name = MyFormField::class; /** * please set. * * @var bool */ protected const IS_BG_COLOUR = true; }
Requirements
See composer.json for details
Suggested Modules
See composer.json for details
Installation
composer require sunnysideup/selected-colour-picker
Configuration
In the _config folder you will find the selected-colour-picker.yml.example
file that shows options for the configuration of this module.
We recommend that you:
- copy these
selected-colour-picker.yml.examplefiles into yourapp/_configfolder (where available - otherwise search forprivate static $in the module to see what can be configured) - remove the .example extension,
- delete the lines you do not care about, and
- adjust the configurations that you would like to use.
Contributing
We welcome any contributions. See CONTRIBUTING.md for more details.
Paid assistance
You can pay us to create an improved / adapted version of this module for your own projects. Please contact us if you like to find out more: www.sunnysideup.co.nz. For exmaple, we can write tests for this module.
Author
Sunny Side Up Ltd.
Care to see more modules?
To find other modules, please visit ssmods.com.