nativescript-grid-template

This little helper allows you to use NativeScript [GridLayout][] with CSS [grid-template-areas][css] values.

Usage no npm install needed!

<script type="module">
  import nativescriptGridTemplate from 'https://cdn.skypack.dev/nativescript-grid-template';
</script>

README

NativeScript Grid Template

This little helper allows you to use NativeScript GridLayout with CSS grid-template-areas values.

Example usage with Svelte Native (config adapted from https://www.cssgridplayground.com/):

<script>
  import gridTemplateAreas from "nativescript-grid-template";
  const areas = gridTemplateAreas(`
    header header header
    sidebar main aside
    sidebar footer footer
  `);
</script>

<gridLayout rows="*, 5*, *" columns="*, 5*, 2*" orientation="vertical">
  <label text="header" {...areas.header} />
  <label text="sidebar" {...areas.sidebar} />
  <label text="main" {...areas.main} />
  <label text="aside" {...areas.aside} />
  <label text="footer" {...areas.footer} />
</gridLayout>

This is only tested briefly. For invalid inputs, like this one:

a a a
a b b
a b c

behaviour is undefined. MRs adding validation are welcome!