Proper way to add layers to elements #57
Labels
complexity: medium
package: theme
NPM package @arwes/theme
type: enhancement
A feature update
type: request
Hi. I loved this framework since i saw it, but it had me a little disapointed that there was no direct way to add custom layers for the components. One option was customize the default layers, but this apply to all the elements that use theme, not just the ones that you specify with the 'layer' option.
Anyway, it can be done editing the files of the 'lib' folder, and its relatively easy. This is how i did it.
First go to your Arwes module folder inside node_modules. The files that are needed to edit are all in the lib folder.
Inside lib, open the file at tools/createTheme/theme.js. You will see on the exports.default an object with the default properties for every option for the elements. In the property 'color' and 'background' are all the posible layers and their default colors, generated by the functions declarated on top. So here i added four more layers named 'extraOne', 'extraTwo', etc; all with the same color because i pretended to edit them later on the app. It ended like this
Is important to add both the color and background property with the same name, so they are linked. If not you will get an error.
Now, to be able to use this on the elements, you need to edit every file that you want to use with these. In my case, every element that have the 'layer' option, wich are: Button, Frame, Highlight, Image, Line, Loading and Words
Every element has a file on his folder named after his name, like Button.js, Frame.js, etc.
On that files, find a line where the 'layer' option is declared, it looks like this
Now add the new layers
And thats all. Now in your code you can pass the layer option in an element like the default ones.
And you can edit the colors as well
I hope someone find this usefull, it is for me. And if there is a better way to do it, please tell me.
The text was updated successfully, but these errors were encountered: