Module talk:Color contrast: Difference between revisions

Content deleted Content added
Recorded copying.
 
(11 intermediate revisions by 7 users not shown)
Line 1:
{{WikiProject banner shell|
{{WikiProject Color}}
}}
{{copied|fromfrom1=Module:Color_contrast|from_oldidfrom_oldid1=823705246|toto1=:incubator:Module:Wp/nod/Color_contrast|to_diffto_diff1=4243085}}
 
|from2=Module:Color_contrast/colors|from_oldid2=673825843|to2=:incubator:Module:Wp/nod/Color_contrast/colors|to_diff2=4243093}}
== Making the lum function accessible from modules ==
 
Line 41 ⟶ 43:
::: You could also write <code>p._lum = color2lum</code> instead of the second function definition, but setting it out explicitly, as you have done, helps whoever is importing the module to see what parameters to supply. Cheers --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 15:41, 6 January 2019 (UTC)
::::Sure, looks good. I'll update the sandbox version. --[[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 15:43, 6 January 2019 (UTC)
 
== Possible typos in code? ==
 
Observing the code, I might have spotted a couple of typos:
 
=== In <code>p._greatercontrast</code> function, lines 160 and 161 ===
I think <syntaxhighlight lang='lua'>if mw.ustring.match(v3, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') or
mw.ustring.match(v3, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') then</syntaxhighlight> should read <syntaxhighlight lang='lua'>if mw.ustring.match(c3, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') or
mw.ustring.match(c3, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') then</syntaxhighlight> instead. Here, <code>v3</code> is expected to be a number, thus there is no point in applying it a regular expression. Besides, given the four lines above, it seems logical to use <code>c3</code> variable here instead of <code>v3</code>.
 
=== In <code>p._styleratio</code> function, line 209 ===
I think <syntaxhighlight lang="lua">if( lum ~= '' ) then bg, lum_fg = v, lum end</syntaxhighlight> should read <syntaxhighlight lang="lua">if( lum ~= '' ) then fg, lum_fg = v, lum end</syntaxhighlight> instead, since at this point we have isolated a forecolor specification from input CSS.
 
My apologies if I would have misinterpreted your code.
 
Kindly, [[User:Olivier Ph.|Olivier Ph.]] ([[User talk:Olivier Ph.|talk]]) 12:11, 13 October 2020 (UTC)
 
== Categorisation broken? ==
 
Through Documentation subpage, [[:Category:Modules handling colors]] is added as expected. However, the page does not appear in {{clc|Modules handling colors}}. -[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 15:12, 7 January 2021 (UTC)
:
: {{re|DePiep}} categorisation behaves as something of a black art. The page appears in [[:Category:Modules handling colors]] now, but obviously didn't earlier today. [[Wikipedia:FAQ/Categorization #Why might a category list not be up to date?]] discusses some of the issues that may cause the lag. I usually try a null edit to "touch" the pages concerned and often find the page then appears in the category, but it's not always 100% successful. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 16:07, 7 January 2021 (UTC)
::I had just edited out the {{tl|Sandbox other}} [https://en.wikipedia.org/w/index.php?title=Module:Color_contrast/doc&diff=998898289&oldid=998796533&diffmode=source]. So we have a cause (bug). Did not investigate problem further.-[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 16:11, 7 January 2021 (UTC)
::: Yes I saw that. But because the category was being added via {{tl|Sandbox other}} and now is added directly via [[Module:Color contrast/doc]], that becomes effectively a different transclusion and the usual caveats about delays because of cached transclusions apply. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 16:56, 7 January 2021 (UTC)
::::{{tlf|Sandbox other}} should be checked for Module ns then? But [https://en.wikipedia.org/w/index.php?title=Special%3AWhatLinksHere&target=Template%3ASandbox+other&namespace=828 here] it seems to work. (To be clear: before my edit the category was empty, and no delay was working, no recent edits). I'll leave it for now. -[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 17:18, 7 January 2021 (UTC)
 
== Template-protected edit request on 18 March 2025 ==
 
{{edit template-protected|Module:Color contrast|answered=yes}}
Line 135:
{{td| local c2 {{=}} args[2] or '#FFFFFF'| local c2 {{=}} args[2] or 'white'}}
Line 137:
{{td| local c3 {{=}} args[3] or '#000000'| local c3 {{=}} args[3] or 'black'}}
Change the specification of the default colors from hex triplets <syntaxhighlight lang="lua" inline>'#FFFFFF'</syntaxhighlight> and <syntaxhighlight lang="lua" inline>'#000000'</syntaxhighlight> to named HTML colors <syntaxhighlight lang="lua" inline>'white'</syntaxhighlight> and <syntaxhighlight lang="lua" inline>'black'</syntaxhighlight> respectively. This allows the default case to take advantage of the pre-computed table of relative luminances of named HTML colors at [[Module:Color contrast/colors]] checked by the <code>color2lum()</code> function instead of calculating the relative luminances of white and black every time (as the module as currently written does), as well as, at least for the default colors, avoiding a parser bug that causes output that begins with <code>#</code> to result in a numbered list. '''[[User:Kinsio|<span style="color:#df0000">Kinsio</span>]]''' <span style="color:#096450">('''''[[User talk:Kinsio|talk]]''''' ★ '''''[[Special:Contributions/Kinsio|contribs]]''''' ★ '''''[[Special:UserRights/Kinsio|rights]]''''')</span> 18:55, 19 March 2025 (UTC)
: {{done}} [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 20:30, 30 March 2025 (UTC)