2.1.1 • Published 1 day ago

@thg-altitude/composites-teepee v2.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 day ago

TeePee Composites

What are composites

Composites are reusable elements/widgets that are interlinked with data from CMS systems (e.g. TeePee, HyGraph, etc). In this repository each composite is coupled to Ingenuity's TeePee CMS data structure.

Using a real example as reference the "GlobalFourBestSellers" composite would be capable of parsing the data format from TeePee. But inside of this composite it may then support multiple components imported via '@thg-altitude/components' to for carousels, pictures, icons.

To get the best out of a composite (and ensure it's capable of use across multiple tenants and storefronts) these are a helpful lists of do's and do not's.

Best Practices

  1. Do not depend on global context (for e.g. Astro.local data).

It's common across storefronts to use Astro.locals or other global context(s) provide easy access to utils. Use of these global objects will only ensure your composite can't be reused across codebases. Utilise props not global context.

  1. Do not heavily depend on components. Instead leverage slots to allow.

While it's common and an important to ensure a DRY codebase composite(s) the use of components needs to be carefully considered. Directly referencing elements (for e.g. Carousel's, Icons, ProductItems) increases the data requirements of the composite but also restrict how flexible and reusable they are across codebases.

Use <slot /> or named slots to decouple components from elements of business logic.

  1. Do not depend on shared utils.

Where possible do not use shared utilities that are nuanced with a specific tenant or storefront solution. Being forced to use utils is a sign that best practice #2 isn't being followed.

Working Example

A 'GlobalFourBestSellers' is commonly made up of a carousel, carousel item and product item(s). A product item requires properties that warrant calculating price, currency and language.

Instead of modifying 'GlobalFourBestSellers' to recieve all of this information via props and feeing these into directly imported dependencies.

Moving the loop and the product items into the content of the slot you drastically increase the re-usability of the composite and the flexibility of whats possible in the storefront.

  1. Alpha Builds
  • Label the version as x.x.x-alpha in the package & package-lock
  • npm publish (no merge to main)
  • once reviewed, merge to main, update to non-alpha, and npm publish
2.1.1

1 day ago

2.1.1-alpha

1 day ago

2.1.0

3 days ago

2.0.7-479-INV

9 days ago

2.0.7-479-INV-2

9 days ago

2.0.7

11 days ago

2.0.6-alpha

14 days ago

2.0.5-alpha

21 days ago

2.0.4-alpha

24 days ago

2.0.2-alpha

1 month ago

2.0.3-alpha

1 month ago

2.0.0-alpha

1 month ago

1.1.4

2 months ago

1.1.1

2 months ago

1.1.3

2 months ago

1.1.2

2 months ago

1.1.0-alpha

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago