ElkArte Community

Elk Development => Feature Discussion => Topic started by: TaliaJoy on March 23, 2020, 11:45:53 pm

Title: Remove inline colors
Post by: TaliaJoy on March 23, 2020, 11:45:53 pm
I notice that there are some colors in ElkArte that are set using inline styles, such as the color designating a user as an administrator or a moderator in the "online now" section of the index. This is rather bothersome for custom theming.
Title: Re: Remove inline colors
Post by: radu81 on March 24, 2020, 06:16:02 am
You can change those colors in ACP -> Members -> Membergroups -> Edit membergroups
Title: Re: Remove inline colors
Post by: emanuele on March 26, 2020, 01:24:22 pm
@TaliaJoy indeed there is some stuff that is inlined, the one you mentioned, as radu suggested as defined from the admin panel and are meant to be changed by the forum admin, so there is only so much that can be done.
The only alternative that comes to my mind right now would be to let themers define lists of colors for these elements and then let admins select for each theme only from the proposed lists, though I think this would hardly please anyone.
Same applies to the colors used in the editor: these are based on the writer preferences and it would not be reasonable to let the theme decide that "red" actually appears as "black" in a certain theme.

At least, if you have any suggestion to work around these limitations I'm open to suggestions and code!
Title: Re: Remove inline colors
Post by: Antechinus on March 29, 2020, 03:21:21 am
It's actually quite easy for themers to work around it. Inline styles can be overridden by using !important in the CSS file.

IOW, template:
Code: [Select]
<a href="spambotzrus.org" class="stinky" target="_your_wallet" style="color: #reallygruesome;">ZOMG</a>

CSS file:
Code: [Select]
.stinky {color: #somethingnicer !important;}

By using this method you can easily define group colours by theme variant if you want to, regardless of what is set in admin.

Note that this is not limited to inlines styles set by PHP. It will also work for overriding inline styles set by javascript, if you need to do that.

Obligatory disclaimer: Yes, using !important indiscriminately is a sign of someone who does not know how CSS works, and will result in the deaths of millions of innocent kittens and everyone thinking your code was written by a muppet, but there are instances when using !important is the only way to sanely get the job done. In such specific cases, there is no real harm in using it as long as you are careful. :)
Title: Re: Remove inline colors
Post by: emanuele on March 29, 2020, 02:51:24 pm
And it will result in volumes of virtual ink from admins that trying to change the color of a group will not obtain the expected result. :P
Title: Re: Remove inline colors
Post by: Antechinus on March 30, 2020, 03:02:30 am
Yeah but that's the theme author's problem. The devs can just point and laugh.
Title: Re: Remove inline colors
Post by: TaliaJoy on March 31, 2020, 10:56:17 pm
OK, how's this for a solution: default colors for default member groups are set by the theme, but they can be overridden by the forum admins in the admin panel.

I don't want to get in the way of admins choosing the desired colors, but it's a bit painful when the default color for the member group set by ElkArte is something with very poor visibility against the theme background. So I would say, let them choose whatever colors they want, but the default should be something that theme authors can set to be aesthetically fitting.
Title: Re: Remove inline colors
Post by: Antechinus on April 01, 2020, 07:57:42 am
If you're going to let them choose whatever they want, there's little point worrying about whether the defaults match your theme. If they have any sense they'll choose something that matches, and if they haven't they'll make it gruesome.

And then this all falls down if they are running multiple themes and/or a multi-variant theme, because chances are you won't be able to get one default that matches them all anyway. In that situation you'd want the sort of solution I suggested: the ability to use custom CSS to change colour by theme/variant if you have more than one operational.

Look at it this way: your complaint is that stuff is hard-coded into the templates, but your idea for a "fix" is to hard-code more stuff into the templates.
Title: Re: Remove inline colors
Post by: Antechinus on April 02, 2020, 06:02:38 pm
Hey here's a thought. Will the admin inputs in Elk accept blank entries? Or, for that matter, invalid entries would do just as well.

IOW, if the inputs will take values which result in an invalid or empty inline style, then there would be no need to override anything because no inline style will be active.

If the admin inputs will take "" or "#whatever" then the template will come out like this:

Code: (Example) [Select]
<a href="nigeriascamz.org" class="ugly" target="_your_wallet" style="color:">Gimme all yer money!</a>
<a href="spambotzrus.org" class="stinky" target="_your_wallet" style="color: #whatever">ZOMG</a>

These won't be active, so will have no effect, so any colours set in index.css or a variant file won't need !important to work. You could just provide a readme that says "For best results, set the admin inputs to blank", or words to that effect.