0.0.8 • Published 3 years ago

react-grid-select v0.0.8

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

react-grid-select

A React component to select a grid size from an available space

version Monthly downloads gzip size All Contributors Build Status MIT License PRs Welcome

Example

Example

Demo

Check out the examples:

Installation

yarn add react-grid-select

or

npm install react-grid-select

Basic usage

import GridSelect from "react-grid-select";

const Demo = () => {
  const [selectedArea, setSelectedArea] = useState({ width: null, height: null });

  return (
    <GridSelect
      cols={5}
      rows={5}
      onRegionUpdate={setSelectedArea}
    />
  );
};

Props

PropTypeDefaultDescription
rowsnumber5The number of rows in the grid
colsnumber5The number of columns in the grid
onRegionUpdateFunctionLog to consoleFunction describing what to do with the selected area information. Probably set this to a state variable
cellSizenumber25Size of each grid cell in pixels
bounds{ maxWidthBlock: { width: number; height: number; }; maxHeightBlock: { width: number; height: number; }; };NoneEnabled area of the grid. By default the whole grid is enabled
disabledbooleanfalseWhether or not the grid is currently disabled. Disabling will pause the grid in it's current state and apply the disabled style
stylesobjectSee belowCustom styles to apply to the grid

Styles

All default styles can be overridden by using the styles prop which accepts the below options

StylesDefaults
active{ border: "1px solid #4d6cdd", background: "#4d6cdd" }
hover{ border: "1px solid #fff" }
cell{ width: cellSize, height: cellSize, background: "#bababa", cursor: "pointer", borderRadius: 3, border: "1px solid #bababa" }
grid{ position: "relative", display: "grid", color: "#444", margin: "25px 0", gridGap: "4px 6px", gridTemplateColumns: Array(cols).fill(${cellSize}px).join(" ") }
disabled{ filter: "brightness(0.7)" }

License

MIT

0.0.8

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago