34.0.1 • Published 7 months ago

@guardian/atoms-rendering v34.0.1

Weekly downloads
641
License
MIT
Repository
github
Last release
7 months ago

Atoms Rendering

Atoms

Atoms Web Architecture

An Atom is a self contained piece of content that can be inserted into multiple articles. This repository implements atom definitions as part of a library which can be imported into the appropriate rendering service (dotcom-rendering or apps-rendering). Once imported, you can configure your rendering service to render the atom component for the atom data passed from your backend (frontend in the case of web).

Usage

import

To import an atom in your project use yarn add @guardian/atoms-rendering then

import { TheAtomYouWant } from '@guardian/atoms-rendering';

<TheAtomYouWant someProp={localData.someProp} />

Naming conventions

There is mostly a one to one correspondance between atoms as named by CAPI/frontend and their names in atoms-rendering, with the notable exception that the Media atom is named YoutubeAtom here.

Running locally

$ git clone https://github.com/guardian/atoms-rendering.git
or
$ git clone git@github.com:guardian/atoms-rendering.git

Make sure that you have yarn installed, if not run

$ brew install yarn

Then,

$ yarn
$ yarn storybook

The available yarn commands are given below:

    "scripts": {
        "build": "microbundle --jsx React.createElement",
        "dev": "microbundle watch --jsx React.createElement",
        "storybook": "start-storybook -p 6006",
        "build-storybook": "build-storybook",
        "tsc": "tsc",
        "lint": "eslint . --ext .ts",
        "test": "jest --watch"
    }

dev-nginx setup

Some of the storybook stories need to fetch YouTube scripts that are only available to clients with an allow-listed domain. YouTube has allow-listed dev-gutools.co.uk (along with dotcom code and prod domains). In order for these stories to run as expected locally, you'll need to use dev-nginx to proxy atoms-rendering.local.dev-gutools.co.uk to localhost. This can be set up by

Testing locally

If you want to test a change before publishing to NPM, you will need to point to this repository. For instance, you might want to check in dotcom-rendering on local that a change you make in this library is correct. For this do the following

  • In atoms-rendering run yarn build,
  • In atoms-rendering run yarn link, then
  • In dotcom-rendering run yarn link "@guardian/atoms-rendering".

Then you will notice that your

dotcom-rendering/node_modules/@guardian/atoms-rendering

is a symlink to the atoms-rendering repository.

When you are done, you should

  • In dotcom-rendering run yarn unlink "@guardian/atoms-rendering".
  • In atoms-rendering run yarn unlink

And in dotcom-rendering you might also want to run

  • yarn install --force, to get the regular package re-installed.

Adding a new atom

Adding a new atom in atoms-rendering involves

  1. Adding the component, eg. MyComponent.tsx - Make sure the outer component of the atom contains data-atom-id and data-atom-type in order to be picked up by teleporter. Here is an example
  2. Adding stories, eg. MyComponent.stories.tsx
  3. Adding a line to index.ts to export the component
  4. Publishing a new version of the library to Npm (see below)

An example PR for adding the Profile Atom can be found here. The component is defined in /src/ProfileAtom.tsx, with the supporting type ProfileAtomType in src/types.tsx. Types are transpiled when this project is built, and are made available to your rendering project when you include the published library as a dependency.

Releasing a new version / Publishing to NPM

atoms-rendering is now published to NPM using changesets

Generate a changeset describing your work by running yarn changeset and following the prompts.

Publishing is triggered by merging the auto-generated Bump Version PR that changesets manages.

Once complete, you can update the version of @guardian/atoms-rendering in any consuming project to see the changes.

Snyk Code Scanning

There's a Github action set up on the repository to scan for vulnerabilities. This is set to "continue on error" and so will show a green tick regardless. In order to check the vulnerabilities we can use the Github code scanning feature in the security tab and this will list all vulnerabilities for a given branch etc. You should use this if adding/removing/updating packages to see if there are any vulnerabilities.

32.3.0

9 months ago

32.2.1

10 months ago

32.2.2

10 months ago

32.2.0

10 months ago

32.2.3

9 months ago

33.0.0

9 months ago

32.1.0

10 months ago

34.0.1

7 months ago

34.0.0

7 months ago

32.0.1

10 months ago

31.0.0

11 months ago

32.0.0

11 months ago

30.0.0

12 months ago

29.0.0

1 year ago

28.0.0

1 year ago

29.1.0

1 year ago

29.1.1

1 year ago

29.1.2

1 year ago

25.1.6

1 year ago

27.0.0

1 year ago

26.0.0

1 year ago

23.8.1

1 year ago

23.11.0

1 year ago

25.1.5

1 year ago

25.1.4

1 year ago

25.1.1

1 year ago

25.1.0

1 year ago

25.1.3

1 year ago

25.1.2

1 year ago

23.9.0

1 year ago

25.0.2

1 year ago

25.0.1

1 year ago

25.0.4

1 year ago

25.0.3

1 year ago

25.0.0

1 year ago

23.10.0

1 year ago

24.0.0

1 year ago

23.8.0

1 year ago

23.7.1

2 years ago

23.7.0

2 years ago

23.7.2

2 years ago

23.4.0

2 years ago

23.5.0

2 years ago

23.6.0

2 years ago

23.2.2

2 years ago

23.2.1

2 years ago

23.3.1

2 years ago

23.2.0

2 years ago

23.0.0

2 years ago

23.0.2

2 years ago

23.0.1

2 years ago

22.6.3

2 years ago

22.6.2

2 years ago

22.6.1

2 years ago

22.6.0

2 years ago

23.1.2

2 years ago

23.1.1

2 years ago

23.1.0

2 years ago

22.5.3

2 years ago

22.2.1

2 years ago

22.2.0

2 years ago

22.3.0

2 years ago

22.4.0

2 years ago

22.5.0

2 years ago

22.1.1

2 years ago

22.1.0

2 years ago

22.0.1

2 years ago

22.0.0

2 years ago

21.0.0

3 years ago

20.0.0

3 years ago

19.0.0

3 years ago

18.0.3

3 years ago

18.0.2

3 years ago

18.0.1

3 years ago

18.0.0

3 years ago

17.0.1

3 years ago

17.0.0

3 years ago

16.0.0

3 years ago

15.0.0

3 years ago

14.1.0

3 years ago

14.2.0

3 years ago

14.2.1

3 years ago

14.0.0

3 years ago

13.0.0

3 years ago

12.2.0

3 years ago

12.1.0

3 years ago

12.0.0

3 years ago

11.0.0

3 years ago

11.0.1

3 years ago

11.1.0

3 years ago

11.0.0-0

3 years ago

10.0.2

3 years ago

10.0.1

3 years ago

10.0.0

3 years ago

9.1.0

3 years ago

9.1.0-0

3 years ago

9.0.0

3 years ago

8.1.0

3 years ago

8.1.2

3 years ago

8.1.1

3 years ago

8.2.0

3 years ago

8.0.2

3 years ago

7.1.3

3 years ago

7.1.2

3 years ago

8.0.0

3 years ago

7.1.0

3 years ago

7.0.1

3 years ago

7.0.0

3 years ago

6.0.0

3 years ago

5.0.0

3 years ago

4.2.0

3 years ago

4.1.0

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.4.1

3 years ago

2.4.0

3 years ago

2.3.1

3 years ago

2.3.0

3 years ago

2.0.9

3 years ago

2.0.8

3 years ago

2.0.7

3 years ago

2.0.6

3 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.13.0

4 years ago

1.12.0

4 years ago

1.11.2

4 years ago

1.11.1

4 years ago

1.11.0

4 years ago

1.10.0

4 years ago

1.9.0

4 years ago

1.8.2

4 years ago

1.8.1

4 years ago

1.8.0

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.2

4 years ago

0.0.0

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago