A game of minesweeper with only one square to sweep. Fun for the whole family.

  • By Tim Holman
  • Last update: Dec 26, 2022
  • Comments: 2

Comments(2)

  • 1

    UX: Clicking the face to restart is not obvious

    When I first tried this, I had no idea how to reset after winning/losing. Maybe clicking the face is the way the board was reset in classic minesweeper? Regardless, I barely played that, and it was a loong time ago, so the restarting action was not obvious to me.

    It would be nice to have some sort of indicator of how to reset. Maybe a small reset icon in the upper right of the face after the game ends? idk of a clean way to indicate this w/o changing the aesthetics.

    Maybe a "help" or "how to play" button in the lower right, by the "a useless web project". It could even open a modal with an iframe that points to https://theuselessweb.com/sites/one-square-minesweeper/

    Not a big deal, just a suggestion :)

  • 2

    Fixes disabling context menu for right clicking the one square

    This fixes https://github.com/tholman/one-square-minesweeper/issues/1, in which the context menu is firing when right clicking the one square.

    The existing logic has:

      document.oncontextmenu = function (e) {
        if (e.target === oneSquare) return false;
      };
    

    Which should work in theory, but in practice it wasn't. I discovered that, even when clicking the square, e.target was the outer div (board-items). It took me a bit to figure out why, but eventually I noticed how pointer-events: none; was set on the flagged class. If I remove that, the oncontextmenu event target is correctly one-square.

    This is kind of weird, since the right click event precedes adding the flagged class. I guess oncontextmenu fires after mouseup, and by the time it fires the class is already applies and the pointer event passes through to the parent div. It's possible that this only happens on faster machines or some modern browser versions, maybe the CSS change parsing was delayed for some reason in your development context? I'm curious how reproducible this issue is.

    I don't know the initial rationale for setting pointer-events to none for flagged, maybe prior logic broke if it was clicked again but you updated it? Regardless, I played around a bit with it after making this change, and I don't notice any changing behavior besides the context menu fix.

    Anyhow, this is a cool project, and I absolutely love theuselessweb.com.