0.4.26 • Published 3 days ago

@myadbox/nebula-template-utils v0.4.26

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
3 days ago

Nebula Template Utils

Template-related utilities for use in Nebula and Exoplanet repos.

Table of contents

Introducing Nebula Template Utils

Nebula Template Utils provides a set of tools that bridge the divide between the Exoplanet repository and the Nebula repository. Many of these tools are used in both repos and provide consistency and interoperability between the two.

Much of this README pertains to users of Exoplanet repo, but there are many more features yet to be better documented.

About size preset categories

In order for the Sesimi app to know how to display a template’s preview to a user, we need to have set at least one size preset in the template config’s sizes array.

Size preset categories—such as newspaper, bannerAd and social—contain a structured (and growing) set of sizes from which we can compile a suitable list and add it to our template config’s sizes property. Ultimately, this list of presets (containing media dimensions, default formats and descriptive labels) is presented to a user as being well-supported choices for them to select and produce media from.

Categories list

Follow this link to view a flattened table detailing every current preset.

An example of preset category:

const exportDefaults = `print`

export const newspaper = {
  tallTabloid: {
    sizes: {
      fullPage: {
        label: `Tall tabloid full page`,
        width: 990,
        height: 1361,
        exportDefaults,
      },
      halfPage: {
        label: `Tall tabloid half page`,
        width: 990,
        height: 661,
        exportDefaults,
      },
    },
  },

  compactTabloid: {
    sizes: {
      fullPage: {
        label: `Compact tabloid full page`,
        width: 990,
        height: 1008,
        exportDefaults,
      },
    },
  },
}

Getting started

  1. Open /src//brands/your template folder/data/config.mjs
  2. Edit the config.mjs sizes and defaultSize objects to required sizes

Have a read of this snippet:

import {defineConfig, embedSizes, allSizes} from '@myadbox/nebula-template-utils'

export default defineConfig({
  sizes: embedSizes({
    support: {
      categories: [allSizes.newspaper, allSizes.paper.iso.a.a4, allSizes.paper.us.letter],
      specific: [allSizes.paper.iso.a.a4.sizes.portrait],
    },
  }),
  defaultSize: allSizes.newspaper.compactTabloid.sizes.fullPage.label,

  // the rest of config
  // fields: [...

})

The template default gives you a head start by importing what’s necessary, all you have to do is edit what’s there so let’s look at that step by step:

defineConfigrequired, do not edit

export default defineConfig({

This begins defining the object that becomes the entire JSON config data bundled with the template’s zip archive, and read by the Sesimi app to create the customised build form for the template. Wrapping the config object in this defineConfig function call enables VS Code to check your progress as you fill out the config object and alert you with red underlines when anything is incorrectly specified.

embedSizesrequired, do not edit

sizes: embedSizes({
  support: {

This embeds sizes available to the user. What is set here will show in their dropdown list.

categoriesoptional

    categories: [allSizes.newspaper, allSizes.paper.iso.a.a4, allSizes.paper.us.letter],

To display a full category for user selection, use categories.

E.g. allSizes.newspaper will display every available newspaper option.

This can be narrowed down if you only want to display a section of the whole category.

E.g. allSizes.newspaper.tallTabloid

Another example is isolating to A4, but both portrait and landscape options:

allSizes.paper.iso.a.a4

specificoptional

    specific: [allSizes.paper.iso.a.a4.sizes.portrait],

To display a specific size only, use specific. Note that while this is marked as "optional" there must be at least one size in a config’s sizes array. This specific option is often used to provide that when only one size is supported.

E.g. allSizes.paper.iso.a.a4.sizes.portrait will display A4 portrait only.

You can add as many specific sizes as needed, separated by a comma:

E.g. allSizes.social.facebook.main.sizes.linkPost, allSizes.social.instagram.main.sizes.post will display two social media size options for the user.

defaultSize — required

defaultSize: allSizes.paper.iso.a.a4.sizes.portrait.label, // NOTE: .label is important

To give the user an initial selected size, use defaultSize. This must be appended with .label to display the label in the select.

Modifying existing presets

You can optionally modify the format and/or quality of the embedded sizes. For example, if you want, say, the bannerAd category of sizes, but your template is animated, you'll want to override the default format (JPG) to be HTML. You can do this by passing the sizes you got via embedSizes into the modifySizes function, like so:

import {defineConfig, embedSizes, modifySizes, allSizes, Format} from '@myadbox/nebula-template-utils'

// for clarity, create a variable of the embedSizes result
const sizes = embedSizes({
  support: {
    categories: [allSizes.bannerAd],
  },
})

// pass in your sizes, along with an object that will override properties of each size
const modifiedSizes = modifySizes(sizes, {format: Format.Html})

export default defineConfig({
  // add the modified sizes to the config
  sizes: modifiedSizes,
  // ... config continues ...

Custom labels and sizes (TODO)

Contributing

To publish a new version, increment the version number in package.json and then run the following from the client workspace root:

yarn nx run @myadbox/nebula-template-utils:build && node ./tools/scripts/publish.mjs @myadbox/nebula-template-utils [ insert
your new version number here] latest
0.4.26

3 days ago

0.4.24

4 days ago

0.4.25

3 days ago

0.4.22

1 month ago

0.4.21

2 months ago

0.4.20

2 months ago

0.4.19

2 months ago

0.4.18

3 months ago

0.4.17

3 months ago

0.4.9

7 months ago

0.4.8

9 months ago

0.4.10

7 months ago

0.4.15

7 months ago

0.4.16

5 months ago

0.4.13

7 months ago

0.4.14

7 months ago

0.4.11

7 months ago

0.4.12

7 months ago

0.4.5

10 months ago

0.4.4

10 months ago

0.4.7

9 months ago

0.4.6

10 months ago

0.4.3

10 months ago

0.3.0

11 months ago

0.4.1

11 months ago

0.4.0

11 months ago

0.4.2

11 months ago

0.2.3

12 months ago

0.1.0

1 year ago

0.1.1

1 year ago

0.2.1

1 year ago

0.0.97

1 year ago

0.0.98

1 year ago

0.0.96

1 year ago

0.0.94

1 year ago

0.0.85

2 years ago

0.0.86

2 years ago

0.0.87

2 years ago

0.0.88

2 years ago

0.0.89

2 years ago

0.0.90

2 years ago

0.0.84

2 years ago

0.0.83

2 years ago

0.0.82

2 years ago

0.0.81

2 years ago

0.0.80

2 years ago

0.0.79

2 years ago

0.0.78

2 years ago

0.0.76

2 years ago

0.0.75

2 years ago

0.0.74

2 years ago

0.0.73

2 years ago

0.0.72

2 years ago

0.0.71

2 years ago

0.0.70

2 years ago

0.0.69

2 years ago

0.0.68

2 years ago

0.0.67

2 years ago

0.0.66

2 years ago

0.0.65

2 years ago

0.0.64

2 years ago

0.0.63

2 years ago

0.0.62

2 years ago

0.0.61

2 years ago

0.0.60

2 years ago

0.0.59

2 years ago

0.0.58

2 years ago

0.0.57

2 years ago

0.0.56

2 years ago

0.0.55

2 years ago

0.0.54

2 years ago

0.0.53

2 years ago

0.0.52

2 years ago

0.0.51

2 years ago

0.0.50

2 years ago

0.0.49

2 years ago

0.0.48

2 years ago

0.0.47

2 years ago

0.0.46

2 years ago

0.0.45

2 years ago

0.0.44

2 years ago

0.0.43

2 years ago

0.0.42

2 years ago

0.0.41

2 years ago

0.0.40

2 years ago

0.0.39

2 years ago

0.0.38

2 years ago

0.0.37

2 years ago

0.0.36

2 years ago

0.0.35

2 years ago

0.0.34

2 years ago

0.0.33

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago