Getting Started with Atoms
As the name suggests, Atom is the smallest part into which an element can be divided. In Helium, components are the smallest running unit of code, hence we name them as Atoms. There are specifically named components in Thought Industries which are replacable when re-defined inside atoms folder.
When rendering components in the Thought Industries platform, if a suitable Atom replacement is found in the
window.TiAtomsproperty, the provided component will be rendered instead. The props and actions that would regularly be passed to the Thought Industries component will be passed to the Atom component instead.
Requirements
If you would like to update a project to include Atoms, there are several requirements that need to be met:
An authenticated Helium project, create a helium project here.
Within the Helium project, there must be an
/atoms/directory in the project root. Within the atoms directory, there should be anindex.tsfile assigning any components you would like to deploy towindow.TiAtomsas seen here.
Note: The name of the component file must be the same as the component it's intended to replace. For example: this file would be rendered anywhere the Thought Industries platform would render an AudioPlayerBar component.
A
vite.atoms.config.tsfile within the Helium project, as seen hereMust include
@thoughtindustries/heliumat version 1.2.0-beta.1 or higher in your project's dependencies.Must update
package.json#scriptswith these commands:
"build:vite": "vite build",
"build:atoms": "vite build -c vite.atoms.config.ts && vite build"
Testing locally:
To test the atoms locally:
- Utilize these components as normal components (importing, rendering etc.). This means they will have to be tested on a local page on your localhost environment (dashboard, home, catalog etc.).
- Once you are happy with your new component, you should move the code to the Atoms/{component} file, and revert the changes you have made during testing.
- After deployment, Atoms will be preferred over regular components on non-helium pages.
As of now, there are only 3 type of Atoms:
- Audio Player - (AudioPlayerBar)
- Home Header - (HomeHeader)
- Learner Dash - (LearnerDashHeader)
Environment Variables
To use a environment variable in an Atom, prefix the variable with 'VITE_', like this:
VITE_APP_VERSION='v1'
Environment Variables should not contain secrets as they are processed client side.