# TDG Shared Components

A library of tools for JavaScript that occur frequently across the TDG digital estate.

## Modules

Modules are JavaScript functions created to make our lives easier. Each of these is self-contained and isolated, meaning they can be imported into projects on a case-by-case basis.

## Components

Components are responsible for rendering things onto the page. These visual elements contain as little styling as possible. Styles can be applied from the parent element.

## Types

Types include types for Drupal, our custom modules, and APIs that are typically accessed via different modules.

## FAQs

Q. Should I add my thing to this repo?

A. Probably, but only if it meets the criteria:

1. It's used in more than one project. Types for drupalSettings is a good example because it's used everywhere, and we can avoid unnecessary duplication by including it here.

2. It's self-contained, so doesn't depend on any internal logic. For example, if it uses window.drupalSettings, consider refactoring to pass this in as a parameter.

3. It's tested. We don't accept anything that does not have full type safety and a test suite (if it's a component or module).