php / doc-en

English PHP documentation
478 stars 709 forks source link

Table legibility on page is poor - use color to differentiate? #884

Open grnassar opened 2 years ago

grnassar commented 2 years ago

From manual page: https://php.net/types.comparisons

Sorry I couldn't submit a pull request to go along with this feature request; I honestly do not know how the XML docs work well and so don't know the best/most straightforward way to implement this.

The tables on this page, all three but especially the last two "loose comparisons" and "strict comparisons," are pretty hard to read as they are, populated with just the bold "true" and "false" text. I would like to suggest that each table cell also receive an identifying background color to ease reading those tables. So for example cells containing "true" could be set to a green background color and "false" to red.

yusuf-saif commented 2 years ago

Hmmm i doubt so looks fine to me

peterdd commented 2 years ago

For styling this either add class to the td cells when generating the HTML, e.g.

<td class="true">

<td class="false">

Then the CSS for example:

#types\.comparisons td.true{ background-color:#cfc;}

Or use javascript for that, either pure js approach or jquery $('td strong code:contains("true")') selectors and add the style dynamic.

Another approach could be to add a :hover on the row, for example

#types\.comparisons tr:hover {backgound-color:#fff;} to highlight the current hovered row.

cmb69 commented 2 years ago

I have no problem with the way it is displayed now, and adding colors might even reduce legibility (see e.g. the menu with purple on black); but if you want to change something in this regard, please have a look at https://github.com/php/phd.

peterdd commented 2 years ago

vanilla js approach:

document.querySelectorAll('#types\\.comparisons td').forEach(function(el) {
  if (el.innerText == 'true') {
    el.style.backgroundColor = "#cfc";
  }
});
document.querySelectorAll('#types\\.comparisons td').forEach(function(el) {
  if (el.innerText == 'false') {
    el.style.backgroundColor = "#ccf";
  }
});
peterdd commented 2 years ago

truefalsebg

grnassar commented 2 years ago

truefalsebg

I think this looks much, much clearer. Thank you! This is an excellent example of the suggestion. (Just as an example of improved legibility: compare finding the difference of behavior between null and false on the no-color text versus this color example; I find the eye catches the differences much more easily in this example.)

cmb69 commented 2 years ago

I think this looks much, much clearer.

Maybe, but certainly not for some visually impaired people. Maybe it is a good idea to replace true/false here with some more easily recognizable symbols?

grnassar commented 2 years ago

I think this looks much, much clearer.

Maybe, but certainly not for some visually impaired people. Maybe it is a good idea to replace true/false here with some more easily recognizable symbols?

Which visual impairments did you have in mind? I must admit I only checked against the common types of colorblindness using https://www.toptal.com/designers/colorfilter, but the above version degraded pretty elegantly across all scenarios, with the "worst case" being nearly identical to how the page appears right now. If there were other impairments that might be affected by color backgrounds that I should be testing, please let me know.