UNPKG

react-honeycomb

Version:

A library for displaying lists as honeycombs with hexagonal cells in React applications

20 lines (19 loc) 750 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getColumnSize = exports.getRowSize = exports.getGridColumnsCount = exports.HoneycombContext = void 0; const React = require("react"); exports.HoneycombContext = React.createContext({ gap: 0 }); function getGridColumnsCount(hexagonSide, containerWidth) { const hexagonWidth = Math.sqrt(3) * hexagonSide; const columns = Math.floor(containerWidth / hexagonWidth); return columns; } exports.getGridColumnsCount = getGridColumnsCount; function getRowSize(hexagonSide) { return hexagonSide / 2; } exports.getRowSize = getRowSize; function getColumnSize(hexagonSide) { return (Math.sqrt(3) * hexagonSide) / 4; } exports.getColumnSize = getColumnSize;