12.0.0 • Published 19 days ago

@financial-times/n-magnet v12.0.0

Weekly downloads
40
License
ISC
Repository
github
Last release
19 days ago

n-magnet CircleCI

  • orchestrates onward journey components (better promo, newsletters, etc)

Documentation

https://docs.google.com/document/d/1nJKG7-xOzZyhKTmJMz9M2FA9P-AQgOVPZD1F_MmX3o4/edit

Related flags

Related Repos

Using the component

Add the component

npm install @financial-times/n-magnet

Configuration

Some configuration variable can be overridden using ENV variables.

config nameenv nameexampledesc
demo.hostDEMO_HOSTlocal.ft.com
demo.portDEMO_PORT5005

Prepare DOM

The component expects some elements to be present in the DOM

  • .js-magnet-cta': required, the component will be loaded in this element
  • .js-magnet-data : optional, should contain a json object with the conceptIds used by the article
{{#if @root.flags.showArticleCTABloc}}
<script class="js-magnet-data" type="application/json">{{{json articleMainConcepts}}}</script>
<div class="magnet-cta js-magnet-cta" data-trackable="magnet-cta"></div>
{{/if}}

Initialise the component

  • simply call magnetInit() from n-magnet
import { magnetInit } from '@financial-times/n-magnet';

if(flags.get('showArticleCTABloc')) {
    magnetInit().then(()=>{
        const replacedItem = document.querySelector('.js-instant-alert-cta');
        replacedItem.style.display = 'none';
    })
    .catch((err) => {
        // fail silently
        // eslint-disable-next-line no-console
        console.debug('failed to init magnet', err);
    });
    }

Running tests

# linting, unit-test
make test
# unit test only
make unit-test
# without coverage
npm run jest 

Running the demo

make install
make demo

Known issues / to do

oGrid issue

Demo is broken by src/components/newsletter-signup/main.js

Error: main.js:14 Uncaught TypeError: oGrid.setMinSupportedIeVersion is not a function

Meaning the demo only works with eventpromo and newsletter-signup/main.js needs to be commented out...

Build process

After some struggle with the build process, styles and js are built separately.

This can probably be improved.

Prettier

Add prettier to the project?

Notes

When working on integration with next-article, it can be useful to tweak package.json like this:

  • use specific branch: @financial-times/n-magnet": "Financial-Times/n-magnet#magnet-api-integration",
  • use local package: @financial-times/n-magnet": "file:/home/devel/ft/n-magnet",
12.0.0

19 days ago

11.1.1

2 months ago

11.1.0

2 months ago

11.0.1

2 months ago

11.0.0

2 months ago

11.0.0-alpha.6

2 months ago

11.0.0-beta.1

2 months ago

11.0.0-alpha.5

2 months ago

11.0.0-alpha.1

2 months ago

11.0.0-alpha.3

2 months ago

11.0.0-alpha.4

2 months ago

10.0.4

4 months ago

10.0.0

10 months ago

10.0.1

6 months ago

10.0.2

6 months ago

10.0.3

6 months ago

9.4.1

11 months ago

9.3.1

1 year ago

9.3.0

1 year ago

9.2.0

2 years ago

9.1.0

2 years ago

9.0.1

2 years ago

9.0.0

2 years ago

6.0.1

2 years ago

7.0.3

2 years ago

7.0.2

2 years ago

7.0.1

2 years ago

8.0.0

2 years ago

7.0.0

2 years ago

6.0.0

2 years ago

5.0.0

2 years ago

4.2.2

3 years ago

4.2.1

3 years ago

4.1.0

3 years ago

4.2.0

3 years ago

4.0.3

3 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.0.1

4 years ago

3.0.1-beta.1

4 years ago

2.0.1

4 years ago

3.0.0

4 years ago

2.0.0

4 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago