Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/seanghay/gridboard

A library for building Grid & Spans on Canvas
https://github.com/seanghay/gridboard

canvas canvas-grid grid

Last synced: about 2 months ago
JSON representation

A library for building Grid & Spans on Canvas

Awesome Lists containing this project

README

        

# Grid Board

A library for building Grid & Spans on Canvas

[![ci](https://github.com/seanghay/gridboard/actions/workflows/ci.yml/badge.svg)](https://github.com/seanghay/gridboard/actions/workflows/ci.yml)
[![Release](https://github.com/seanghay/gridboard/actions/workflows/release.yml/badge.svg)](https://github.com/seanghay/gridboard/actions/workflows/release.yml)
[![npm](https://img.shields.io/npm/v/@gridboard/core)](https://npmjs.com/package/@gridboard/core)

## Installation

```sh
# npm
npm i @gridboard/core

# pnpm
pnpm i @gridboard/core

# Yarn
yarn add @gridboard/core
```

### Browser

```html

import { renderGrid } from 'https://unpkg.com/@gridboard/core?module';

```

## Usage

[See example](https://github.com/seanghay/gridboard/tree/main/packages/web)

```js
renderGrid({
width,
height,
gapSize: state.gridGap,
gapEdge: false,
spans: state.spans,
rowSize: state.gridRowSize,
columnSize: state.gridColumnSize,
render({
row, column,
cellHeight,
cellWidth,
position,
estimatedHeight,
estimatedWidth,
x,
y
}) {
ctx.fillStyle = '#eee';
ctx.fillRect(
x,
y,
cellWidth,
cellHeight
);
}
});
```

## Spans

Spans look like this `0:4!0:5, 0:4!4:4` where `row:columnSpanSize!column:rowSpanSize` separated by commas `,`

## License

MIT