voidlabs / mosaico

Mosaico - Responsive Email Template Editor
https://mosaico.io
GNU General Public License v3.0
1.7k stars 500 forks source link

unable to set default values for elements #537

Closed lcdservices closed 4 years ago

lcdservices commented 5 years ago

I am creating a copy of the versafix-1 base template with the primary intent of adding additional fonts and setting alternate default css values for various blocks. The documentation indicates:

"When you use -ko-attr- or -ko- it must be preceded by the related attribute/property that will be used as default value."

However, when I do that, I get errors in the console such as:

TODO error!!! Trying to set a new default value for contentTheme backgroundColor while it already exists (current: #ffffff, new: #fc4c02)

I've attempted altering the font size, font face, and color. The errors are the same, simply referencing different variables and css values. Referencing the error above -- when looking at the place where contentTheme is declared, there is no default value set. It just references up through the color widget.

What am I missing? How do I declare a different default css value?

lcdservices commented 5 years ago

My question seems related to: https://github.com/voidlabs/mosaico/issues/442

I think I can fix this by creating a custom contentTheme variable that I use for the block in question.

But I have to say, that's a tedious amount of adjustment/troubleshooting to figure this out. If we're assigning a theme to a block, we should be able to set a local default on a per-block-element basis. As it stands -- you can't explicitly set a default in the variable declaration, and you must make sure all uses of a theme reference the same default value. That really seems backward.

bago commented 5 years ago

If you "generate" your template, the am amount of adjustment/troubleshooting will be much less: https://github.com/voidlabs/versafix-template

There's a reason if mosaico works this way and it is related to the "theme" function as I wanted blocks to share a theme so that users could simply change the whole aspect once instead of being forced to edit each and every block style. For this to work fine I had to force this behaviour that everytime you use the same variable then this have to use the same value (1 variable = 1 value).

Contributions are welcome, so if you think you identified a better way to make mosaico smarter and easier to use, I'll be happy to review the code changes.

bago commented 5 years ago

If you have 2 different colors in your template then they can't be the same variable. Use 2 different variable names.

Your issue is not you're unable to set a default value (in fact the error tells you that you're trying to assign a new default value for the same variable you already assigned a different default value) but that you cannot assign 2 different values to the same variable.

If you have red and blue buttons in your templates then either you use 2 different variables goodButtonColor badButtonColor or you use 2 different themes for the blocks using one color and the blocks using the other colors.