3.1.20 • Published 12 months ago

@thi.ng/layout v3.1.20

Weekly downloads
17
License
Apache-2.0
Repository
github
Last release
12 months 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.1.20

12 months ago

3.1.19

1 year ago

3.1.18

1 year ago

3.1.17

1 year ago

3.1.14

1 year ago

3.1.16

1 year ago

3.1.15

1 year ago

3.1.13

1 year ago

3.1.12

1 year ago

3.1.11

1 year ago

3.1.10

1 year ago

3.1.9

1 year ago

3.1.8

1 year ago

3.1.7

1 year ago

3.1.6

1 year ago

3.1.5

1 year ago

3.1.3

1 year ago

3.1.2

1 year ago

3.1.1

2 years ago

3.1.0

2 years ago

3.1.4

1 year ago

3.0.45

2 years ago

3.0.46

2 years ago

3.0.43

2 years ago

3.0.44

2 years ago

3.0.47

2 years ago

3.0.41

2 years ago

3.0.42

2 years ago

3.0.40

2 years ago

3.0.39

2 years ago

3.0.38

2 years ago

3.0.37

2 years ago

3.0.36

2 years ago

3.0.35

2 years ago

3.0.34

2 years ago

3.0.33

2 years ago

3.0.32

2 years ago

3.0.31

2 years ago

3.0.30

2 years ago

3.0.29

2 years ago

3.0.28

2 years ago

3.0.27

2 years ago

3.0.26

2 years ago

3.0.25

2 years ago

3.0.24

2 years ago

3.0.23

2 years ago

3.0.22

2 years ago

3.0.21

2 years ago

3.0.20

2 years ago

3.0.19

2 years ago

3.0.16

2 years ago

3.0.17

2 years ago

3.0.15

2 years ago

3.0.18

2 years ago

3.0.14

2 years ago

3.0.13

2 years ago

3.0.12

2 years ago

3.0.11

2 years ago

3.0.10

2 years ago

3.0.8

2 years ago

3.0.9

2 years ago

3.0.7

2 years ago

3.0.6

2 years ago

3.0.4

2 years ago

3.0.3

2 years ago

3.0.1

2 years ago

3.0.5

2 years ago

3.0.0

2 years ago

2.1.29

3 years ago

2.1.34

3 years ago

2.1.35

2 years ago

2.1.32

3 years ago

2.1.33

3 years ago

2.1.30

3 years ago

2.1.31

3 years ago

2.1.28

3 years ago

2.1.27

3 years ago

2.1.25

3 years ago

2.1.26

3 years ago

2.1.24

3 years ago

2.1.23

3 years ago

2.1.22

3 years ago

2.1.19

3 years ago

2.1.21

3 years ago

2.1.20

3 years ago

2.1.16

3 years ago

2.1.17

3 years ago

2.1.14

3 years ago

2.1.15

3 years ago

2.1.13

3 years ago

2.1.18

3 years ago

2.1.12

3 years ago

2.1.9

4 years ago

2.1.10

4 years ago

2.1.11

4 years ago

2.1.6

4 years ago

2.1.8

4 years ago

2.1.7

4 years ago

2.1.5

4 years ago

2.1.4

4 years ago

2.0.7

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.3

4 years ago

2.1.0

4 years ago

2.0.4

4 years ago

2.0.6

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

0.1.38

5 years ago

0.1.37

5 years ago

0.1.36

5 years ago

0.1.35

5 years ago

0.1.34

5 years ago

0.1.30

5 years ago

0.1.31

5 years ago

0.1.32

5 years ago

0.1.33

5 years ago

0.1.29

5 years ago

0.1.28

5 years ago

0.1.27

5 years ago

0.1.26

5 years ago

0.1.25

5 years ago

0.1.24

5 years ago

0.1.23

5 years ago

0.1.22

5 years ago

0.1.21

6 years ago

0.1.20

6 years ago

0.1.19

6 years ago

0.1.18

6 years ago

0.1.17

6 years ago

0.1.16

6 years ago

0.1.15

6 years ago

0.1.14

6 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago