{"size": 1459, "ext": "js", "max_stars_repo_path": "src/Helpers/getDimensions.js", "max_stars_repo_name": "Walker-TW/Algorithm-Visualizer", "max_stars_repo_stars_event_min_datetime": "2020-05-30T13:25:23.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-09T11:03:47.000Z", "max_issues_repo_path": "src/Helpers/getDimensions.js", "max_issues_repo_name": "Walker-TW/Algorithm-Visualizer", "max_issues_repo_issues_event_min_datetime": "2020-05-15T16:54:03.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-13T12:37:18.000Z", "max_forks_repo_path": "src/Helpers/getDimensions.js", "max_forks_repo_name": "Walker-TW/Algorithm-Visualizer", "max_forks_repo_forks_event_min_datetime": "2020-06-26T16:28:26.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-17T15:00:52.000Z"}
{"max_stars_count": 202, "max_issues_count": 6, "max_forks_count": 9, "avg_line_length": 28.0576923077, "max_line_length": 79, "alphanum_fraction": 0.6895133653}
const [screenWidth, screenHeight] = [window.innerWidth, window.innerHeight];
const GRID_PADDING = 40;
const FULL_SIZE_NAV_HEIGHT = 48;
const MID_SIZE_NAV_HEIGHT = 104;
const THIN_SIZE_NAV_HEIGHT = 104;
const STATS_HEIGHT = 83;

let width, height;

const fullSize = screenWidth > 1654;
const midSize = screenWidth > 1212;
const thinSize = screenWidth > 991;
const tablet = screenWidth > 414;

const adjustedHeight = (navHeight, nodeSize) => {
  return Math.floor(
    (screenHeight - GRID_PADDING - navHeight - STATS_HEIGHT) / nodeSize
  );
};
const adjustedWidth = (screenWidth, nodeSize) => {
  return Math.floor(Math.floor((screenWidth - GRID_PADDING) * 0.9) / nodeSize);
};
export const maxFill = (value, nodeSize) => {
  return Math.floor((value - GRID_PADDING) / nodeSize);
};

export const getDimensions = (nodeSize) => {
  let size = nodeSize ? nodeSize : defaultNodeSize;
  [width, height] = fullSize
    ? [
        adjustedWidth(screenWidth, size),
        adjustedHeight(FULL_SIZE_NAV_HEIGHT, size),
      ]
    : midSize
    ? [
        adjustedWidth(screenWidth, size),
        adjustedHeight(MID_SIZE_NAV_HEIGHT, size),
      ]
    : thinSize
    ? [
        adjustedWidth(screenWidth, size),
        adjustedHeight(THIN_SIZE_NAV_HEIGHT, size),
      ]
    : [maxFill(screenWidth, size), maxFill(screenHeight, size)];

  return [width, height];
};

export const defaultNodeSize = thinSize ? 20 : tablet ? 30 : 40;

export default getDimensions;
