Skip to content

Conversation

RafaelJohn9
Copy link
Contributor

@RafaelJohn9 RafaelJohn9 commented Sep 23, 2025

Changes

Fix #2068

  • Removes the Monitor Background Image from the front page
  • Makes the different tags that were inside the monitor more visible (changed their colors)

Context

After the remove of the Background image, the monitor tag looks like this:

Screenshot_20250923_235909
  • I opted to have the tag still to have the name monitor since it contains different details such as latest Git version, Binary links for different operating systems and the release date for the latest Git version.

  • One thing I wasn't sure of was whether to remove the images from the repository, would love to hear your thoughts on this.

@dscho
Copy link
Member

dscho commented Sep 25, 2025

I have to admit that the new look does not tickle my fancy... But then, I had no problem with the monitor, either. @To1ne do you prefer the new look? If so, I won't object against merging.

@To1ne
Copy link
Collaborator

To1ne commented Sep 26, 2025

I have to admit that the new look does not tickle my fancy

Well, me neither. For me this makes it more obvious what the latest release is, so that is good. (or maybe my brain was trained to ignore the computer monitor already, that's also possible).

Maybe it's just the empty space that's making it weird. Can you move the other links up? And maybe make the Pro Git section full width?

}

.monitor {
@include background-image-2x($baseurl + "images/monitor-default", $monitor-width, $monitor-height);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also remove the assets if we don't need them no more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW this is also the reason for the Playwright test failure:

before after
0b8e1c7b4a7e58b23d502940afdb317184e893e8 1592a2271140f8c85e0e8dca3ad09626c2c91847

Notice the upper part of the monitor in the left screenshot?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW originally I had meant not to compare screenshots, but to overlay with a really blurry <div> and then measure the pixel brightness, then verify that it is relatively bright for light mode and dark for dark mode. But IIRC I got stuck somewhere along the lines. Maybe it was the "measure pixel brightness".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa, I can't believe that I couldn't make it work back then. It's relatively easy:

const { chromium } = require('playwright');
const fs = require('fs');

(async () => {
  const browser = await chromium.launch(/* uncomment for debugging: { headless: false } */);
  const page = await browser.newPage();
  await page.goto('https://git-scm.com');

  const getBrightness = async () => {
    // Take screenshot as base64
    const screenshot = await page.screenshot({ type: 'png' });
    return await page.evaluate(async (base64) => {
      return new Promise((resolve) => {
        const img = new Image();
        img.src = 'data:image/png;base64,' + base64;
        img.onload = () => {
          const canvas = document.createElement('canvas');
          canvas.width = canvas.height = 1;
          const ctx = canvas.getContext('2d');

          // Draw scaled-down image to average colors
          ctx.drawImage(img, 0, 0, 1, 1);
          const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;

          // Calculate brightness, for more details, see
          // https://en.wikipedia.org/wiki/Relative_luminance#Relative_luminance_and_%22gamma_encoded%22_colorspaces
          const brightness = 0.2126 * r + 0.7152 * g + 0.0722 * b;
          resolve(brightness);
        };
      });
    }, screenshot.toString('base64'));
  };

  console.log(`Estimated brightness: ${await getBrightness()}`);

  const darkModeButton = page.locator('#dark-mode-button');
  await darkModeButton.click();

  console.log(`Estimated dark brightness: ${await getBrightness()}`);

  // Inject image into page and analyze brightness
  await browser.close();
})();

For me, this prints:

Estimated brightness: 216.4316
Estimated dark brightness: 63.005199999999995

Therefore, I think the best idea would be to change the Playwright tests that want to verify that dark mode is dark, light mode is bright, with a variation of this code, say, dividing the return value by 255 to limit it to the range between 0 and 1, and then assert something like expect(await getBrightness()).toBeCloseTo(0.25, 2) for dark mode (and 0.85 for light mode).

@RafaelJohn9 do you want to run with this and replace the screenshot-based assertions (and likewise these assertions) with this kind of more robust approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing 👍,

Will update the tests 🤝

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelJohn9 maybe that update should be split out into its own PR, which could then be fast-tracked?

Copy link
Contributor Author

@RafaelJohn9 RafaelJohn9 Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh okay,

lemme reset 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't mean the deletion of the resources that are no longer referenced. I meant the test update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misunderstood that 😅 ,

Awesome, so should I open another PR referencing the same issue, or should I create a separate issue for it ?

Copy link
Member

@dscho dscho Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In git-scm.com, we play a bit looser (albeit not as loose as the Git mailing list): We don't require an issue for every PR. Just open another PR with the updated test (and removing the stored screenshots), maybe referencing this finding about the Playwright tests being broken by benign updated as justification.

@jvns
Copy link
Collaborator

jvns commented Oct 1, 2025

I've been working on a new potential look for the "Install" page, without the computer monitor. I'm not sure how it should affect the homepage yet. It's not quite ready yet to make a PR but here's a screenshot of the current state:

image

@dscho
Copy link
Member

dscho commented Oct 1, 2025

image

This is probably how we should present it on the front page, too. Nice, sleek, informative.

@RafaelJohn9
Copy link
Contributor Author

So uhm,

should I update it to match the deisgn?

@dscho
Copy link
Member

dscho commented Oct 1, 2025

So uhm,

should I update it to match the deisgn?

Maybe it would make sense to let @jvns complete the "Install" page and then update the design in the same PR?

@RafaelJohn9 RafaelJohn9 force-pushed the refactor/rm-computer-monitor branch from 5e73d77 to 52da97c Compare October 2, 2025 08:26
dscho added a commit that referenced this pull request Oct 2, 2025
## Changes

- Replaced pixel-based visual regression tests for dark/light mode with
perceptually accurate brightness assertions.
- Implemented a `getPageBrightness()` helper that computes **relative
luminance** using the ITU-R BT.709/sRGB coefficients (`0.2126*R +
0.7152*G + 0.0722*B`), normalized to the `[0, 1]` range.
- Added assertions that light mode brightness is approximately `0.85 ±
0.1` and dark mode is `0.25 ± 0.1`.
- Removed all stored screenshot snapshots for dark/light mode across
browsers and devices.

## Context

Pixel-diff-based screenshot tests are fragile they fail on minor layout
shifts, anti-aliasing changes, or browser rendering differences, even
when the visual theme (light/dark) is correct.

One example is the PR where the monitor around Git's version number
is removed, which caused the dark mode tests to fail, even though the
new look did not change anything about how dark the dark mode is.

Instead, we now verify **perceived brightness** using the standard
definition of *relative luminance* from color science (per
[Wikipedia](https://en.wikipedia.org/wiki/Relative_luminance)), which
aligns with human vision sensitivity (green contributes most, blue
least).

Reference:
#2088 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove computer monitor from landing page
4 participants