Skip to main content
Topic: Remove inline colors (Read 2003 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Remove inline colors

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.

Re: Remove inline colors

Reply #1

You can change those colors in ACP -> Members -> Membergroups -> Edit membergroups

Re: Remove inline colors

Reply #2

@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!
Bugs creator.
Features destroyer.
Template killer.

Re: Remove inline colors

Reply #3

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. :)
Last Edit: March 29, 2020, 03:30:00 am by Antechinus
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Remove inline colors

Reply #4

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
Bugs creator.
Features destroyer.
Template killer.

 

Re: Remove inline colors

Reply #5

Yeah but that's the theme author's problem. The devs can just point and laugh.
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Remove inline colors

Reply #6

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.

Re: Remove inline colors

Reply #7

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.
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Remove inline colors

Reply #8

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.
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P