Share to: share facebook share twitter share wa share telegram print page

Template talk:Navbox/Archive 25

Archive 20Archive 23Archive 24Archive 25

Improved readability

Other languages:
Korean English

For improved readability, how about deleting

:css('padding', '3px')  on line 531
:css('width', '1px')  on line 171
:css('width', '1px')   on line 255

and changing the 8th line of Module:Navbox/styles.css to 0px?

Changed result (sandbox):

Whatback11 (talk) 15:33, 29 April 2025 (UTC)

This would need to be tested with multiple other configurations e.g. subboxes and groups, and all of those have a reason themselves anyway. Width of 1px is there to ensure certain cells are guaranteed to be the minimum size, and padding is insufficient for e.g. the image cell (and I suspect is there for whitespace between rows). Izno (talk) 16:13, 29 April 2025 (UTC)
What exactly does 'certain cell' mean? Whatback11 (talk) 10:36, 1 May 2025 (UTC)
We want to minimize the width of the group cells, and setting their width to 1px does so. Or did so, I'm not sure which. That's why those are set to 1px in those locations. Izno (talk) 16:08, 1 May 2025 (UTC)
What's this Korean thing for? --Redrose64 🌹 (talk) 21:09, 29 April 2025 (UTC)
The user started the same conversation on ko.wp. Izno (talk) 23:18, 29 April 2025 (UTC)
I appear to have been mentioned at ko: wikipedia. Pointless really, as I don't read a word of it, as my user page there clearly states. --Redrose64 🌹 (talk) 20:20, 4 May 2025 (UTC)
You were mentioned via being quoted, because of your earlier question. (Technically, not a direct quote. A translated version of your comment was attributed to you.) Whatback11 is continuing to mirror the conversation between the Korean and English versions of this discussion. (With translations of each comment.) I'll now be mentioned as well, presumably. FeRDNYC (talk) 09:06, 14 May 2025 (UTC)
I'm confused. Module:Navbox hasn't changed since January, yet I can find no :css('padding', '3px') on line 531, no :css('width', '1px') on line 171, and no :css('width', '1px') on line 255.
In general principle, though, applying inline styles when generating HTML programmatically is a code smell. Even if those styles are needed, that's what style classes are for. It's as easy to generate a class="" attribute as it is to generate a style="" attribute, and the class="" doesn't screw up your carefully-planned CSS (or interfere with being able to make design updates down the road just by tweaking that CSS).
And if the styles apply in certain specific situations that can only be determined algorithmically, that's fine. (Although it's surprising just how much you can accomplish using pure CSS, thanks to pseudo-classes like :first-child, :nth-of-type, and if you can afford to get really fancy, :has().) But even in code-only situations, it's still better to define a new class to represent those cases, :addClass() that in the code, and apply the styles to the class instead of inline. (We have TemplateStyles for a reason, after all.)
The overuse of inline styles is almost certainly a big part of why there are so many ugly !important rules in the various site and skin CSS files, as designers then try to force the CSS to override style="" attributes. And when it comes to code smells, they don't get much stinkier than !important.
So, IOW — and purely in my opinion (though it's not a particularly humble one, in this instance) — if "the group cells" need to have a width of 1px, and only the code can determine what's a group cell...
Bad
if i_am_a_group_cell_and_I_have_an_image  -- or whatever
then
    row
        :tag('td')
            :stuffStuff()
            :css('width', '1px')
Good
if i_am_a_group_cell_and_I_have_an_image then
    row
        :tag('td')
            :stuffStuff()
            :addClass(cfg.class.navbox_group_cell_with_image)
coupled with, in the TemplateStyles,
td.navbox-group-with-image {
  width: 1px;
}
FeRDNYC (talk) 09:59, 14 May 2025 (UTC)
I think the reason this is inline CSS and not classes is that the class names would be just as long as what is added inline, or something to that effect. What they're doing here also doesn't have any particular need to be overwritten by arbitrary other requirements. (I'm not particularly compelled to defend the position.)
That said, this section isn't about them being inline but instead solely about their existence at all. Izno (talk) 17:04, 14 May 2025 (UTC)
Prefix: a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9

Portal di Ensiklopedia Dunia

Kembali kehalaman sebelumnya