diff --git a/src/HandMatrix.css b/src/HandMatrix.css index 5c1cf66..6db06fe 100644 --- a/src/HandMatrix.css +++ b/src/HandMatrix.css @@ -13,14 +13,19 @@ margin: 0; box-sizing: border-box; display: flex; - flex-flow: row wrap; + flex-flow: row; + flex-wrap: nowrap; + overflow: hidden; + width: 100%; } .hand-matrix-cell { border: 1px solid grey; display: inline-block; - font-size: 1em; touch-action: none; + font-size: 1rem; + width: 7.691%; + overflow: hidden; } @media screen and (max-width: 992px) { diff --git a/src/HandMatrix.js b/src/HandMatrix.js index 89b9ca8..708db19 100644 --- a/src/HandMatrix.js +++ b/src/HandMatrix.js @@ -1,5 +1,7 @@ -import React, { useState } from "react"; +import React from "react"; import PropTypes from 'prop-types'; +import { Textfit } from 'react-textfit'; + import "./HandMatrix.css"; export const combos = [ @@ -25,17 +27,16 @@ const chunk = (arr, size) => const ComboTile = React.memo( ({ - combo, - styles = {}, - comboSubtext = "", - showText = true, - colorize = true, - }) => { + combo, + styles = {}, + comboSubtext = "", + showText = true, + colorize = true, + }) => { return (
{showText && ( <> -
+
{combo}
{comboSubtext}
@@ -62,12 +63,12 @@ const ComboTile = React.memo( const ComboRow = React.memo( ({ - row, - comboStyle, - comboSubtext, - showText, - colorize, - }) => ( + row, + comboStyle, + comboSubtext, + showText, + colorize, + }) => (
{row.map((combo, j) => ( assertElementFitsHeight(wrapper, originalHeight); +// const testSecondary = () => assertElementFitsWidth(wrapper, originalWidth) +// function innerHeight(el) { +// const style = window.getComputedStyle(el, null); +// if (!style) return el.clientHeight; +// return ( +// el.clientHeight - +// parseInt(style.getPropertyValue("padding-top"), 10) - +// parseInt(style.getPropertyValue("padding-bottom"), 10) +// ); +// } +// function innerWidth(el) { +// const style = window.getComputedStyle(el, null); +// // Hidden iframe in Firefox returns null, https://github.com/malte-wessel/react-textfit/pull/34 +// if (!style) return el.clientWidth; +// return ( +// el.clientWidth - +// parseInt(style.getPropertyValue("padding-left"), 10) - +// parseInt(style.getPropertyValue("padding-right"), 10) +// ); +// } + /** * Texas Hold'em hand matrix component */ function HandMatrix({ - comboSubtext, - comboStyle, - onSelect, - onPointerDown, - onPointerUp, - onPointerEnter, - onPointerMove, - showText, - colorize, -}) { + comboSubtext, + comboStyle, + onSelect, + onPointerDown, + onPointerUp, + onPointerEnter, + onPointerMove, + showText, + colorize, + }) { let currentlyPointingAt; - const getComboForPointerEvent = (e) => document.elementFromPoint(e.clientX, e.clientY).dataset.combo; + const getComboForPointerEvent = (e) => document.elementFromPoint(e.clientX, e.clientY)?.dataset.combo; const comboEventDispatcher = fn => e => { if (!fn) return; const combo = getComboForPointerEvent(e);