3.0.38 • Published 5 days ago

@thi.ng/layout v3.0.38

Weekly downloads
17
License
Apache-2.0
Repository
github
Last release
5 days ago

layout

npm version npm downloads Twitter Follow

This project is part of the @thi.ng/umbrella monorepo.

About

Configurable nested 2D grid layout manager.

Currently, this package features only a single grid layout allocator, as well as more generic supporting types to define other layout types / implementations.

Status

STABLE - used in production

Search or submit any issues for this package

Installation

yarn add @thi.ng/layout

ES module import:

<script type="module" src="https://cdn.skypack.dev/@thi.ng/layout"></script>

Skypack documentation

For Node.js REPL:

# with flag only for < v16
node --experimental-repl-await

> const layout = await import("@thi.ng/layout");

Package sizes (gzipped, pre-treeshake): ESM: 677 bytes

Dependencies

Usage examples

Several demos in this repo's /examples directory are using this package.

A selection:

ScreenshotDescriptionLive demoSource
Interactive inverse FFT toy synthDemoSource
Canvas based Immediate Mode GUI componentsDemoSource
Minimal IMGUI usage exampleDemoSource

API

Generated API docs

GridLayout

The GridLayout class supports infinite nesting and column/row-based space allocation, based on an initial configuration and supporting multiple column/row spans.

screenshot

The code producing this structure:

import { gridLayout } from "@thi.ng/layout";

// create a single column layout @ position 10,10 / 200px wide
// the last values are row height and cell spacing
const layout = gridLayout(10, 10, 200, 1, 16, 4);

// get next layout box (1st row)
// usually you don't need to call .next() manually, but merely pass
// the layout instance to a component...
layout.next();
// { x: 10, y: 10, w: 200, h: 16, cw: 200, ch: 16, gap: 4 }

// 2nd row
layout.next();
// { x: 10, y: 30, w: 200, h: 16, cw: 200, ch: 16, gap: 4 }

// create nested 2-column layout (3rd row)
const twoCols = layout.nest(2);

twoCols.next();
// { x: 10, y: 50, w: 98, h: 16, cw: 98, ch: 16, gap: 4 }

twoCols.next();
// { x: 112, y: 50, w: 98, h: 16, cw: 98, ch: 16, gap: 4 }

// now nest 3-columns in the 1st column of twoCols
// (i.e. now each column is 1/6th of the main layout's width)
const inner = twoCols.nest(3);

// allocate with col/rowspan, here 1 column x 4 rows
inner.next([1, 4])
// { x: 10, y: 70, w: 30, h: 76, cw: 30, ch: 16, gap: 4 }
inner.next([1, 4])
// { x: 44, y: 70, w: 30, h: 76, cw: 30, ch: 16, gap: 4 }
inner.next([1, 4])
// { x: 78, y: 70, w: 30, h: 76, cw: 30, ch: 16, gap: 4 }

// back to twoCols (2nd column)
twoCols.next([1, 2]);
// { x: 112, y: 70, w: 98, h: 36, cw: 98, ch: 16, gap: 4 }

Authors

Karsten Schmidt

If this project contributes to an academic publication, please cite it as:

@misc{thing-layout,
  title = "@thi.ng/layout",
  author = "Karsten Schmidt",
  note = "https://thi.ng/layout",
  year = 2019
}

License

© 2019 - 2021 Karsten Schmidt // Apache Software License 2.0

3.0.38

5 days ago

3.0.37

8 days ago

3.0.36

17 days ago

3.0.35

20 days ago

3.0.34

1 month ago

3.0.33

1 month ago

3.0.32

1 month ago

3.0.31

1 month ago

3.0.30

1 month ago

3.0.29

1 month ago

3.0.28

2 months ago

3.0.27

2 months ago

3.0.26

2 months ago

3.0.25

2 months ago

3.0.24

2 months ago

3.0.23

2 months ago

3.0.22

2 months ago

3.0.21

2 months ago

3.0.20

2 months ago

3.0.19

3 months ago

3.0.16

3 months ago

3.0.17

3 months ago

3.0.15

3 months ago

3.0.18

3 months ago

3.0.14

3 months ago

3.0.13

3 months ago

3.0.12

4 months ago

3.0.11

4 months ago

3.0.10

4 months ago

3.0.8

4 months ago

3.0.9

4 months ago

3.0.7

5 months ago

3.0.6

5 months ago

3.0.4

5 months ago

3.0.3

6 months ago

3.0.1

6 months ago

3.0.5

5 months ago

3.0.0

6 months ago

2.1.29

9 months ago

2.1.34

8 months ago

2.1.35

6 months ago

2.1.32

9 months ago

2.1.33

8 months ago

2.1.30

9 months ago

2.1.31

9 months ago

2.1.28

11 months ago

2.1.27

12 months ago

2.1.25

1 year ago

2.1.26

1 year ago

2.1.24

1 year ago

2.1.23

1 year ago

2.1.22

1 year ago

2.1.19

1 year ago

2.1.21

1 year ago

2.1.20

1 year ago

2.1.16

2 years ago

2.1.17

1 year ago

2.1.14

2 years ago

2.1.15

2 years ago

2.1.13

2 years ago

2.1.18

1 year ago

2.1.12

2 years ago

2.1.9

2 years ago

2.1.10

2 years ago

2.1.11

2 years ago

2.1.6

2 years ago

2.1.8

2 years ago

2.1.7

2 years ago

2.1.5

2 years ago

2.1.4

2 years ago

2.0.7

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.3

2 years ago

2.1.0

2 years ago

2.0.4

3 years ago

2.0.6

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

0.1.38

3 years ago

0.1.37

3 years ago

0.1.36

3 years ago

0.1.35

3 years ago

0.1.34

3 years ago

0.1.30

3 years ago

0.1.31

3 years ago

0.1.32

3 years ago

0.1.33

3 years ago

0.1.29

3 years ago

0.1.28

3 years ago

0.1.27

3 years ago

0.1.26

3 years ago

0.1.25

3 years ago

0.1.24

3 years ago

0.1.23

4 years ago

0.1.22

4 years ago

0.1.21

4 years ago

0.1.20

4 years ago

0.1.19

4 years ago

0.1.18

4 years ago

0.1.17

4 years ago

0.1.16

4 years ago

0.1.15

4 years ago

0.1.14

4 years ago

0.1.13

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago