Comments (2)
Having spent a bunch of days looking at the sources (I even recompiled it to a readable developer version), I have seen exactly how this works.
Laraberg "colors" settings property is an array of color objects (containing "name", "slug", "color" properties). The name is shown when you hover your mouse over the color from the selector; the color is used to fill the selector and the slug is used to generate a class that is applied to the element (thus you define each color once as a background and once for text in CSS).
Since this colors needs to be in your CSS and passed as a JSON object to Laraberg, I decided it easiest to simply define an array of arrays in my "config/app.php" file with all the colors I want (below is the default list):
'colors' => [
[
'name' => 'White',
'slug' => 'white',
'color' => '#ffffff',
],
[
'name' => 'Black',
'slug' => 'black',
'color' => '#000000',
],
[
'name' => 'Cyan bluish gray',
'slug' => 'cyan-bluish-gray',
'color' => '#abb8c3',
],
[
'name' => 'Pale pink',
'slug' => 'pale-pink',
'color' => '#f78da7',
],
[
'name' => 'Vivid red',
'slug' => 'vivid-red',
'color' => '#cf2e2e',
],
[
'name' => 'Luminous vivid orange',
'slug' => 'luminous-vivid-orange',
'color' => '#ff6900',
],
[
'name' => 'Luminous vivid amber',
'slug' => 'luminous-vivid-amber',
'color' => '#fcb900',
],
[
'name' => 'Light green cyan',
'slug' => 'light-green-cyan',
'color' => '#7bdcb5',
],
[
'name' => 'Vivid green cyan',
'slug' => 'vivid-green-cyan',
'color' => '#00d084',
],
[
'name' => 'Pale cyan blue',
'slug' => 'pale-cyan-blue',
'color' => '#8ed1fc',
],
[
'name' => 'Vivid cyan blue',
'slug' => 'vivid-cyan-blue',
'color' => '#0693e3',
],
[
'name' => 'Vivid purple',
'slug' => 'vivid-purple',
'color' => '#9b51e0',
],
],
Then on all pages where I might want to add the editor or its output I have this loop to generate the CSS rules:
<style>
@foreach(config('app.colors') as $color)
.has-{{ $color['slug'] }}-color {
color: {!! $color['color'] !!};
}
.has-{{ $color['slug'] }}-background-color {
background-color: {!! $color['color'] !!};
}
@endforeach
</style>
And then finally when setting up the editor, I insert the list with the following code (in the Blade) colors: @json(config('app.colors'))
The @JSON directive json_encodes the array, into the required structure and it is passed to the editor.
If you want to be able to define colors on the fly (not only pre-defined colors), you can enable it by using disableCustomColors: false
also in the settings object. I have found a bunch more of these toggles that will work.
from laraberg.
This issue has been automatically marked as stale because it has been open for 60 days with no activity.
from laraberg.
Related Issues (20)
- using UniSharp/laravel-filemanager with laraberg v2 HOT 1
- using UniSharp/laravel-filemanager with laraberg v2 HOT 1
- Adding a custom block category HOT 1
- Unpacked laraberg.js HOT 2
- No matter what happens, "Your site doesnโt include support for the block" gets thrown. HOT 1
- Cannot unselect in edit mode HOT 1
- The color picker in the inspector is broken HOT 2
- wp-block-group - ContentSize not working HOT 1
- wp-block-buttons justify content does not work HOT 1
- Migration Added Then Immediately Removed - Fresh Laravel 10 Install HOT 2
- With Livewire could an alternative to Gutenberg be made? HOT 1
- Data loss as a result of dropping lb_content table after ruinning laraberg migrations HOT 1
- RichText registerFormatType HOT 1
- Customizing Link Search / Autocomplete Links Functionality HOT 1
- Server Side Custom Block HOT 1
- not getting image to upload or select from library HOT 4
- multi language
- I cannot see medial library image choosing in image block. how can i implement with my custom library in laravel HOT 1
- No background color and text color for setting HOT 1
- I can't upload an image via the editor. Help!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laraberg.