Skip to content

Commit

Permalink
Add usage section to readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-searle committed Apr 17, 2019
1 parent 65cbc15 commit 521c90d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions components/x-article-save-button/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ Feature | Type | Required | Default value | Descript
`csrfToken` | String | no | none | CSRF token (will be included in a hidden form field).
`trackableId` | String | no | `'save-for-later'` | Identifier for tracking purposes

## Usage

The components provided by this module are all functions that expect a map of [teaser properties](#properties). They can be used with vanilla JavaScript or JSX (If you are not familiar check out [WTF is JSX][jsx-wtf] first). For example if you were writing your application using React you could use the component like this:

```jsx
import React from 'react';
import { ArticleSaveButton } from '@financial-times/x-article-save-button';

// A == B == C
const a = ArticleSaveButton(props);
const b = <ArticleSaveButton {...props} />;
const c = React.createElement(ArticleSaveButton, props);
```

All `x-` components are designed to be compatible with a variety of runtimes, not just React. Check out the [`x-engine`][engine] documentation for a list of recommended libraries and frameworks.

[jsx-wtf]: https://jasonformat.com/wtf-is-jsx/

## Client side behaviour

For users with JavaScript enabled, the default form submit action is prevented, and a custom event (named 'x-article-save-button') will be dispatched on the form element.
Expand Down

0 comments on commit 521c90d

Please sign in to comment.