Tyr


Contents
What is Tyr?
Tyr defines pages which will be available in Shuri by using components defined in Hela.
Both pages & components config are defined here.
But Tyr also integrates custom scripts to be used in Shuri (like ads) which doesn't belong to a Design System (ie: Hela).
And Tyr generates CSS (critical or not) for each page.
The final package also integrates fonts from Hela (no actions are performed on them).
Releasing a new version
If you made some direct changes in Tyr, you can create a new version:
- upgrade the
version
in package.json
- submit the PR
- once merged, create the release
- the package will be automatically published on NPM
If you made CSS or fonts changes in Hela, you might want to update the Hela package version as well:
- before each previous steps, update the hela package version in
package.json
- run
yarn
- follow previous steps
Adding a new page or component
Here is a PR where both a page & a component were added.
:warning: In both case, Hela might have to be updated to a new version (containing new components) in your PR.
A new page
In case you want to create a Contribution page.
- Declare the page type in
src/types/PageConfig.ts
- Create the page in
src/pages/ContributionPage/ContributionPage.tsx
. This define how the page will be rendered (you'll mostly use a template to render the page) - Create fixtures required for your page in
src/fixtures/contribution.json
- Define the storybook page in
src/pages/ContributionPage/ContributionPage.stories.tsx
which will re-use you previously defined fixtures & page - Export the page from the
src/pages/ContributionPage/index.ts
: export * from './ContributionPage'
- Create a new page config in
src/config/pageConfigs/ContributionPageConfig.ts
, required keys are:
name
: the name of the page in lowerCamelCasecomponent
: the component defined in src/pages/ContributionPage/ContributionPage.tsx
expiration
: TTL in minutes of the whole page (default is 300)components
: an array of components which are required to render the page (you might want the footer and the header which are in PAGE_TEMPLATE_COMPONENT_CONFIGS
)
A new component
- Declare the component type in
src/types/ComponentConfig.ts
(depending on which category it belong):
article
: if the component require some direct article information to be generated (like the title)common
: in case the component has nothing to deal with other things (like the footer, the direct, etc.)rubric
: the component needs a rubric to be generated (like most read)
- Define the component in
src/config/componentConfigs/component*Configs.ts
(depending on which category it belong), keys to define:
componentName
(required): use the name you defined in the first stepcomponent
(required): the component from Hela (don't forget to import it)expiration
(optional): TTL in minutes (default to 43200 (30j))
- Add the new component to one or more pages. For example if it belongs to an article:
- Edit
src/config/pageConfigs/articlePageConfig.ts
- Here are the required keys:
name
: use the name you defined in the first steprequired
: if the component is required to build the page (for example the title is required but social bar are optional)propName
: the prop name you used for your component in Hela
Developement
You'll need to check if everything is ok inside Storybook, so launch the hot reloading storybook:
yarn storybook
When working locally, you might need to build a shippable version of Tyr to be used in Shuri, use:
yarn build:local
And if you are only working on the article page, you can build HTML & CSS only for that page (it'll speed up the build) using:
PAGE=article yarn build:local
PAGE=tag yarn build:local
If you want to build for multiple pages, you can use coma:
PAGE=article,live yarn build:local
Testing
You can run tests either by:
- using vitest for unit tests
Linter
Unit tests